Tweak listeners and their error messages

This commit is contained in:
TheKysek 2016-08-03 13:15:45 +02:00
parent ad0859f2e7
commit 71fda58a3b

View File

@ -56,18 +56,27 @@ def main():
advertiser = Advertiser() advertiser = Advertiser()
advertiser.start() advertiser.start()
try: listener_ipv4 = None
listener_ipv4 = Listener('0.0.0.0', shared.listening_port) listener_ipv6 = None
listener_ipv4.start()
except Exception as e:
logging.error('Error while starting IPv4 listener')
logging.error(e)
if socket.has_ipv6:
try: try:
listener_ipv6 = Listener('::', shared.listening_port, family=socket.AF_INET6) listener_ipv6 = Listener('', shared.listening_port, family=socket.AF_INET6)
listener_ipv6.start() listener_ipv6.start()
except Exception as e: except Exception as e:
logging.error('Error while starting IPv6 listener') logging.warning('Error while starting IPv6 listener')
logging.warning(e)
try:
listener_ipv4 = Listener('', shared.listening_port)
listener_ipv4.start()
except Exception as e:
if listener_ipv6:
logging.warning('Error while starting IPv4 listener. '
'However the IPv6 one seems to be working and will probably accept IPv4 connections.')
else:
logging.error('Error while starting IPv4 listener.'
'You will not receive incoming connections. Please check your port configuration')
logging.error(e) logging.error(e)
if __name__ == '__main__': if __name__ == '__main__':