Let tldextract lib handle domain extraction

This fixes an error where the TLD is removed from the domain
and stored in the basename
This commit is contained in:
Philipp Ludewig 2022-03-19 19:10:05 +01:00
parent 33bf3b2a3a
commit 08855c4af9
2 changed files with 5 additions and 2 deletions

2
debian/control vendored
View file

@ -15,7 +15,7 @@ Depends: ${python3:Depends}, ${misc:Depends}
, python3-miniupnpc, python3-dbus, python3-jinja2 , python3-miniupnpc, python3-dbus, python3-jinja2
, python3-toml, python3-packaging, python3-publicsuffix2 , python3-toml, python3-packaging, python3-publicsuffix2
, python3-ldap, python3-zeroconf (>= 0.36), python3-lexicon, , python3-ldap, python3-zeroconf (>= 0.36), python3-lexicon,
, python-is-python3 , python3-tldextract, python-is-python3
, nginx, nginx-extras (>=1.18) , nginx, nginx-extras (>=1.18)
, apt, apt-transport-https, apt-utils, dirmngr , apt, apt-transport-https, apt-utils, dirmngr
, openssh-server, iptables, fail2ban, bind9-dnsutils , openssh-server, iptables, fail2ban, bind9-dnsutils

View file

@ -2,6 +2,7 @@
import os import os
import re import re
import tldextract
from typing import List from typing import List
from datetime import datetime, timedelta from datetime import datetime, timedelta
from publicsuffix2 import PublicSuffixList from publicsuffix2 import PublicSuffixList
@ -68,7 +69,9 @@ class MyDiagnoser(Diagnoser):
return return
base_dns_zone = _get_dns_zone_for_domain(domain) base_dns_zone = _get_dns_zone_for_domain(domain)
basename = domain.replace(base_dns_zone, "").rstrip(".") or "@" basename = tldextract.extract(domain).domain
if len(basename) == 0:
basename = "@"
expected_configuration = _build_dns_conf( expected_configuration = _build_dns_conf(
domain, include_empty_AAAA_if_no_ipv6=True domain, include_empty_AAAA_if_no_ipv6=True