aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_component.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-02-10 21:34:16 +0100
committerKim Alvefur <zash@zash.se>2017-02-10 21:34:16 +0100
commit594cd2890617a6472ba44b5146cf613d97a72b26 (patch)
treeb94754ed8abee90a404d2914f4e02e5e7ec38310 /plugins/mod_component.lua
parente902bcea2ee39bf7fdeda44d9f28dd8c893084d7 (diff)
parenta586901308157ae912d86292adf3ca6704217521 (diff)
downloadprosody-594cd2890617a6472ba44b5146cf613d97a72b26.tar.gz
prosody-594cd2890617a6472ba44b5146cf613d97a72b26.zip
Merge 0.10->trunk
Diffstat (limited to 'plugins/mod_component.lua')
-rw-r--r--plugins/mod_component.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua
index cf678933..a829cecb 100644
--- a/plugins/mod_component.lua
+++ b/plugins/mod_component.lua
@@ -29,6 +29,13 @@ local opt_keepalives = module:get_option_boolean("component_tcp_keepalives", mod
local sessions = module:shared("sessions");
+local function keepalive(event)
+ local session = event.session;
+ if not session.notopen then
+ return event.session.send(' ');
+ end
+end
+
function module.add_host(module)
if module:get_host_type() ~= "component" then
error("Don't load mod_component manually, it should be for a component, please see https://prosody.im/doc/components", 0);
@@ -135,8 +142,12 @@ function module.add_host(module)
module:hook("iq/host", handle_stanza, -1);
module:hook("message/host", handle_stanza, -1);
module:hook("presence/host", handle_stanza, -1);
+
+ module:hook("component-read-timeout", keepalive, -1);
end
+module:hook("component-read-timeout", keepalive, -1);
+
--- Network and stream part ---
local xmlns_component = 'jabber:component:accept';
@@ -332,6 +343,13 @@ function listener.ondetach(conn)
sessions[conn] = nil;
end
+function listener.onreadtimeout(conn)
+ local session = sessions[conn];
+ if session then
+ return (hosts[session.host] or prosody).events.fire_event("component-read-timeout", { session = session });
+ end
+end
+
module:provides("net", {
name = "component";
private = true;