Software /
code /
prosody
Comparison
plugins/mod_s2s.lua @ 11704:0a8671f32424
mod_s2s: Guard against missing 'to' on incoming stream
Given an incoming <stream:stream from="example.com"> this line would
have mistakenly reported the 'from' as the local host. Neither are
technically required and may be missing, especially on connections used
only for Dialback.
Outgoing connections initiated by Prosody always have 'from_host' and
'to_host', so it is safer to check it this way.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 18 Jul 2021 09:08:04 +0200 |
parent | 11684:8b0baf3003fb |
child | 11705:7132acfd287e |
comparison
equal
deleted
inserted
replaced
11703:e57c5d9c722c | 11704:0a8671f32424 |
---|---|
612 else | 612 else |
613 session:open_stream(session.from_host, session.to_host); | 613 session:open_stream(session.from_host, session.to_host); |
614 end | 614 end |
615 end | 615 end |
616 | 616 |
617 local this_host = session.direction == "incoming" and session.to_host or session.from_host | 617 local this_host = session.direction == "outgoing" and session.from_host or session.to_host |
618 | 618 |
619 if reason then -- nil == no err, initiated by us, false == initiated by remote | 619 if reason then -- nil == no err, initiated by us, false == initiated by remote |
620 local stream_error; | 620 local stream_error; |
621 local condition, text, extra | 621 local condition, text, extra |
622 if type(reason) == "string" then -- assume stream error | 622 if type(reason) == "string" then -- assume stream error |