Show More
@@ -36,7 +36,11 b' except socket.gaierror:' | |||||
36 |
|
36 | |||
37 | PUBLIC_IPS = [] |
|
37 | PUBLIC_IPS = [] | |
38 | try: |
|
38 | try: | |
39 |
|
|
39 | hostname = socket.gethostname() | |
|
40 | PUBLIC_IPS = socket.gethostbyname_ex(hostname)[2] | |||
|
41 | # try hostname.local, in case hostname has been short-circuited to loopback | |||
|
42 | if not hostname.endswith('.local') and all(ip.startswith('127') for ip in PUBLIC_IPS): | |||
|
43 | PUBLIC_IPS = socket.gethostbyname_ex(socket.gethostname() + '.local')[2] | |||
40 | except socket.gaierror: |
|
44 | except socket.gaierror: | |
41 | pass |
|
45 | pass | |
42 | else: |
|
46 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now