aboutsummaryrefslogtreecommitdiffstats
path: root/core/s2smanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-09-20 15:17:37 +0100
committerMatthew Wild <mwild1@gmail.com>2009-09-20 15:17:37 +0100
commitd989c5e4e9b10542907657febd8e1060251a1e48 (patch)
treed4a1f04039d1b1ff3ebcf09a8ec3229da8eebb60 /core/s2smanager.lua
parente857dbd1c9106e5081b2b78a52cdf8855dadf7fd (diff)
parent51aec63307bd252c34d8172d8d1e3e5a8133d002 (diff)
downloadprosody-d989c5e4e9b10542907657febd8e1060251a1e48.tar.gz
prosody-d989c5e4e9b10542907657febd8e1060251a1e48.zip
Merge with 0.5
Diffstat (limited to 'core/s2smanager.lua')
-rw-r--r--core/s2smanager.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 3e6c24ac..fbce0c2b 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -39,6 +39,7 @@ local dialback_secret = uuid_gen();
local adns, dns = require "net.adns", require "net.dns";
+local connect_timeout = config.get("*", "core", "s2s_timeout") or 60;
local dns_timeout = config.get("*", "core", "dns_timeout") or 60;
incoming_s2s = {};
@@ -129,6 +130,16 @@ function new_incoming(conn)
session.log = log;
session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end
incoming_s2s[session] = true;
+ add_task(connect_timeout, function ()
+ if session.conn ~= conn or
+ session.type == "s2sin" then
+ return; -- Ok, we're connect[ed|ing]
+ end
+ -- Not connected, need to close session and clean up
+ (session.log or log)("warn", "Destroying incomplete session %s->%s due to inactivity",
+ session.from_host or "(unknown)", session.to_host or "(unknown)");
+ session:close("connection-timeout");
+ end);
return session;
end
@@ -301,6 +312,17 @@ function make_connect(host_session, connect_host, connect_port)
conn.write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0' xml:lang='en'>]], from_host, to_host));
log("debug", "Connection attempt in progress...");
+ add_task(connect_timeout, function ()
+ if host_session.conn ~= conn or
+ host_session.type == "s2sout" or
+ host_session.connecting then
+ return; -- Ok, we're connect[ed|ing]
+ end
+ -- Not connected, need to close session and clean up
+ (host_session.log or log)("warn", "Destroying incomplete session %s->%s due to inactivity",
+ host_session.from_host or "(unknown)", host_session.to_host or "(unknown)");
+ host_session:close("connection-timeout");
+ end);
return true;
end