mirror of
https://github.com/Screenly/Anthias.git
synced 2026-05-08 07:14:55 -04:00
Try multiple network interfaces when determining the node's IP address. Also, show correct port according to the settings.listen_port value. Previously was hardcoded to 8080, which may not be true if you've customized your port.
17 lines
369 B
Python
17 lines
369 B
Python
from netifaces import ifaddresses
|
|
|
|
def get_node_ip():
|
|
"""Returns this node's IP, if it can be
|
|
determined, returning None if not."""
|
|
|
|
precedence = ["eth0", "eth1", "en0", "en1"]
|
|
|
|
for interface in precedence:
|
|
try:
|
|
my_ip = ifaddresses(interface)[2][0]['addr']
|
|
return my_ip
|
|
except:
|
|
pass
|
|
|
|
return None
|