aboutsummaryrefslogtreecommitdiffstats
path: root/core/sessionmanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-10-03 02:41:28 +0100
committerMatthew Wild <mwild1@gmail.com>2009-10-03 02:41:28 +0100
commit58c524a536d3f82d0c56121ab5ee2036e9067b49 (patch)
treebf4147e661571cc0ae93b3999ed1061fd0b6e64f /core/sessionmanager.lua
parent59a69e124ec6f97518990b1b8bbe5ffad89cbfdf (diff)
downloadprosody-58c524a536d3f82d0c56121ab5ee2036e9067b49.tar.gz
prosody-58c524a536d3f82d0c56121ab5ee2036e9067b49.zip
sessionmanager: Add c2s_timeout option for unauthenticated client connections
Diffstat (limited to 'core/sessionmanager.lua')
-rw-r--r--core/sessionmanager.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 59f0eadf..0dfc0823 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -28,11 +28,13 @@ local config_get = require "core.configmanager".get;
local nameprep = require "util.encodings".stringprep.nameprep;
local fire_event = require "core.eventmanager".fire_event;
-
+local add_task = require "util.timer".add_task;
local gettime = require "socket".gettime;
local st = require "util.stanza";
+local c2s_timeout = config_get("*", "core", "c2s_timeout");
+
local newproxy = newproxy;
local getmetatable = getmetatable;
@@ -53,6 +55,14 @@ 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