# HG changeset patch # User Kim Alvefur # Date 1601730468 -7200 # Node ID 5bcddab1659bdb37746ad5dba30cc413cd709451 # Parent d60094d9b4589952daad6d7fea8618192ff27090# Parent 1aea75b63d0ac6193fb08b6591d0c6859eefbce2 Merge 0.11->trunk diff -r d60094d9b458 -r 5bcddab1659b plugins/mod_bosh.lua --- a/plugins/mod_bosh.lua Fri Oct 02 16:44:30 2020 +0100 +++ b/plugins/mod_bosh.lua Sat Oct 03 15:07:48 2020 +0200 @@ -282,7 +282,6 @@ end local to_host = nameprep(attr.to); - local wait = tonumber(attr.wait); if not to_host then log("debug", "BOSH client tried to connect to invalid host: %s", attr.to); report_bad_host(); @@ -291,6 +290,24 @@ response:send(tostring(close_reply)); return; end + + if not prosody.hosts[to_host] then + log("debug", "BOSH client tried to connect to non-existant host: %s", attr.to); + local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", + ["xmlns:stream"] = xmlns_streams, condition = "improper-addressing" }); + response:send(tostring(close_reply)); + return; + end + + if prosody.hosts[to_host].type ~= "local" then + log("debug", "BOSH client tried to connect to %s host: %s", prosody.hosts[to_host].type, attr.to); + local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", + ["xmlns:stream"] = xmlns_streams, condition = "improper-addressing" }); + response:send(tostring(close_reply)); + return; + end + + local wait = tonumber(attr.wait); if not rid or (not attr.wait or not wait or wait < 0 or wait % 1 ~= 0) then log("debug", "BOSH client sent invalid rid or wait attributes: rid=%s, wait=%s", attr.rid, attr.wait); local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate",