gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [ascension] 03/04: fixed style and logic issues, added some


From: gnunet
Subject: [GNUnet-SVN] [ascension] 03/04: fixed style and logic issues, added some comments
Date: Wed, 22 May 2019 20:10:22 +0200

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

rexxnor pushed a commit to branch master
in repository ascension.

commit 1859a81b5b4783399fdc3743f8897ac94a78a41f
Author: rexxnor <address@hidden>
AuthorDate: Wed May 22 19:17:34 2019 +0200

    fixed style and logic issues, added some comments
---
 ascension/ascension.py     | 60 ++++++++++++++++++++++++----------------------
 ascension/test/gnunet.zone |  2 --
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/ascension/ascension.py b/ascension/ascension.py
index 06bdd44..ffceba7 100644
--- a/ascension/ascension.py
+++ b/ascension/ascension.py
@@ -193,8 +193,8 @@ class Ascender():
                     break
 
                 # execute thing to run on item
-                label, listofrdatasets = labelrecords
-                subzones = label.split('.')
+                name, listofrdatasets = labelrecords
+                subzones = str(name).split('.')
                 domain = self.domain
 
                 if len(subzones) > 1:
@@ -236,9 +236,9 @@ class Ascender():
                         # modify value to fit gns syntax
                         rdtype, value, label = \
                             self.transform_to_gns_format(record,
-                                                        rdtype,
-                                                        domain,
-                                                        label)
+                                                         rdtype,
+                                                         domain,
+                                                         label)
                         # skip record if value is none
                         if value is None:
                             continue
@@ -270,20 +270,19 @@ class Ascender():
                 taskqueue.task_done()
         # End of worker
 
-
-
         self.create_zone_hierarchy()
 
-
         # Create one thread
         thread = threading.Thread(target=worker)
         thread.start()
 
         # add records
-        for label, value in customrdataset.items():
-            if value is None:
+        for name, rdatasets in self.zone.nodes.items():
+            # log if the rdataset is empty for some reason
+            if not rdatasets:
+                logging.warning("Empty Rdataset!")
                 continue
-            taskqueue.put((label, value))
+            taskqueue.put((name, rdatasets))
 
         # Block until all tasks are done
         taskqueue.join()
@@ -381,7 +380,7 @@ class Ascender():
             else:
                 value = "%s.%s" % (value, self.domain)
         elif rdtype == 'NS':
-            if self.subzonedict(str(label) + "." + zonename):
+            if self.subzonedict.get(str(label) + "." + zonename):
                 return (None, None, None)
             nameserver = str(record.target)
             if nameserver[-1] == ".":
@@ -584,7 +583,6 @@ class Ascender():
         """
         Creates the zone hierarchy in GNS for label
         """
-
         # Extend Dictionary using GNS identities that already exist,
         # checking for conflicts with information in DNS
         ids = sp.run([GNUNET_ZONE_CREATION_COMMAND, '-d'], stdout=sp.PIPE)
@@ -593,25 +591,29 @@ class Ascender():
         altdomainlist = [e for e in domainlist if self.domain + " " in e]
         for zone in altdomainlist:
             zonename, _, pkey = zone.split(" ")
-            if not self.subzonedict[zonename]:
+            if self.subzonedict.get(zonename) is None:
                 self.subzonedict[zonename] = (pkey, self.minimum)
             else:
+                # FIXME Christian what was that?
                 pkey_ttl = self.subzonedict[zonename]
                 self.subzonedict[zonename] = (pkey, self.minimum)
 
         # 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():
-            # FIXME: name not right!
-            subzones = name.split('.')
-            for i in xrange(1,length(subzones)-1):
+        for name in self.zone.nodes.keys():
+            subzones = str(name).split('.')
+            # FIXME Christian: For some reason this fails spectacularly
+            for i in range(1, len(subzones)-1):
                 subdomain = ".".join(subzones[i:])
+                # FIXME Christian this seems superfluous
                 zonename = "%s.%s" % (subdomain, self.domain)
                 ttl = self.minimum # new record, cannot use existing one, 
might want to use larger value
-                if not self.subzonedict[zonename]:
-                    pkey = self.create_zone_and_get_pkey(zonename + "." + 
self.domain)
+                if self.subzonedict.get(zonename) is None:
+                    pkey = self.create_zone_and_get_pkey("%s.%s" %
+                                                         (zonename,
+                                                          self.domain))
                     self.subzonedict[zonename] = (pkey, ttl)
-                    
+
         # 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)
@@ -630,13 +632,14 @@ class Ascender():
             if num_gnspkeys > 1:
                 logging.critical("Detected ambiguous PKEY records for label \
                                   %s (not generating PKEY record)", name)
-                continue           
+                continue
             gnspkey = str(gnspkeys[0])
-            
-            # FIXME: test strlen(gnspkey) "right length", theoretically: 
Crockford base32 decoder...
-            zone = name + "." + self.domain
-            if not self.subzonedict[zone]:
-                self.subzonedict[zone] = (gnspkey[11:],ttl)
+
+            # FIXME: test strlen(gnspkey) "right length", theoretically:
+            # Crockford base32 decoder... -> base32-crockford looks promising
+            zone = "%s.%s" % (name, self.domain)
+            if not self.subzonedict.get(zone):
+                self.subzonedict[zone] = (gnspkey[11:], ttl)
             else:
                 # This should be impossible!!?
                 pkey_ttl = self.subzonedict[zone]
@@ -646,8 +649,7 @@ class Ascender():
                     continue
 
         # Generate PKEY records for all entries in subzonedict
-                    
-        for zone, pkeyttltuple in self.subzonedict:
+        for zone, pkeyttltuple in self.subzonedict.items():
             pkey, ttl = pkeyttltuple
             domain = ".".join(zone.split('.')[1::])
             label = zone.split('.')[0]
diff --git a/ascension/test/gnunet.zone b/ascension/test/gnunet.zone
index e44173a..a5697ec 100644
--- a/ascension/test/gnunet.zone
+++ b/ascension/test/gnunet.zone
@@ -6,9 +6,7 @@ $TTL    3600
                        604800          ; Expire
                         3600 )         ; Negative Cache TTL
 @      IN      NS      ns1.gnunet.gnu.
-@      IN      NS      
gns--pkey--7h4hfww26fmdamt243dhssens2w5qevphbm9bhv54sz3cz1053ng.gnunet.gnu.
 @      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

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



reply via email to

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