function listener.onreadtimeout(conn)
local session = sessions[conn];
if session then
- return session.send(' ');
+ return (hosts[session.host] or prosody).events.fire_event("c2s-read-timeout", { session = session });
end
end
+local function keepalive(event)
+ return event.session.send(' ');
+end
+
function listener.associate_session(conn, session)
sessions[conn] = session;
end
-function module.add_host() end
+function module.add_host(module)
+ module:hook("c2s-read-timeout", keepalive, -1);
+end
+
+module:hook("c2s-read-timeout", keepalive, -1);
module:hook("server-stopping", function(event)
local reason = event.reason;
return true;
end
+local function keepalive(event)
+ return event.session.sends2s(' ');
+end
+
function module.add_host(module)
if module:get_option_boolean("disallow_s2s", false) then
module:log("warn", "The 'disallow_s2s' config option is deprecated, please see http://prosody.im/doc/s2s#disabling");
module:hook("route/remote", route_to_existing_session, -1);
module:hook("route/remote", route_to_new_session, -10);
module:hook("s2s-authenticated", make_authenticated, -1);
+ module:hook("s2s-read-timeout", keepalive, -1);
end
-- Stream is authorised, and ready for normal stanzas
function listener.onreadtimeout(conn)
local session = sessions[conn];
if session then
- return session.sends2s(' ');
+ return (hosts[session.host] or prosody).events.fire_event("s2s-read-timeout", { session = session });
end
end