gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [ascension] 06/45: working prototype for A, AAAA, MX, CNAME


From: gnunet
Subject: [GNUnet-SVN] [ascension] 06/45: working prototype for A, AAAA, MX, CNAME, TXT and more records
Date: Fri, 25 Jan 2019 10:02:06 +0100

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

rexxnor pushed a commit to branch master
in repository ascension.

commit 1d211abf5960635bd4c3135f80c0231120897b66
Author: rexxnor <address@hidden>
AuthorDate: Fri Sep 21 15:31:08 2018 +0200

    working prototype for A, AAAA, MX, CNAME, TXT and more records
---
 gnsmigrator/gnsmigrator.py | 64 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 50 insertions(+), 14 deletions(-)

diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index f31fe3f..811863e 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -80,6 +80,14 @@ class GNSMigrator():
                     subprocess.run([GNUNET_ZONE_CREATION_COMMAND,
                                     '-C', domainpart])
 
+                pkey_lookup = subprocess.Popen([GNUNET_ZONE_CREATION_COMMAND, 
'-d'],
+                                               stdout=subprocess.PIPE)
+                pkey_line = subprocess.Popen(['grep', domainpart],
+                                             stdin=pkey_lookup.stdout,
+                                             stdout=subprocess.PIPE)
+                pkey_zone = subprocess.check_output(['cut', '-d', ' ', '-f3'],
+                                                    
stdin=pkey_line.stdout).decode().strip()
+
                 # If it is TLD, don't add PKEY to higher zone as they do not 
exist
                 if counter > 0:
                     result = subprocess.check_output([GNUNET_GNS_COMMAND,
@@ -94,28 +102,53 @@ class GNSMigrator():
                                         '-t', 'PKEY',
                                         '-V', pkey_zone,
                                         '-e', 'never'])
-                    #'-e', current+validity])
                 counter += 1
 
     @staticmethod
-    def add_records_to_gns(zone):
-        """
-        Adds the records from the zones to GNS with expiration
-        :param zone:  zone to add to GNS
-        :returns: 0 on success, 1 on error
-        """
-        pass
-
-    @staticmethod
-    def check_records_existing(zone):
+    def add_records_to_gns(zonename, zone, domain):
         """
         Checks if records are present
         :param param1: zone to lookup
         :returns: parts of zone that are not in GNS
         """
+        # can optimize with for record in zone.iterate_rdatas.filter()
         for record in zone.iterate_rdatas():
-            print(record)
-        return ""
+            dnsname, ttl, rtype = record
+            rtype_str = dns.rdatatype.to_text(rtype.rdtype)
+            dnsname_str = str(dnsname)
+            value = str(rtype)
+            if rtype_str == 'MX':
+                valuelist = value.split(' ')
+                value = '%s,%s' % (valuelist[0], valuelist[1])
+            #if rtype_str != 'SOA':
+            if dnsname_str != '@':
+                ret = subprocess.run([GNUNET_GNS_COMMAND,
+                                      '-t', rtype_str,
+                                      '-u', '%s.%s' % (dnsname_str, zonename)],
+                                     stdout=subprocess.PIPE)
+                if 'Got'.encode() not in ret.stdout:
+                    subprocess.run([GNUNET_NAMESTORE_COMMAND,
+                                    '-z', zonename,
+                                    '-a', '-n', dnsname_str,
+                                    '-t', rtype_str,
+                                    '-V', value,
+                                    '-e', '%ds' % ttl])
+                    if rtype_str in ['A', 'AAAA']:
+                        # This is EXPERIMENTAL
+                        subprocess.run([GNUNET_NAMESTORE_COMMAND,
+                                        '-z', zonename,
+                                        '-a', '-n', dnsname_str,
+                                        '-t', 'LEHO',
+                                        '-V', '%s.%s' % (dnsname_str, domain),
+                                        '-e', '%ds' % ttl])
+
+
+    @staticmethod
+    def get_lowest_domain_part(domain):
+        """
+        Returns the lowest domain part in hierarchy
+        """
+        return domain.split('.')[0]
 
 
 def main():
@@ -136,9 +169,12 @@ def main():
 
     for domain, zonetuple in gnsmigrator.zones.items():
         zone, xfrinfo = zonetuple
-        remaining_records = gnsmigrator.check_records_existing(zone)
+        zonename = gnsmigrator.get_lowest_domain_part(domain)
+        gnsmigrator.add_records_to_gns(zonename, zone, domain)
+        print(xfrinfo)
     #    gnsmigrator.add_records_to_gns(remaining_records)
 
 
 if __name__ == '__main__':
+    # ensure gnunet is runnning
     main()

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



reply via email to

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