Software /
code /
prosody-modules
Comparison
mod_s2s_keepalive/mod_s2s_keepalive.lua @ 3771:98e1e3ce307d
mod_s2s_keepalive: Invert check to work with bidi connections
When mod_s2s_bidi is active there may be s2sin connections in the s2sout
map, which made this not work correctly.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 23 Dec 2019 01:12:10 +0100 |
parent | 3770:ae34ee0867f0 |
child | 3772:22f02716819f |
comparison
equal
deleted
inserted
replaced
3770:ae34ee0867f0 | 3771:98e1e3ce307d |
---|---|
10 | 10 |
11 local function send_pings() | 11 local function send_pings() |
12 local ping_hosts = {}; | 12 local ping_hosts = {}; |
13 | 13 |
14 for remote_domain, session in pairs(s2sout) do | 14 for remote_domain, session in pairs(s2sout) do |
15 if session.type == "s2sout" -- as opposed to _unauthed | 15 if session.type ~= "s2sout_unauthed" |
16 and (not(keepalive_servers) or keepalive_servers:contains(remote_domain)) then | 16 and (not(keepalive_servers) or keepalive_servers:contains(remote_domain)) then |
17 session.sends2s(st.iq({ to = remote_domain, type = "get", from = host, id = "keepalive" }) | 17 session.sends2s(st.iq({ to = remote_domain, type = "get", from = host, id = "keepalive" }) |
18 :tag("ping", { xmlns = "urn:xmpp:ping" }) | 18 :tag("ping", { xmlns = "urn:xmpp:ping" }) |
19 ); | 19 ); |
20 end | 20 end |
21 end | 21 end |
22 | 22 |
23 for session in pairs(prosody.incoming_s2s) do | 23 for session in pairs(prosody.incoming_s2s) do |
24 if session.type == "s2sin" -- as opposed to _unauthed | 24 if session.type ~= "s2sin_unauthed" |
25 and (not(keepalive_servers) or keepalive_servers:contains(session.from_host)) then | 25 and (not(keepalive_servers) or keepalive_servers:contains(session.from_host)) then |
26 if not s2sout[session.from_host] then ping_hosts[session.from_host] = true; end | 26 if not s2sout[session.from_host] then ping_hosts[session.from_host] = true; end |
27 session.sends2s " "; | 27 session.sends2s " "; |
28 -- If the connection is dead, this should make it time out. | 28 -- If the connection is dead, this should make it time out. |
29 end | 29 end |