mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix(ml): ipv6 check (#22735)
This commit is contained in:
parent
740ca14a68
commit
5270107926
2 changed files with 18 additions and 2 deletions
|
|
@ -13,8 +13,16 @@ else:
|
||||||
|
|
||||||
module_dir = Path(__file__).parent
|
module_dir = Path(__file__).parent
|
||||||
|
|
||||||
|
|
||||||
|
def is_ipv6(host: str) -> bool:
|
||||||
|
try:
|
||||||
|
return ip_address(host).version == 6
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
bind_host = non_prefixed_settings.immich_host
|
bind_host = non_prefixed_settings.immich_host
|
||||||
if ip_address(bind_host).version == 6:
|
if is_ipv6(bind_host):
|
||||||
bind_host = f"[{bind_host}]"
|
bind_host = f"[{bind_host}]"
|
||||||
bind_address = f"{bind_host}:{non_prefixed_settings.immich_port}"
|
bind_address = f"{bind_host}:{non_prefixed_settings.immich_port}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,16 @@ import requests
|
||||||
port = os.getenv("IMMICH_PORT", 3003)
|
port = os.getenv("IMMICH_PORT", 3003)
|
||||||
host = os.getenv("IMMICH_HOST", "0.0.0.0")
|
host = os.getenv("IMMICH_HOST", "0.0.0.0")
|
||||||
|
|
||||||
|
|
||||||
|
def is_ipv6(host: str) -> bool:
|
||||||
|
try:
|
||||||
|
return ip_address(host).version == 6
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
host = "localhost" if host == "0.0.0.0" else host
|
host = "localhost" if host == "0.0.0.0" else host
|
||||||
host = f"[{host}]" if ip_address(host).version == 6 else host
|
host = f"[{host}]" if is_ipv6(host) else host
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(f"http://{host}:{port}/ping", timeout=2)
|
response = requests.get(f"http://{host}:{port}/ping", timeout=2)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue