mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-07-19 00:20:00 +00:00
Enhance DNS resolution check to accept a custom list of domains
This commit is contained in:
parent
5a922f84a6
commit
1ab46f2c6d
@ -320,18 +320,19 @@ class InternManager():
|
|||||||
# except Exception:
|
# except Exception:
|
||||||
# return False
|
# 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.
|
Check if the system's current DNS server can resolve a domain name.
|
||||||
Works on both Windows and Unix-like systems.
|
Works on both Windows and Unix-like systems.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
domains_list (list, optional): List of domains to test. Defaults to common domains.
|
||||||
|
|
||||||
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
|
||||||
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:
|
try:
|
||||||
for domain in test_domains:
|
for domain in test_domains:
|
||||||
|
@ -222,7 +222,9 @@ def main(script_id = 0):
|
|||||||
# time.sleep(2)
|
# time.sleep(2)
|
||||||
# msg.ask("[yellow]Press Enter to continue ...")
|
# 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()
|
print()
|
||||||
console.print("[red]❌ ERROR: DNS configuration is required!")
|
console.print("[red]❌ ERROR: DNS configuration is required!")
|
||||||
console.print("[red]The program cannot function correctly without proper DNS settings.")
|
console.print("[red]The program cannot function correctly without proper DNS settings.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user