aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_bosh.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-10-03 15:03:09 +0200
committerKim Alvefur <zash@zash.se>2020-10-03 15:03:09 +0200
commit62eee94e2bc04402be96786a7a83ade4a3728807 (patch)
treedbee876a8485f346d3efe53f216009251bc21542 /plugins/mod_bosh.lua
parent8f2b039615bc244e91527fb690250626f3c18159 (diff)
downloadprosody-62eee94e2bc04402be96786a7a83ade4a3728807.tar.gz
prosody-62eee94e2bc04402be96786a7a83ade4a3728807.zip
mod_bosh: Ensure that stream is directed to a VirtualHost (fixes #425)
Diffstat (limited to 'plugins/mod_bosh.lua')
-rw-r--r--plugins/mod_bosh.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua
index 7f750613..52168670 100644
--- a/plugins/mod_bosh.lua
+++ b/plugins/mod_bosh.lua
@@ -277,6 +277,22 @@ function stream_callbacks.streamopened(context, attr)
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", tostring(attr.rid), tostring(attr.wait));