Turn ipv6 representation of ipv4 addresses to simple ips for incoming connections

This commit is contained in:
shortcutme 2019-01-20 16:20:01 +01:00
parent 7c97e37dc3
commit 30b71328b9
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 4 additions and 1 deletions

View File

@ -131,7 +131,10 @@ class ConnectionServer(object):
self.stream_server.stop()
def handleIncomingConnection(self, sock, addr):
ip, port = addr
ip, port = addr[0:2]
ip = ip.lower()
if ip.startswith("::ffff:"): # IPv6 to IPv4 mapping
ip = ip.replace("::ffff:", "", 1)
self.num_incoming += 1
# Connection flood protection