mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Moved get_dns_zone_from_domain from utils/network to utils/dns
This commit is contained in:
parent
008baf1350
commit
4b9dbd92eb
2 changed files with 22 additions and 22 deletions
|
@ -36,3 +36,24 @@ def get_public_suffix(domain):
|
||||||
public_suffix = domain_prefix.plit(".")[-1] + "." + public_suffix
|
public_suffix = domain_prefix.plit(".")[-1] + "." + public_suffix
|
||||||
|
|
||||||
return public_suffix
|
return public_suffix
|
||||||
|
|
||||||
|
def get_dns_zone_from_domain(domain):
|
||||||
|
"""
|
||||||
|
Get the DNS zone of a domain
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
domain -- The domain name
|
||||||
|
|
||||||
|
"""
|
||||||
|
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)
|
||||||
|
if answer[0] == "ok" :
|
||||||
|
return separator.join(domain_subs)
|
||||||
|
elif answer[1][0] == "NXDOMAIN" :
|
||||||
|
return None
|
||||||
|
domain_subs.pop(0)
|
||||||
|
|
||||||
|
# Should not be executed
|
||||||
|
return None
|
|
@ -185,27 +185,6 @@ def dig(
|
||||||
|
|
||||||
return ("ok", answers)
|
return ("ok", answers)
|
||||||
|
|
||||||
def get_dns_zone_from_domain(domain):
|
|
||||||
"""
|
|
||||||
Get the DNS zone of a domain
|
|
||||||
|
|
||||||
Keyword arguments:
|
|
||||||
domain -- The domain name
|
|
||||||
|
|
||||||
"""
|
|
||||||
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)
|
|
||||||
if answer[0] == "ok" :
|
|
||||||
return separator.join(domain_subs)
|
|
||||||
elif answer[1][0] == "NXDOMAIN" :
|
|
||||||
return None
|
|
||||||
domain_subs.pop(0)
|
|
||||||
|
|
||||||
# Should not be executed
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _extract_inet(string, skip_netmask=False, skip_loopback=True):
|
def _extract_inet(string, skip_netmask=False, skip_loopback=True):
|
||||||
"""
|
"""
|
||||||
Extract IP addresses (v4 and/or v6) from a string limited to one
|
Extract IP addresses (v4 and/or v6) from a string limited to one
|
||||||
|
|
Loading…
Add table
Reference in a new issue