aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-01-23 00:56:57 +0000
committerMatthew Wild <mwild1@gmail.com>2012-01-23 00:56:57 +0000
commitb14f0af41d94b5ee137d48e269ad29b45ee765d9 (patch)
tree23dd118b9e745bfa49eb722ce5324c7ed2ab6a00
parent73ab6ec28714e2cbfcf920aa87ba14b56a7c6a15 (diff)
downloadprosody-b14f0af41d94b5ee137d48e269ad29b45ee765d9.tar.gz
prosody-b14f0af41d94b5ee137d48e269ad29b45ee765d9.zip
sessionmanager, mod_c2s: Move timeout logic to mod_c2s
-rw-r--r--core/sessionmanager.lua10
-rw-r--r--plugins/mod_c2s.lua11
2 files changed, 11 insertions, 10 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 17c718dc..276cd8f5 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -28,8 +28,6 @@ local gettime = require "socket".gettime;
local st = require "util.stanza";
-local c2s_timeout = config_get("*", "core", "c2s_timeout");
-
local newproxy = newproxy;
local getmetatable = getmetatable;
@@ -62,14 +60,6 @@ function new_session(conn)
session.ip = conn:ip();
local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$");
session.log = logger.init(conn_name);
-
- if c2s_timeout then
- add_task(c2s_timeout, function ()
- if session.type == "c2s_unauthed" then
- session:close("connection-timeout");
- end
- end);
- end
return session;
end
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