From 1ab46f2c6d941ddd850c7b569dc7502e9594caba Mon Sep 17 00:00:00 2001 From: Alessandro Perazzetta <482310+AlessandroPerazzetta@users.noreply.github.com> Date: Mon, 9 Jun 2025 00:45:37 +0200 Subject: [PATCH] Enhance DNS resolution check to accept a custom list of domains --- StreamingCommunity/Util/os.py | 9 +++++---- StreamingCommunity/run.py | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/StreamingCommunity/Util/os.py b/StreamingCommunity/Util/os.py index f8c93f5..5ce6bcf 100644 --- a/StreamingCommunity/Util/os.py +++ b/StreamingCommunity/Util/os.py @@ -320,18 +320,19 @@ class InternManager(): # except Exception: # return False - def check_dns_resolve(self): + def check_dns_resolve(self, domains_list: list = None): """ Check if the system's current DNS server can resolve a domain name. Works on both Windows and Unix-like systems. + Args: + domains_list (list, optional): List of domains to test. Defaults to common domains. + Returns: bool: True if the current DNS server can resolve a domain name, False if can't resolve or in case of errors - bool: True if the current DNS server can resolve a domain name, - False if can't resolve or in case of errors """ - test_domains = ["github.com", "google.com", "microsoft.com", "amazon.com"] + test_domains = domains_list or ["github.com", "google.com", "microsoft.com", "amazon.com"] try: for domain in test_domains: diff --git a/StreamingCommunity/run.py b/StreamingCommunity/run.py index 2db8a86..b567f9c 100644 --- a/StreamingCommunity/run.py +++ b/StreamingCommunity/run.py @@ -222,7 +222,9 @@ def main(script_id = 0): # time.sleep(2) # msg.ask("[yellow]Press Enter to continue ...") - if not internet_manager.check_dns_resolve(): + domains_list = [site_info['full_url'].replace('http://', '').replace('https://', '').strip('/') for site_info in config_manager.configSite.values()] + + if not internet_manager.check_dns_resolve(domains_list): print() console.print("[red]❌ ERROR: DNS configuration is required!") console.print("[red]The program cannot function correctly without proper DNS settings.")