refactor: enhance DNS resolution check to support multiple domains across platforms

This commit is contained in:
Alessandro Perazzetta 2025-05-26 17:37:34 +02:00
parent f88eea6be1
commit 80b13d1e8a

View File

@ -323,17 +323,20 @@ class InternManager():
def check_dns_resolve(self): def check_dns_resolve(self):
""" """
Check if the system's current DNS server can resolve a domain name. Check if the system's current DNS server can resolve a domain name.
Works on both Windows and Unix-like systems.
Returns: Returns:
bool: True if the current DNS server can resolve a domain name, bool: True if the current DNS server can resolve a domain name,
False if can't resolve or in case of errors False if can't resolve or in case of errors
""" """
test_domains = ["github.com", "google.com", "microsoft.com", "amazon.com"]
try: try:
resolver = dns.resolver.Resolver() for domain in test_domains:
# Simple DNS resolution test - will raise an exception if it fails # socket.gethostbyname() works consistently across all platforms
resolver.resolve("github.com") os.socket.gethostbyname(domain)
return True return True
except Exception: except (os.socket.gaierror, os.socket.error):
return False return False
class OsSummary: class OsSummary: