##// END OF EJS Templates
utils.localinterfaces: Add PUBLIC_IPS to consolidate socket logic...
W. Trevor King -
Show More
@@ -5,6 +5,9 b' LOCALHOST : The loopback interface, or the first interface that points to this'
5 5 machine. It will *almost* always be '127.0.0.1'
6 6
7 7 LOCAL_IPS : A list of IP addresses, loopback first, that point to this machine.
8
9 PUBLIC_IPS : A list of public IP addresses that point to this machine.
10 Use these to tell remote clients where to find you.
8 11 """
9 12 #-----------------------------------------------------------------------------
10 13 # Copyright (C) 2010-2011 The IPython Development Team
@@ -31,10 +34,14 b' try:'
31 34 except socket.gaierror:
32 35 pass
33 36
37 PUBLIC_IPS = []
34 38 try:
35 LOCAL_IPS.extend(socket.gethostbyname_ex(socket.gethostname())[2])
39 PUBLIC_IPS = socket.gethostbyname_ex(socket.gethostname())[2]
36 40 except socket.gaierror:
37 41 pass
42 else:
43 PUBLIC_IPS = uniq_stable(PUBLIC_IPS)
44 LOCAL_IPS.extend(PUBLIC_IPS)
38 45
39 46 # include all-interface aliases: 0.0.0.0 and ''
40 47 LOCAL_IPS.extend(['0.0.0.0', ''])
General Comments 0
You need to be logged in to leave comments. Login now