Remove hostname resolution in get_webhost

#3131
This commit is contained in:
Safihre
2025-11-18 16:02:24 +01:00
parent 9c8b26ab4e
commit f8a0b3db52
2 changed files with 11 additions and 13 deletions

View File

@@ -31,12 +31,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
python-version: ["3.14"]
name: ["Linux"]
os: [ubuntu-latest]
include:
- name: macOS
os: macos-13
os: macos-latest
python-version: "3.14"
- name: Windows
os: windows-2022

View File

@@ -540,21 +540,19 @@ def get_webhost(web_host, web_port, https_port):
# If only APIPA's or IPV6 are found, fall back to localhost
ipv4 = ipv6 = False
localhost = hostip = "localhost"
try:
info = socket.getaddrinfo(socket.gethostname(), None)
# Valid user defined name?
info = socket.getaddrinfo(web_host, None)
except socket.error:
# Hostname does not resolve
if not is_localhost(web_host):
web_host = "0.0.0.0"
try:
# Valid user defined name?
info = socket.getaddrinfo(web_host, None)
info = socket.getaddrinfo(localhost, None)
except socket.error:
if not is_localhost(web_host):
web_host = "0.0.0.0"
try:
info = socket.getaddrinfo(localhost, None)
except socket.error:
info = socket.getaddrinfo("127.0.0.1", None)
localhost = "127.0.0.1"
info = socket.getaddrinfo("127.0.0.1", None)
localhost = "127.0.0.1"
for item in info:
ip = str(item[4][0])
if ip.startswith("169.254."):