Tweak listeners and their error messages
This commit is contained in:
parent
ad0859f2e7
commit
71fda58a3b
29
src/main.py
29
src/main.py
|
@ -56,19 +56,28 @@ 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:
|
if socket.has_ipv6:
|
||||||
logging.error('Error while starting IPv4 listener')
|
try:
|
||||||
logging.error(e)
|
listener_ipv6 = Listener('', shared.listening_port, family=socket.AF_INET6)
|
||||||
|
listener_ipv6.start()
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning('Error while starting IPv6 listener')
|
||||||
|
logging.warning(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
listener_ipv6 = Listener('::', shared.listening_port, family=socket.AF_INET6)
|
listener_ipv4 = Listener('', shared.listening_port)
|
||||||
listener_ipv6.start()
|
listener_ipv4.start()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error('Error while starting IPv6 listener')
|
if listener_ipv6:
|
||||||
logging.error(e)
|
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)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user