Software /
code /
prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 5669:9345c161481f
mod_c2s, mod_s2s: Fire an event on read timeouts
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 11 Jun 2013 21:36:15 +0200 |
parent | 5661:f226a0d23e85 |
child | 5713:5cf6dedf36f4 |
comparison
equal
deleted
inserted
replaced
5668:5a9318ac92f6 | 5669:9345c161481f |
---|---|
133 return false; | 133 return false; |
134 end | 134 end |
135 return true; | 135 return true; |
136 end | 136 end |
137 | 137 |
138 local function keepalive(event) | |
139 return event.session.sends2s(' '); | |
140 end | |
141 | |
138 function module.add_host(module) | 142 function module.add_host(module) |
139 if module:get_option_boolean("disallow_s2s", false) then | 143 if module:get_option_boolean("disallow_s2s", false) then |
140 module:log("warn", "The 'disallow_s2s' config option is deprecated, please see http://prosody.im/doc/s2s#disabling"); | 144 module:log("warn", "The 'disallow_s2s' config option is deprecated, please see http://prosody.im/doc/s2s#disabling"); |
141 return nil, "This host has disallow_s2s set"; | 145 return nil, "This host has disallow_s2s set"; |
142 end | 146 end |
143 module:hook("route/remote", route_to_existing_session, -1); | 147 module:hook("route/remote", route_to_existing_session, -1); |
144 module:hook("route/remote", route_to_new_session, -10); | 148 module:hook("route/remote", route_to_new_session, -10); |
145 module:hook("s2s-authenticated", make_authenticated, -1); | 149 module:hook("s2s-authenticated", make_authenticated, -1); |
150 module:hook("s2s-read-timeout", keepalive, -1); | |
146 end | 151 end |
147 | 152 |
148 -- Stream is authorised, and ready for normal stanzas | 153 -- Stream is authorised, and ready for normal stanzas |
149 function mark_connected(session) | 154 function mark_connected(session) |
150 local sendq, send = session.sendq, session.sends2s; | 155 local sendq, send = session.sendq, session.sends2s; |
626 end | 631 end |
627 | 632 |
628 function listener.onreadtimeout(conn) | 633 function listener.onreadtimeout(conn) |
629 local session = sessions[conn]; | 634 local session = sessions[conn]; |
630 if session then | 635 if session then |
631 return session.sends2s(' '); | 636 return (hosts[session.host] or prosody).events.fire_event("s2s-read-timeout", { session = session }); |
632 end | 637 end |
633 end | 638 end |
634 | 639 |
635 function listener.register_outgoing(conn, session) | 640 function listener.register_outgoing(conn, session) |
636 session.direction = "outgoing"; | 641 session.direction = "outgoing"; |