gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [ascension] branch master updated: added ttl separation; te


From: gnunet
Subject: [GNUnet-SVN] [ascension] branch master updated: added ttl separation; tested basic functionality on small zone
Date: Mon, 22 Apr 2019 07:27:33 +0200

This is an automated email from the git hooks/post-receive script.

rexxnor pushed a commit to branch master
in repository ascension.

The following commit(s) were added to refs/heads/master by this push:
     new a238fb0  added ttl separation; tested basic functionality on small zone
a238fb0 is described below

commit a238fb06372bcc7dded46e17df59155ad5968b1b
Author: rexxnor <address@hidden>
AuthorDate: Mon Apr 22 07:23:53 2019 +0200

    added ttl separation; tested basic functionality on small zone
---
 ascension/ascension.py                  | 44 +++++++++++++++++++--------------
 ascension/test/gnunet.zone              | 10 +++++---
 ascension/test/test_ascension_simple.sh |  2 +-
 3 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/ascension/ascension.py b/ascension/ascension.py
index 667430c..e3a52dc 100644
--- a/ascension/ascension.py
+++ b/ascension/ascension.py
@@ -81,6 +81,8 @@ class Ascender():
         cls.zonegenerator = None
         cls.nscache = dict()
         cls.flags = flags
+        cls.ttl = None
+        cls.refresh = cls.ttl
 
     @classmethod
     def initial_zone_transfer(cls, serial=None):
@@ -208,6 +210,8 @@ class Ascender():
 
                 # execute thing to run on item
                 label, listofrdatasets = labelrecords
+                cls.ttl = int(cls.get_zone_soa_expiry()[0])
+                cls.refresh = cls.ttl
 
                 for rdataset in listofrdatasets:
                     for record in rdataset:
@@ -216,12 +220,23 @@ class Ascender():
                             continue
 
                         try:
-                            ttl = rdataset.ttl
+                            if rdataset.ttl < cls.ttl:
+                                ttl = rdataset.ttl
+                                if ttl < cls.refresh:
+                                    cls.refresh = ttl
+                            elif rdataset.ttl == cls.ttl:
+                                ttl = int(cls.ttl) * 10
+                            else:
+                                ttl = rdataset.ttl * 10
                         except AttributeError:
-                            ttl = 3600
+                            ttl = cls.refresh
 
                         value = str(record)
 
+                        # resolves record to check if it exists
+                        if cls.check_if_record_exists_in_zone(label, rdtype, 
cls.domain):
+                            continue
+
                         # ignore NS for itself here
                         if label == '@' and rdtype == 'NS':
                             logging.info("ignoring NS record for itself")
@@ -442,12 +457,6 @@ class Ascender():
         :returns: serial of the SOA record in GNS
         """
         try:
-            # this would also work but does not check if record/zone expired
-            #serial = sp.check_output([GNUNET_NAMESTORE_COMMAND,
-            #                          '-t', 'SOA',
-            #                          '-z', cls.domain,
-            #                          '-n', '@',
-            #                          '-D'])
             serial = sp.check_output([GNUNET_GNS_COMMAND,
                                       '-t', 'SOA',
                                       '-u', '@.%s' % cls.domain,])
@@ -463,13 +472,13 @@ class Ascender():
         return soa_serial
 
     @classmethod
-    def get_soa_refresh_time(cls):
+    def get_zone_soa_expiry(cls):
         """
         Extracts the current serial from the class SOA
         :returns: refresh time of the current SOA record
         """
-        ttlpattern = re.compile(r'.+\s\d+,(\d+),\d+,\d+,\d+', re.M)
-        return re.findall(ttlpattern, cls.soa)[0]
+        ttlpattern = re.compile(r'.+\s\d+\s(\d+)\s\d+\s\d+\s\d+', re.M)
+        return re.findall(ttlpattern, str(cls.soa[2]))
 
     @classmethod
     def get_zone_refresh_time(cls):
@@ -562,19 +571,18 @@ class Ascender():
 
 
     @staticmethod
-    def check_if_record_exists_in_zone(record, zonename):
+    def check_if_record_exists_in_zone(name, rtype, zonename):
         """
         Checks if the given record exists in GNS
-        :param record: The record to check for
+        :param name: The record name to check for
+        :param type: The record type to check for
         :param zonename: The zone in which to look up the record
         :returns: True on existance, False otherwise
         """
-        dnsname, _, rdata = record
-        rtype_str = str(dns.rdatatype.to_text(rdata.rdtype))
         ret = sp.check_output([GNUNET_GNS_COMMAND,
-                               '-t', rtype_str,
+                               '-t', rtype,
                                '-u', '%s.%s' %
-                               (dnsname, zonename)]
+                               (name, zonename)]
                              )
         if 'Got ' in ret.decode():
             return True
@@ -690,7 +698,7 @@ def main():
             logging.info("Finished migrating of the zone %s", ascender.domain)
         else:
             logging.info("Zone %s already up to date", ascender.domain)
-        refresh = int(ascender.get_zone_refresh_time())
+        refresh = ascender.refresh
         retry = int(ascender.get_zone_retry_time())
         if standalone:
             return 0
diff --git a/ascension/test/gnunet.zone b/ascension/test/gnunet.zone
index 799185a..d5b5e44 100644
--- a/ascension/test/gnunet.zone
+++ b/ascension/test/gnunet.zone
@@ -9,12 +9,14 @@ $TTL  3600
 @      IN      NS      
gns--pkey--7h4hfww26fmdamt243dhssens2w5qevphbm9bhv54sz3cz1053ng.gnunet.org.
 @      IN      A       127.0.0.1
 gns--pkey--7h4hfww26fmdamt243dhssens2w5qevphbm9bhv54sz3cz1053ng IN  A 0.0.0.0
+foo    IN      AAAA    2002::
+asdf   IN      CNAME   www
+$TTL   300
+ns1    IN      A       127.0.0.1
+ns2    IN      A       37.35.124.161
 www    IN      A       127.0.0.1
+$TTL   7200
 owncloud       IN      A       127.0.0.1
 nextcloud      IN      A       127.0.0.1
 mail   IN      MX      10      mail.gnunet.org.
 mail   IN      A       127.0.0.1
-foo    IN      AAAA    2002::
-asdf   IN      CNAME   www
-ns1    IN      A       127.0.0.1
-ns2    IN      A       37.35.124.161
diff --git a/ascension/test/test_ascension_simple.sh 
b/ascension/test/test_ascension_simple.sh
index f1e3fd1..ad11325 100644
--- a/ascension/test/test_ascension_simple.sh
+++ b/ascension/test/test_ascension_simple.sh
@@ -42,7 +42,7 @@ fi
 named -c basic_named.conf -p 5000
 
 # Check if domain resolves
-nslookup gnunet.org 127.0.0.1 -port=5000
+nslookup -port=5000 gnunet.org 127.0.0.1
 if [ "$?" -ne 0 ]; then
     echo "Something went wrong with named"
     cleanup

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]