From 8c1d1dd99a5059f9cb0e153075af9cae3bb0215c Mon Sep 17 00:00:00 2001 From: MercierCorentin Date: Tue, 13 Jul 2021 18:17:23 +0200 Subject: [PATCH] Utils/dns get_dns_zone_from_domain improve --- src/yunohost/utils/dns.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/yunohost/utils/dns.py b/src/yunohost/utils/dns.py index 00bbc4f62..461fb0a4a 100644 --- a/src/yunohost/utils/dns.py +++ b/src/yunohost/utils/dns.py @@ -39,6 +39,7 @@ def get_public_suffix(domain): return public_suffix def get_dns_zone_from_domain(domain): + # TODO Check if this function is YNH_DYNDNS_DOMAINS compatible """ Get the DNS zone of a domain @@ -49,12 +50,15 @@ def get_dns_zone_from_domain(domain): separator = "." domain_subs = domain.split(separator) for i in range(0, len(domain_subs)): - answer = dig(separator.join(domain_subs), rdtype="NS", full_answers=True) + current_domain = separator.join(domain_subs) + answer = dig(current_domain, rdtype="NS", full_answers=True, resolvers="force_external") + print(answer) if answer[0] == "ok" : - return separator.join(domain_subs) - elif answer[1][0] == "NXDOMAIN" : - return None + # Domain is dns_zone + return current_domain + if separator.join(domain_subs[1:]) == get_public_suffix(current_domain): + # Couldn't check if domain is dns zone, + # returning private suffix + return current_domain domain_subs.pop(0) - - # Should not be executed return None \ No newline at end of file