mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 07:46:07 -07:00
Improve resolving hostnames
This commit is contained in:
parent
bb1bf87fe2
commit
f5794a5bae
1 changed files with 2 additions and 2 deletions
|
@ -565,12 +565,12 @@ def get_ip(host):
|
||||||
ip_address = ''
|
ip_address = ''
|
||||||
if is_valid_ip(host):
|
if is_valid_ip(host):
|
||||||
return host
|
return host
|
||||||
else:
|
elif not re.fullmatch(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})', host):
|
||||||
try:
|
try:
|
||||||
ip_address = socket.getaddrinfo(host, None)[0][4][0]
|
ip_address = socket.getaddrinfo(host, None)[0][4][0]
|
||||||
logger.debug(u"IP Checker :: Resolved %s to %s." % (host, ip_address))
|
logger.debug(u"IP Checker :: Resolved %s to %s." % (host, ip_address))
|
||||||
except:
|
except:
|
||||||
logger.error(u"IP Checker :: Bad IP or hostname provided.")
|
logger.error(u"IP Checker :: Bad IP or hostname provided: %s." % host)
|
||||||
return ip_address
|
return ip_address
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue