[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [ascension] 13/45: added zone merging of full and increment
From: |
gnunet |
Subject: |
[GNUnet-SVN] [ascension] 13/45: added zone merging of full and incremental zones |
Date: |
Fri, 25 Jan 2019 10:02:13 +0100 |
This is an automated email from the git hooks/post-receive script.
rexxnor 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] 01/45: added gitignore and README, (continued)
- [GNUnet-SVN] [ascension] 01/45: added gitignore and README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 07/45: fixes, added a few tests, updated README and requirements, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 14/45: reworked the incremental zone transfer, added notice for bind, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 11/45: added ttl of SOA to zone for later implementation of timer, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 09/45: updated README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 23/45: fixed non existing file, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 19/45: fixed some minor bugs, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 16/45: fixed special cases with GNS2DNS, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 25/45: fixed bugs, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 20/45: fixed zonemaster to zonedata in README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 13/45: added zone merging of full and incremental zones,
gnunet <=
- [GNUnet-SVN] [ascension] 05/45: initial prototype, bootstrapping zones and zone transfer, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 17/45: updated requirements and README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 22/45: finished refactoring, fixed a few bugs, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 10/45: added incremental zone transfer logic, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 06/45: working prototype for A, AAAA, MX, CNAME, TXT and more records, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 15/45: created baseclass and separated small from big zones, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 27/45: unstable version, port specification possible, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 28/45: refactored code, added debug mode, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 26/45: added definitive support for IXFR, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 44/45: updated README, cleanup, PEP8, gnunet, 2019/01/25