Software /
code /
prosody
Diff
core/sessionmanager.lua @ 1872:1905eca82ddf
sessionmanager: Add c2s_timeout option for unauthenticated client connections
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 03 Oct 2009 02:41:28 +0100 |
parent | 1684:645e18990211 |
child | 1873:3b770710a1ee |
line wrap: on
line diff
--- a/core/sessionmanager.lua Sat Oct 03 02:33:33 2009 +0100 +++ b/core/sessionmanager.lua Sat Oct 03 02:41:28 2009 +0100 @@ -28,11 +28,13 @@ 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 @@ 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