mod_net_proxy: Fixed errors when connection with nil ip is being processed
authorPascal Mathis <mail@pascalmathis.com>
Thu, 05 Apr 2018 19:08:46 +0200
changeset 3001 97b30fec709c
parent 3000 0fb95dc11bc8
child 3002 719b76ee0578
mod_net_proxy: Fixed errors when connection with nil ip is being processed
mod_net_proxy/mod_net_proxy.lua
--- a/mod_net_proxy/mod_net_proxy.lua	Wed Apr 04 21:40:08 2018 +0200
+++ b/mod_net_proxy/mod_net_proxy.lua	Thu Apr 05 19:08:46 2018 +0200
@@ -344,6 +344,13 @@
 local listener = {};
 
 function listener.onconnect(conn)
+	-- Silently drop connections with an IP address of <nil>, which can happen when the socket was closed before the
+	-- responsible net.server backend was able to grab the IP address of the connecting client.
+	if conn:ip() == nil then
+		conn:close();
+		return;
+	end
+
 	-- Check if connection is coming from a trusted proxy
 	if not is_trusted_proxy(conn) then
 		conn:close();