# HG changeset patch
# User Pascal Mathis <mail@pascalmathis.com>
# Date 1522948126 -7200
# Node ID 97b30fec709cf2851f78636b7650acd9a6f63378
# Parent  0fb95dc11bc8029dac2c90292a4686da11f39cef
mod_net_proxy: Fixed errors when connection with nil ip is being processed

diff -r 0fb95dc11bc8 -r 97b30fec709c 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();