From c8fad9605cb2c9746c1a3eb7d0f99edcb005ad9c Mon Sep 17 00:00:00 2001 From: gyptazy Date: Mon, 17 Mar 2025 06:57:01 +0100 Subject: [PATCH] fix: Catch non-resolvable DNS names and log them but proceed by the given host list Fixes: #143 --- proxlb/utils/proxmox_api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/proxlb/utils/proxmox_api.py b/proxlb/utils/proxmox_api.py index d9645e8..a17c912 100644 --- a/proxlb/utils/proxmox_api.py +++ b/proxlb/utils/proxmox_api.py @@ -182,7 +182,15 @@ class ProxmoxApi: bool: False if the Proxmox server is not reachable. """ logger.debug("Starting: test_api_proxmox_host.") - ip = socket.getaddrinfo(host, None, socket.AF_UNSPEC) + + # Try resolving DNS to IP and log non-resolvable ones + try: + ip = socket.getaddrinfo(host, None, socket.AF_UNSPEC) + except socket.gaierror: + logger.warning(f"Could not resolve {host}.") + return False + + # Validate if given object is IPv4 or IPv6 for address_type in ip: if address_type[0] == socket.AF_INET: logger.debug(f"{host} is type ipv4.")