fix crash / add logging for reverse lookup on invalid ip address string

This commit is contained in:
Thomas Waldmann 2019-04-14 21:53:35 +02:00
parent c320578879
commit f4bdf5b37d

View File

@ -285,6 +285,10 @@ def rev_lookup(ipaddr):
try:
return socket.gethostbyaddr(ipaddr)[0]
except socket.error as err:
if err.errno in (-5, 4):
# -5 / 4 == no address associated with hostname (invalid ip?)
logger.warning("errno -5 when trying to reverse lookup %r" % ipaddr)
break
if err.errno in (errno.EPERM, ):
# EPERM == 1 == unknown host
break