mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Update IP helper function
This commit is contained in:
parent
7245e97726
commit
efdd4156d8
1 changed files with 7 additions and 5 deletions
|
@ -1194,18 +1194,20 @@ def get_plexpy_url(hostname=None):
|
|||
scheme = 'http'
|
||||
|
||||
if hostname is None and plexpy.CONFIG.HTTP_HOST in ('0.0.0.0', '::'):
|
||||
import socket
|
||||
# Only returns IPv4 address
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
s.settimeout(0)
|
||||
try:
|
||||
# Only returns IPv4 address
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
s.connect(('<broadcast>', 0))
|
||||
s.connect(('<broadcast>', 1))
|
||||
hostname = s.getsockname()[0]
|
||||
except socket.error:
|
||||
try:
|
||||
hostname = socket.gethostbyname(socket.gethostname())
|
||||
except socket.gaierror:
|
||||
pass
|
||||
finally:
|
||||
s.close()
|
||||
|
||||
if not hostname:
|
||||
hostname = 'localhost'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue