diff options
author | Matthew Wild <mwild1@gmail.com> | 2013-06-29 14:45:47 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2013-06-29 14:45:47 +0100 |
commit | 2489f372db5f8d584c537ba31844cdaf8fd19b10 (patch) | |
tree | 27741db74d498be76001287c8a4e6a9076bb5a27 /plugins/mod_c2s.lua | |
parent | 5adcad1a43d110e0458b38c42b0a21a70eb5336e (diff) | |
parent | 82bd1a5967eba247d95ddde8d8d77197b2bada91 (diff) | |
download | prosody-2489f372db5f8d584c537ba31844cdaf8fd19b10.tar.gz prosody-2489f372db5f8d584c537ba31844cdaf8fd19b10.zip |
Merge
Diffstat (limited to 'plugins/mod_c2s.lua')
-rw-r--r-- | plugins/mod_c2s.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 1d2dd6dd..91bde574 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -50,7 +50,7 @@ function stream_callbacks.streamopened(session, attr) session.streamid = uuid_generate(); (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); - if not hosts[session.host] then + if not hosts[session.host] or not hosts[session.host].modules.c2s then -- We don't serve this host... session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)}; return; @@ -262,10 +262,27 @@ function listener.ondisconnect(conn, err) end end +function listener.onreadtimeout(conn) + local session = sessions[conn]; + if session then + 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(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; for _, session in pairs(sessions) do |