comparison mod_net_proxy/mod_net_proxy.lua @ 2997:97b30fec709c

mod_net_proxy: Fixed errors when connection with nil ip is being processed
author Pascal Mathis <mail@pascalmathis.com>
date Thu, 05 Apr 2018 19:08:46 +0200
parents 7eb6fa9b03fd
children b33b2fbdc713
comparison
equal deleted inserted replaced
2996:0fb95dc11bc8 2997:97b30fec709c
342 342
343 -- Network Listener Methods 343 -- Network Listener Methods
344 local listener = {}; 344 local listener = {};
345 345
346 function listener.onconnect(conn) 346 function listener.onconnect(conn)
347 -- Silently drop connections with an IP address of <nil>, which can happen when the socket was closed before the
348 -- responsible net.server backend was able to grab the IP address of the connecting client.
349 if conn:ip() == nil then
350 conn:close();
351 return;
352 end
353
347 -- Check if connection is coming from a trusted proxy 354 -- Check if connection is coming from a trusted proxy
348 if not is_trusted_proxy(conn) then 355 if not is_trusted_proxy(conn) then
349 conn:close(); 356 conn:close();
350 module:log("warn", "Dropped connection from untrusted proxy: %s", conn:ip()); 357 module:log("warn", "Dropped connection from untrusted proxy: %s", conn:ip());
351 return; 358 return;