[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [ascension] 13/57: added zone merging of full and increment
From: |
gnunet |
Subject: |
[GNUnet-SVN] [ascension] 13/57: added zone merging of full and incremental zones |
Date: |
Sat, 13 Apr 2019 13:32:10 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository ascension.
commit e495d920dec5452e52d3cb48a137330c7ec7bf58
Author: rexxnor <address@hidden>
AuthorDate: Fri Sep 28 10:54:16 2018 +0200
added zone merging of full and incremental zones
---
gnsmigrator/gnsmigrator.py | 45 +++++++++++++++++++++++++++++----------------
setup.py | 2 +-
2 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index 61ae1cf..80881e3 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -198,6 +198,19 @@ class GNSMigrator():
"""
return domain.split('.')[0]
+ @staticmethod
+ def merge_zones(domain, fullzone, incrementalzone):
+ """
+ Merges full zone with incremental zone
+ """
+ # The library sucks so I do it with string operations
+ fullset = set(fullzone.to_text().decode().split('\n'))
+ incrementalset = set(incrementalzone.to_text().decode().split('\n'))
+ merged = '\n'.join(fullset.union(incrementalset))
+ mergedzone = dns.zone.from_text(merged.encode(), origin=domain)
+ return mergedzone
+
+
@classmethod
def refresh_zone(cls, domain, zonetuple, dnsresolver):
"""
@@ -212,23 +225,23 @@ class GNSMigrator():
zone, xfrinfo = zonetuple
zonename = cls.get_lowest_domain_part(domain)
cls.add_records_to_gns(zonename, zone, domain, dnsresolver)
+ newzone = dns.zone.Zone(domain)
# Ugly way to get serial
- serial = int(str(zone.get_rdataset('@', dns.rdatatype.SOA)).split('
')[5])
- newzone = dns.zone.from_xfr(dns.query.xfr(xfrinfo[0],
- xfrinfo[1],
- rdtype=dns.rdatatype.IXFR,
- serial=serial))
-
- # If the zone serials match, refresh the TTL in the daemon, else
insert new TTL
- newserial = int(str(newzone.get_rdataset('@',
dns.rdatatype.SOA)).split(' ')[5])
- if serial == newserial:
- cls.zones[domain] = (zone, (xfrinfo[0],
- xfrinfo[1],
- newzone.get_rdataset('@',
dns.rdatatype.SOA).ttl))
- cls.zones[domain] = (newzone, (xfrinfo[0],
- xfrinfo[1],
- newzone.get_rdataset('@',
dns.rdatatype.SOA).ttl))
+ oldserial = int(str(zone.get_rdataset('@', dns.rdatatype.SOA)).split('
')[5])
+ try:
+ newzone = dns.zone.from_xfr(dns.query.xfr(xfrinfo[0],
+ xfrinfo[1],
+
rdtype=dns.rdatatype.IXFR,
+ serial=oldserial))
+ except dns.zone.NoNS:
+ print('the zone for domain %s was not updated' % domain)
+
+ # Merge old and new zone
+ updatedzone = cls.merge_zones(domain, zone, newzone)
+ cls.zones[domain] = (updatedzone, (xfrinfo[0],
+ xfrinfo[1],
+ zone.get_rdataset('@',
dns.rdatatype.SOA).ttl))
def main():
@@ -236,7 +249,7 @@ def main():
Initializes object and handles arguments
"""
# argument parsing from docstring definition
- args = docopt.docopt(__doc__, version='GNS Migrator 0.1.0')
+ args = docopt.docopt(__doc__, version='GNS Migrator 0.1.1')
# Checks if GNUnet services are running
try:
diff --git a/setup.py b/setup.py
index bdb41b2..0adbe62 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="gnsmigrator",
- version="0.1.0",
+ version="0.1.1",
author="Patrick Gerber",
author_email="address@hidden",
description="Tool to migrate DNS Zones to the GNU Name System",
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [ascension] 16/57: fixed special cases with GNS2DNS, (continued)
- [GNUnet-SVN] [ascension] 16/57: fixed special cases with GNS2DNS, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 14/57: reworked the incremental zone transfer, added notice for bind, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 11/57: added ttl of SOA to zone for later implementation of timer, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 05/57: initial prototype, bootstrapping zones and zone transfer, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 24/57: fixed zone serialisation, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 17/57: updated requirements and README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 36/57: some experimental fixes, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 19/57: fixed some minor bugs, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 15/57: created baseclass and separated small from big zones, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 21/57: fixed serial fetching and added serialization of zone, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 13/57: added zone merging of full and incremental zones,
gnunet <=
- [GNUnet-SVN] [ascension] 29/57: added warnings to logging if records failed to be added, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 27/57: unstable version, port specification possible, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 02/57: Added LICENSE, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 18/57: refactored adding of records, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 08/57: added GNS2DNS support and rudimentary Unittests (incomplete), gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 23/57: fixed non existing file, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 42/57: added dnscurve detection and log it, fix ttl bug with hierarchy, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 07/57: fixes, added a few tests, updated README and requirements, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 10/57: added incremental zone transfer logic, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 54/57: lint manpage, gnunet, 2019/04/13