def all_localhosts():
 ips = ['127.0.0.1']
 try:
  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:
  return ips
 ips = []
 for item in info:
  item = item[4][0]
  if ((item not in ips) and (('::1' not in item) or sabnzbd.cfg.ipv6_hosting())):
   ips.append(item)
 return ips

def all_localhosts ( ) : ips = [ '127.0.0.1' ] try : 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 : return ips ips = [ ] for item in info : item = item [ 4 ] [ 0 ] if ( ( item not in ips ) and ( ( '::1' not in item ) or sabnzbd . cfg . ipv6_hosting ( ) ) ) : ips . append ( item ) return ips
return all unique values of localhost in order of preference .