comparison mod_s2s_keepalive/mod_s2s_keepalive.lua @ 3833:580862decd77

mod_s2s_keepalive: Respect keepalive_servers when creating watchdogs
author Kim Alvefur <zash@zash.se>
date Sat, 04 Jan 2020 11:09:28 +0100
parents 22f02716819f
children c4002aae4ad3
comparison
equal deleted inserted replaced
3832:0d4146cf9fbc 3833:580862decd77
41 end 41 end
42 42
43 module:hook("s2sin-established", function (event) 43 module:hook("s2sin-established", function (event)
44 local session = event.session; 44 local session = event.session;
45 if session.watchdog_keepalive then return end -- in case mod_bidi fires this twice 45 if session.watchdog_keepalive then return end -- in case mod_bidi fires this twice
46 if keepalive_servers and not keepalive_servers:contains(session.from_host) then return end
46 session.watchdog_keepalive = watchdog.new(keepalive_timeout, function () 47 session.watchdog_keepalive = watchdog.new(keepalive_timeout, function ()
47 session.log("info", "Keepalive ping timed out, closing connection"); 48 session.log("info", "Keepalive ping timed out, closing connection");
48 session:close("connection-timeout"); 49 session:close("connection-timeout");
49 end); 50 end);
50 end); 51 end);
51 52
52 module:hook("s2sout-established", function (event) 53 module:hook("s2sout-established", function (event)
53 local session = event.session; 54 local session = event.session;
54 if session.watchdog_keepalive then return end -- in case mod_bidi fires this twice 55 if session.watchdog_keepalive then return end -- in case mod_bidi fires this twice
56 if keepalive_servers and not keepalive_servers:contains(session.from_host) then return end
55 session.watchdog_keepalive = watchdog.new(keepalive_timeout, function () 57 session.watchdog_keepalive = watchdog.new(keepalive_timeout, function ()
56 session.log("info", "Keepalive ping timed out, closing connection"); 58 session.log("info", "Keepalive ping timed out, closing connection");
57 session:close("connection-timeout"); 59 session:close("connection-timeout");
58 end); 60 end);
59 end); 61 end);