aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_c2s.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-05-30 21:55:09 +0100
committerMatthew Wild <mwild1@gmail.com>2018-05-30 21:55:09 +0100
commit255e6f19d3c578b577576e4975ce5bde4454db0c (patch)
treec11212fdc293b35e1989e38b7e51ded86d2ad267 /plugins/mod_c2s.lua
parent0fd614dbab5caba118f3037f94e3beb8472c1a97 (diff)
parenta65f49b7992b20cb7c59b3a377a857e0dc426701 (diff)
downloadprosody-255e6f19d3c578b577576e4975ce5bde4454db0c.tar.gz
prosody-255e6f19d3c578b577576e4975ce5bde4454db0c.zip
Merge 0.9->0.10
Diffstat (limited to 'plugins/mod_c2s.lua')
-rw-r--r--plugins/mod_c2s.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index 8bcce6d8..7f0d1b01 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -49,12 +49,19 @@ local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
function stream_callbacks.streamopened(session, attr)
local send = session.send;
- session.host = nameprep(attr.to);
- if not session.host then
+ local host = nameprep(attr.to);
+ if not host then
session:close{ condition = "improper-addressing",
text = "A valid 'to' attribute is required on stream headers" };
return;
end
+ if not session.host then
+ session.host = host;
+ elseif session.host ~= host then
+ session:close{ condition = "not-authorized",
+ text = "The 'to' attribute must remain the same across stream restarts" };
+ return;
+ end
session.version = tonumber(attr.version) or 0;
session.streamid = uuid_generate();
(session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host);