plugins/mod_c2s.lua
changeset 4548 e6e5c76ff009
parent 4543 db27a4c18b6a
child 4551 8f25f3b1c62f
--- a/plugins/mod_c2s.lua	Mon Jan 23 00:11:01 2012 +0000
+++ b/plugins/mod_c2s.lua	Mon Jan 23 00:56:57 2012 +0000
@@ -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 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 @@
 		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