Skip to content

Commit 1930fd6

Browse files
Improve alternative routing logic
1 parent 165dc2d commit 1930fd6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

proton/api.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ def get_alternative_routes_from_dns(self, callback=None):
527527
dns_hosts_response = list(
528528
executor.map(self.__query_for_dns_data, host_and_dns, timeout=20)
529529
)
530+
dns_hosts_response = [dns_url for dns_url in dns_hosts_response if dns_url]
530531

531532
if len(dns_hosts_response) == 0:
532533
continue
@@ -578,12 +579,18 @@ def __query_for_dns_data(self, dns_settings):
578579
bytes: content of the response
579580
"""
580581
dns_host, dns_encoded_data = dns_settings[0], dns_settings[1]
581-
response = requests.get(
582-
dns_host,
583-
headers={"accept": "application/dns-message"},
584-
timeout=(3.05, 16.95),
585-
params={"dns": dns_encoded_data}
586-
)
582+
try:
583+
response = requests.get(
584+
dns_host,
585+
headers={"accept": "application/dns-message"},
586+
timeout=(3.05, 16.95),
587+
params={"dns": dns_encoded_data}
588+
)
589+
590+
if response.status_code == 404:
591+
return
592+
except Exception as e: # noqa
593+
return
587594

588595
return response.content
589596

0 commit comments

Comments
 (0)