Browse Source

Work-around for malfunctioning IPv6 one some Linux platforms.

Specifically: situation where "localhost" resolves to "::1" and "127.0.0.1" while IPV6 is disabled and therefor "::1" not really working.
pull/7/merge
ShyPike 14 years ago
parent
commit
0fafbd6f2e
  1. 15
      SABnzbd.py

15
SABnzbd.py

@ -494,13 +494,22 @@ def print_modules():
#------------------------------------------------------------------------------
def all_localhosts():
""" Return all unique values of localhost """
ips = []
""" Return all unique values of localhost in order of preference """
ips = ['127.0.0.1']
try:
# Check whether IPv6 is available and enabled
info = socket.getaddrinfo('::1', None)
af, socktype, proto, canonname, sa = info[0]
s = socket.socket(af, socktype, proto)
s.close()
except socket.error:
return ips
try:
info = socket.getaddrinfo('localhost', None)
except:
# localhost does not resolve
return ['127.0.0.1']
return ips
ips = []
for item in info:
item = item[4][0]
if item not in ips:

Loading…
Cancel
Save