Software /
code /
prosody
Changeset
4591:75b3d0c301d0
Merge with Zash
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 07 Mar 2012 20:11:01 +0000 |
parents | 4589:8553d822f417 (diff) 4590:883611842d3a (current diff) |
children | 4593:470f502f02a3 4594:565ea0c1a7ea |
files | plugins/s2s/mod_s2s.lua |
diffstat | 1 files changed, 27 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/s2s/mod_s2s.lua Sun Mar 04 17:39:19 2012 +0100 +++ b/plugins/s2s/mod_s2s.lua Wed Mar 07 20:11:01 2012 +0000 @@ -168,9 +168,33 @@ if session.direction == "incoming" then -- Send a reply stream header - session.to_host = attr.to and nameprep(attr.to); - session.from_host = attr.from and nameprep(attr.from); - + + -- Validate to/from + local to, from = nameprep(attr.to), nameprep(attr.from); + if not to and attr.to then -- COMPAT: Some servers do not reliably set 'to' (especially on stream restarts) + session:close({ condition = "improper-addressing", text = "Invalid 'to' address" }); + return; + end + if not from and attr.from then -- COMPAT: Some servers do not reliably set 'from' (especially on stream restarts) + session:close({ condition = "improper-addressing", text = "Invalid 'from' address" }); + return; + end + + -- Set session.[from/to]_host if they have not been set already and if + -- this session isn't already authenticated + if session.type == "s2sin_unauthed" and from and not session.from_host then + session.from_host = from; + elseif from ~= session.from_host then + session:close({ condition = "improper-addressing", text = "New stream 'from' attribute does not match original" }); + return; + end + if session.type == "s2sin_unauthed" and to and not session.to_host then + session.to_host = to; + elseif to ~= session.to_host then + session:close({ condition = "improper-addressing", text = "New stream 'to' attribute does not match original" }); + return; + end + session.streamid = uuid_gen(); (session.log or log)("debug", "Incoming s2s received %s", st.stanza("stream:stream", attr):top_tag()); if session.to_host then