aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-06-11 21:36:15 +0200
committerKim Alvefur <zash@zash.se>2013-06-11 21:36:15 +0200
commit4c9866805e69426b720586141c73d94fc4a54cd5 (patch)
treeb32edde961413150280e7ba6efa7492ae42b60bc
parentb6ecf01333bcb773beb784e2be93af305dd1cf01 (diff)
downloadprosody-4c9866805e69426b720586141c73d94fc4a54cd5.tar.gz
prosody-4c9866805e69426b720586141c73d94fc4a54cd5.zip
mod_c2s, mod_s2s: Fire an event on read timeouts
-rw-r--r--plugins/mod_c2s.lua12
-rw-r--r--plugins/mod_s2s/mod_s2s.lua7
2 files changed, 16 insertions, 3 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index d87b3415..91bde574 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -265,15 +265,23 @@ end
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;
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua
index bce617ca..5e50e88b 100644
--- a/plugins/mod_s2s/mod_s2s.lua
+++ b/plugins/mod_s2s/mod_s2s.lua
@@ -135,6 +135,10 @@ function route_to_new_session(event)
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");
@@ -143,6 +147,7 @@ function module.add_host(module)
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
@@ -628,7 +633,7 @@ end
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