Software /
code /
prosody
Changeset
8844:29c6d2681bad 0.9.14
mod_c2s: Do not allow the stream 'to' to change across stream restarts (fixes #1147)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 25 May 2018 21:09:34 +0200 |
parents | 8587:986c3e22ec32 |
children | 8845:c6b45cac9423 |
files | plugins/mod_c2s.lua |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Wed Jan 10 15:15:25 2018 +0000 +++ b/plugins/mod_c2s.lua Fri May 25 21:09:34 2018 +0200 @@ -40,12 +40,19 @@ 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);