From 308cf1c32f9145ed83160014a090f01a36f02720 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 23 Jan 2012 00:56:57 +0000 Subject: sessionmanager, mod_c2s: Move timeout logic to mod_c2s --- plugins/mod_c2s.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'plugins/mod_c2s.lua') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 2fbed1c9..4d7318a5 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -8,6 +8,7 @@ module:set_global(); +local add_task = require "util.timer".add_task; local new_xmpp_stream = require "util.xmppstream".new; local nameprep = require "util.encodings".stringprep.nameprep; local portmanager = require "core.portmanager"; @@ -24,6 +25,7 @@ local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; local log = module._log; +local c2s_timeout = module:get_option_number("c2s_timeout"); local opt_keepalives = module:get_option_boolean("tcp_keepalives", false); local sessions = module:shared("sessions"); @@ -186,6 +188,15 @@ function listener.onconnect(conn) end end + + if c2s_timeout then + add_task(c2s_timeout, function () + if session.type == "c2s_unauthed" then + session:close("connection-timeout"); + end + end); + end + session.dispatch_stanza = stream_callbacks.handlestanza; end -- cgit v1.2.3