comparison mod_s2s_idle_timeout/mod_s2s_idle_timeout.lua @ 932:4e235e565693

mod_bidi, mod_dwd, mod_s2s_idle_timeout: Update for recent 0.9 changes (612467e263af)
author Matthew Wild <mwild1@gmail.com>
date Fri, 22 Mar 2013 14:24:05 +0000
parents 6c454d7208ae
children
comparison
equal deleted inserted replaced
931:e20e94d75fe3 932:4e235e565693
5 5
6 local s2s_sessions = setmetatable({}, { __mode = "kv" }); 6 local s2s_sessions = setmetatable({}, { __mode = "kv" });
7 7
8 local idle_timeout = module:get_option("s2s_idle_timeout") or 300; 8 local idle_timeout = module:get_option("s2s_idle_timeout") or 300;
9 local check_interval = math.ceil(idle_timeout * 0.75); 9 local check_interval = math.ceil(idle_timeout * 0.75);
10 local _make_authenticated = s2smanager.make_authenticated; 10
11 function s2smanager.make_authenticated(session, host) 11 local function install_checks(session)
12 if not session.last_received_time then 12 if not session.last_received_time then
13 session.last_received_time = now(); 13 session.last_received_time = now();
14 if session.direction == "incoming" then 14 if session.direction == "incoming" then
15 local _data = session.data; 15 local _data = session.data;
16 function session.data(conn, data) 16 function session.data(conn, data)
24 return _sends2s(data); 24 return _sends2s(data);
25 end 25 end
26 end 26 end
27 s2s_sessions[session] = true; 27 s2s_sessions[session] = true;
28 end 28 end
29 return _make_authenticated(session, host);
30 end 29 end
30
31 module:hook("s2s-authenticated", function (event)
32 install_checks(event.session);
33 end);
31 34
32 function check_idle_sessions(time) 35 function check_idle_sessions(time)
33 time = time or now(); 36 time = time or now();
34 for session in pairs(s2s_sessions) do 37 for session in pairs(s2s_sessions) do
35 local last_received_time = session.last_received_time; 38 local last_received_time = session.last_received_time;