dns-autoconf: remove dependency to public suffix list, not sure what scenario it was supposed to cover, probably goodenough without it

This commit is contained in:
Alexandre Aubin 2021-09-12 15:40:17 +02:00
parent bd384d094f
commit 41cf266e25

View file

@ -19,11 +19,8 @@
"""
import dns.resolver
from publicsuffixlist import PublicSuffixList
from moulinette.utils.filesystem import read_file
YNH_DYNDNS_DOMAINS = ["nohost.me", "noho.st", "ynh.fr"]
# Lazy dev caching to avoid re-reading the file multiple time when calling
# dig() often during same yunohost operation
external_resolvers_ = []
@ -94,24 +91,6 @@ def dig(
return ("ok", answers)
def get_public_suffix(domain):
"""get_public_suffix("www.example.com") -> "example.com"
Return the public suffix of a domain name based
"""
# Load domain public suffixes
psl = PublicSuffixList()
public_suffix = psl.publicsuffix(domain)
# FIXME: wtf is this supposed to do ? :|
if public_suffix in YNH_DYNDNS_DOMAINS:
domain_prefix = domain[0:-(1 + len(public_suffix))]
public_suffix = domain_prefix.split(".")[-1] + "." + public_suffix
return public_suffix
def get_dns_zone_from_domain(domain):
# TODO Check if this function is YNH_DYNDNS_DOMAINS compatible
"""
@ -138,11 +117,6 @@ def get_dns_zone_from_domain(domain):
if answer[0] == "ok":
# Domain is dns_zone
return parent
# Otherwise, check if the parent of this parent is in the public suffix list
if parent.split(".", 1)[-1] == get_public_suffix(parent):
# Couldn't check if domain is dns zone, # FIXME : why "couldn't" ...?
# returning private suffix
return parent
# FIXME: returning None will probably trigger bugs when this happens, code expects a domain string
return None