From f11bc3c99c73095c3ac7c8ac9ac92c9f6d43ab7d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 14 Jul 2021 22:09:39 +0200 Subject: net.server_epoll: Add way to enable TCP keeplives on all connections In case one wishes to enable this for all connections, not just c2s (not Direct TLS ones, because LuaSec) and s2s. Unclear what use these are, since they kick in after 2 hours of idle time. --- net/server_epoll.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 1da0791b..0e615b19 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -80,6 +80,9 @@ local default_config = { __index = { -- Attempt writes instantly opportunistic_writes = false; + + -- TCP Keepalives + tcp_keepalive = false; -- boolean | number }}; local cfg = default_config.__index; @@ -727,8 +730,10 @@ function interface:init() return self:add(true, true); end --- luacheck: ignore 212/self function interface:defaultoptions() + if cfg.tcp_keepalive then + self:setoption("keepalive", true); + end end function interface:pause() -- cgit v1.2.3