net.server_epoll: Add way to enable TCP keeplives on all connections
authorKim Alvefur <zash@zash.se>
Wed, 14 Jul 2021 22:09:39 +0200
changeset 11691 153d2fdd97d3
parent 11690 f4c3dcc907d8
child 11692 3fc564f7441b
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
--- a/net/server_epoll.lua	Wed Jul 14 22:06:24 2021 +0200
+++ b/net/server_epoll.lua	Wed Jul 14 22:09:39 2021 +0200
@@ -80,6 +80,9 @@
 
 	-- Attempt writes instantly
 	opportunistic_writes = false;
+
+	-- TCP Keepalives
+	tcp_keepalive = false; -- boolean | number
 }};
 local cfg = default_config.__index;
 
@@ -727,8 +730,10 @@
 	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()