ascension

Migrate DNS zones to the GNU Name System
Log | Files | Refs | README | LICENSE

commit c11712c96c7e66bf21c24691f5c05cc80e1e7f53
parent db545a42e300771283cac1f18c9c2626437eb657
Author: rexxnor <rexxnor+gnunet@brief.li>
Date:   Sat, 22 Jun 2019 02:07:22 +0200

fixed a few bugs and prepared root migration

Diffstat:
Mascension/ascension.py | 36+++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/ascension/ascension.py b/ascension/ascension.py @@ -92,6 +92,9 @@ class Ascender(): flags: str, minimum: str) -> None: self.domain = domain + # special case for root zone + if domain[-1] == '.' and len(domain) == 1: + self.domain = '@' if domain[-1] == '.': self.domain = self.domain[:-1] self.port = int(port) @@ -140,7 +143,8 @@ class Ascender(): :returns: Serial of the zones SOA record """ # Makes domains better resolvable - domain = domain + "." + if not domain == "@": + domain = domain + "." # SOA is different if taken directly from SOA record # compared to AXFR/IXFR - changed to respect this try: @@ -353,7 +357,7 @@ class Ascender(): '-z', zonename, '-n', str(label), ] + recordline, - ) + ) if ret.returncode != 0: logging.warning("failed adding record with name %s", @@ -505,7 +509,8 @@ class Ascender(): '-D', '-z', self.domain, '-t', 'SOA', - '-n', '@']) + '-n', '@'], + stderr=sp.DEVNULL) serial = serial.decode() except sp.CalledProcessError: serial = "" @@ -652,18 +657,6 @@ class Ascender(): zonename, _, pkey, _, privkey = zone.split(" ") self.subzonedict[zonename] = (pkey, self.minimum, privkey) - # Create missing zones (and add to dict) for GNS zones that are NOT DNS zones - # ("." is not a zone-cut in DNS, but always in GNS). - for name in self.zone.nodes.keys(): - subzones = str(name).split('.') - for i in range(1, len(subzones)): - subdomain = ".".join(subzones[i:]) - zonename = "%s.%s" % (subdomain, self.domain) - ttl = self.minimum # new record, cannot use existing one - if self.subzonedict.get(zonename) is None: - pkey, privkey = self.create_zone_and_get_pkey(zonename) - self.subzonedict[zonename] = (pkey, ttl, privkey) - # Check if a delegated zone is available in GNS as per NS record # Adds NS records that contain "gns--pkey--" to dictionary nsrecords = self.zone.iterate_rdatasets(dns.rdatatype.NS) @@ -700,6 +693,19 @@ class Ascender(): logging.critical("PKEY in DNS does not match PKEY in GNS for name %s", name) continue + # Create missing zones (and add to dict) for GNS zones that are NOT DNS zones + # ("." is not a zone-cut in DNS, but always in GNS). + for name in self.zone.nodes.keys(): + subzones = str(name).split('.') + for i in range(1, len(subzones)): + subdomain = ".".join(subzones[i:]) + zonename = "%s.%s" % (subdomain, self.domain) + ttl = self.minimum # new record, cannot use existing one + if self.subzonedict.get(zonename) is None: + pkey, privkey = self.create_zone_and_get_pkey(zonename) + self.subzonedict[zonename] = (pkey, ttl, privkey) + + # Generate PKEY records for all entries in subzonedict for zone, pkeyttltuple in self.subzonedict.items(): pkey, ttl, _ = pkeyttltuple