mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-07-19 16:40:01 +00:00
Check dns resolve domains (#338)
* refactor: streamline proxy checking in search function * refactor: update DNS check method, try a real dns resolution instead of checking dns provider * Fix merge conflicts * Automatic domain update [skip ci] * Automatic domain update [skip ci] * Automatic domain update [skip ci] * Enhance DNS resolution check to accept a custom list of domains * Update run.py --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: None <62809003+Arrowar@users.noreply.github.com>
This commit is contained in:
parent
1d38d04906
commit
eec0d4239a
@ -320,16 +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
|
||||||
"""
|
"""
|
||||||
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:
|
||||||
|
@ -9,6 +9,7 @@ import platform
|
|||||||
import argparse
|
import argparse
|
||||||
import importlib
|
import importlib
|
||||||
import threading, asyncio
|
import threading, asyncio
|
||||||
|
from urllib.parse import urlparse
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
|
|
||||||
@ -153,6 +154,7 @@ def initialize():
|
|||||||
except:
|
except:
|
||||||
console.log("[red]Error with loading github.")
|
console.log("[red]Error with loading github.")
|
||||||
|
|
||||||
|
|
||||||
def restart_script():
|
def restart_script():
|
||||||
"""Riavvia lo script con gli stessi argomenti della riga di comando."""
|
"""Riavvia lo script con gli stessi argomenti della riga di comando."""
|
||||||
print("\nRiavvio dello script...\n")
|
print("\nRiavvio dello script...\n")
|
||||||
@ -191,6 +193,11 @@ def force_exit():
|
|||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_hostname(url_string: str) -> str:
|
||||||
|
"""Safely extracts the hostname from a URL string."""
|
||||||
|
return urlparse(url_string).hostname
|
||||||
|
|
||||||
|
|
||||||
def main(script_id = 0):
|
def main(script_id = 0):
|
||||||
|
|
||||||
color_map = {
|
color_map = {
|
||||||
@ -210,19 +217,10 @@ def main(script_id = 0):
|
|||||||
log_not = Logger()
|
log_not = Logger()
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
# if not internet_manager.check_dns_provider():
|
# Get all site hostname
|
||||||
# print()
|
hostname_list = [hostname for site_info in config_manager.configSite.values() if (hostname := _extract_hostname(site_info.get('full_url')))]
|
||||||
# console.print("[red]❌ ERROR: DNS configuration is required!")
|
|
||||||
# console.print("[red]The program cannot function correctly without proper DNS settings.")
|
|
||||||
# console.print("[yellow]Please configure one of these DNS servers:")
|
|
||||||
# console.print("[blue]• Cloudflare (1.1.1.1) 'https://developers.cloudflare.com/1.1.1.1/setup/windows/'")
|
|
||||||
# console.print("[blue]• Quad9 (9.9.9.9) 'https://docs.quad9.net/Setup_Guides/Windows/Windows_10/'")
|
|
||||||
# console.print("\n[yellow]⚠️ The program will not work until you configure your DNS settings.")
|
|
||||||
|
|
||||||
# time.sleep(2)
|
if not internet_manager.check_dns_resolve(hostname_list):
|
||||||
# msg.ask("[yellow]Press Enter to continue ...")
|
|
||||||
|
|
||||||
if not internet_manager.check_dns_resolve():
|
|
||||||
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