[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [ascension] 25/57: fixed bugs
From: |
gnunet |
Subject: |
[GNUnet-SVN] [ascension] 25/57: fixed bugs |
Date: |
Sat, 13 Apr 2019 13:32:22 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository ascension.
commit e5161d1423034ab2319fa9147e24f28ceaa068a9
Author: rexxnor <address@hidden>
AuthorDate: Thu Oct 18 10:28:50 2018 +0200
fixed bugs
---
gnsmigrator/gnsmigrator.py | 59 ++++++++++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 15 deletions(-)
diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index b1832a5..33f170b 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -23,8 +23,6 @@ from ctypes import c_void_p
from enum import Enum
from dataclasses import dataclass
import multiprocessing
-import gzip
-import pickle
import queue
import re
import sys
@@ -401,6 +399,29 @@ class BaseMigrator():
soa_answer = dns.resolver.query(domain, 'SOA')
return soa_answer[0].serial
+ @staticmethod
+ def get_zone_serial(zonename):
+ """
+ Extracts the current serial from a given zone
+ """
+ if zonename[-1] == '.':
+ zonename = zonename[:-1]
+ try:
+ serial = sp.check_output([GNUNET_GNS_COMMAND,
+ '-t', 'SOA',
+ '-u', '@.%s' % zonename])
+ serial = serial.decode()
+ except sp.CalledProcessError:
+ serial = ""
+ soa_serial = 0
+ soapattern = re.compile(r'.+\s(\d+),\d+,+\d+,\d+,\d+', re.M)
+ if re.findall(soapattern, serial):
+ soa_serial = re.findall(soapattern, serial)[0]
+ else:
+ soa_serial = 0
+ return soa_serial
+
+
class ZoneMigrator(BaseMigrator):
"""
Class that migrates small zones efficiently
@@ -456,12 +477,6 @@ class TLDMigrator(BaseMigrator):
"""
zone = None
# And to unzip and unpickle:
- try:
- with gzip.open('%s.zone.gz' % cls.tld[:-1], 'rb') as zonefile:
- zone = pickle.load(zonefile)
- cls.zone = zone
- except FileNotFoundError as filenotfound:
- print(filenotfound)
currentserial = cls.get_current_serial(cls.tld)
zoneserial = 0
@@ -472,17 +487,30 @@ class TLDMigrator(BaseMigrator):
else:
if zoneserial == 0:
cls.initial_zone_transfer()
- if zoneserial < currentserial:
cls.transfer_zone()
+ elif zoneserial < currentserial and zoneserial != 0:
+ cls.merge_zones()
- # zip and pickle the zone
- with gzip.open('%s.zone.gz' % cls.tld[:-1], 'wb') as zonefile:
- pickle.dump(cls.zone, zonefile)
+ @classmethod
+ def merge_zones(cls):
+ """
+ Fetch diff and merge zones
+ """
+ currentzone = cls.zone
+ partialzone = dns.zone.from_xfr(cls.zonegenerator)
+ for rdata in partialzone.iterate_rdatasets(dns.rdatatype.NS):
+ name, rdataset = rdata
+ current_set = currentzone.get_rdataset(name, dns.rdatatype.NS,
+ create=True)
+ current_set.union_update(rdataset)
+ for soarecord in partialzone.iterate_rdatas(dns.rdatatype.SOA):
+ name, _, rdata = soarecord
+ if str(name) == '@':
+ super().add_soa_record_to_gns(soarecord, cls.tld[:-1], cls.tld)
@classmethod
def transfer_zone(cls, zone_factory=dns.zone.Zone,
- relativize=True, check_origin=True
- ):
+ relativize=True, check_origin=True):
"""
Do the actual zone transfer
"""
@@ -514,6 +542,7 @@ class TLDMigrator(BaseMigrator):
cls.zone = zone
except Exception as transferexception:
print("Error occured during Zone transfer: %s" % transferexception)
+ raise
@classmethod
def multithreaded_add_records_to_gns(cls):
@@ -613,7 +642,7 @@ def main():
if tld and transferns:
migrator = TLDMigrator(tld, transferns)
- serial = migrator.get_current_serial(tld)
+ serial = migrator.get_zone_serial(tld)
migrator.initial_zone_transfer(serial)
migrator.bootstrap_zone()
migrator.mirror_zone()
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [ascension] 37/57: updated README, (continued)
- [GNUnet-SVN] [ascension] 37/57: updated README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 22/57: finished refactoring, fixed a few bugs, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 30/57: updated gnsmigrator and removed c rebuilds, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 44/57: updated README, cleanup, PEP8, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 32/57: testing and added logging of executed commands to debug, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 28/57: refactored code, added debug mode, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 35/57: unify all records under label, added SUPPORTED_RECORDS global, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 40/57: improvements, better case separation, more logging, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 50/57: flags adjustment and soa record is now public by default, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 33/57: added needed return statement; add glue records first, then NS, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 25/57: fixed bugs,
gnunet <=
- [GNUnet-SVN] [ascension] 38/57: renamed project to ascension, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 31/57: added testing for gnunet -K option and more, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 52/57: changed argument -ns to -n, removed gnunet.py, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 46/57: added license headers, GNU coding style guidelines, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 53/57: Add ascension.1, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 34/57: updated gnsmigrator for multiline, added multiline tests, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 41/57: added logic for subzones with zone cut, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 45/57: renamed files, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 48/57: fixed creation zone for non-bailiwick records. bugfixes, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 47/57: updated docstrings, gnunet, 2019/04/13