diff --git a/core/services/networking/api_requests/subtools/dns_evaluation.py b/core/services/networking/api_requests/subtools/dns_evaluation.py index 5dc73d0..a23676f 100644 --- a/core/services/networking/api_requests/subtools/dns_evaluation.py +++ b/core/services/networking/api_requests/subtools/dns_evaluation.py @@ -40,8 +40,21 @@ def is_dns_problem(url: str) -> bool: def dns_works_via_tor(domain, connection_observer, client_observer=None): """ - Check if domain's resolver is blocking Tor by querying via proxychains. - Dynamically configures proxychains with the given port. + Purpose: + Check if domain's resolver is blocking Tor by querying via proxychains. + + Method: + Dynamically configures proxychains with the given port. + Uses this to query the DNS via dig. + + Dependencies: + Proxychains being installed. + + Called by: + step4_error_classifier's classify_request_error + + Raises Errors? + False """ port_number = ConnectionService.get_random_available_port_number() @@ -87,15 +100,20 @@ socks5 127.0.0.1 {port_number} print("running command...") # Run dig through proxychains with the dynamic config - result = subprocess.run( - ['proxychains4', '-f', config_path, 'dig', domain, '+short'], - capture_output=True, - text=True, - timeout=10 - ) - print(f"result: {result}") + try: + result = subprocess.run( + ['proxychains4', '-f', config_path, 'dig', domain, '+short'], + capture_output=True, + text=True, + timeout=10 + ) + logger.debug(f"result: {result}") + except: + logger.error(f"[DNS PROBLEM] Proxychains not installed on this computer") + return False + output = result.stdout.strip() - print(f"output: {output}") + logger.debug(f"output of stripping the IP out of the result: {output}") if not output or result.returncode != 0: logger.debug(f"[DNS PROBLEM] {domain}: No response") @@ -103,7 +121,7 @@ socks5 127.0.0.1 {port_number} logger.debug(f"[DNS OK] {domain}: {output}") return output - + except subprocess.TimeoutExpired: logger.debug(f"[DNS PROBLEM] {domain}: Timeout") return False