gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [ascension] 19/45: fixed some minor bugs


From: gnunet
Subject: [GNUnet-SVN] [ascension] 19/45: fixed some minor bugs
Date: Fri, 25 Jan 2019 10:02:19 +0100

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

rexxnor pushed a commit to branch master
in repository ascension.

commit 1fb4d54b0140366e8709eb28f02edda9008e8c15
Author: rexxnor <address@hidden>
AuthorDate: Thu Oct 11 23:23:18 2018 +0200

    fixed some minor bugs
---
 gnsmigrator/gnsmigrator.py | 49 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 39 insertions(+), 10 deletions(-)

diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index 00e9bd7..f11c211 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -203,23 +203,21 @@ class BaseMigrator():
         :param domain: full domain of zone
         """
         for record in zone.iterate_rdatas():
-            # fancy dictionary because switch case does not exist in python
             dnsname_str = str(record[0])
             rtype_str = dns.rdatatype.to_text(record[2].rdtype)
-            print(dnsname_str)
-            print(rtype_str)
             if dnsname_str == '@':
                 if rtype_str == 'SOA':
                     BaseMigrator.add_soa_record_to_gns(record, zonename, 
domain)
-                print("Record type %s is not yet supported" % rtype_str)
             else:
                 if rtype_str == 'NS' and dnsname_str != '@':
                     BaseMigrator.add_ns_record_to_gns(record, zonename, domain)
                 elif rtype_str == 'MX':
                     BaseMigrator.add_mx_record_to_gns(record, zonename)
+                #elif rtype_str == 'SRV':
+                #    BaseMigrator.add_srv_record_to_gns(record, zonename)
                 elif rtype_str in ['A', 'AAAA']:
                     BaseMigrator.add_a_aaaa_record_to_gns(record, zonename, 
domain)
-                elif rtype_str in ['TXT', 'SRV', 'CNAME']:
+                elif rtype_str in ['TXT', 'CNAME']:
                     BaseMigrator.add_gen_record_to_gns(record, zonename)
                 else:
                     print("Record type %s is not yet supported" % rtype_str)
@@ -232,13 +230,38 @@ class BaseMigrator():
         """
         if not BaseMigrator.check_if_record_exists_in_zone(record, zonename):
             dnsname, ttl, rdata = record
+            rtype_str = str(dns.rdatatype.to_text(rdata.rdtype))
             sp.run([GNUNET_NAMESTORE_COMMAND,
                     '-z', zonename,
                     '-a', '-n', str(dnsname),
-                    '-t', dns.rdatatype.to_text(rdata.rdtype),
+                    '-t', rtype_str,
                     '-V', str(rdata),
                     '-e', '%ds' % ttl])
 
+    @staticmethod
+    def add_srv_record_to_gns(record, zonename):
+        # TODO Add support for SRV records
+        """
+        Adds a SRV record to GNS
+        """
+        if not BaseMigrator.check_if_record_exists_in_zone(record, zonename):
+            value, ttl, rdata = record
+            rtype_str = str(dns.rdatatype.to_text(rdata.rdtype))
+            dnsname_str = str(rdata).split(' ')[3]
+            debug = " ".join([GNUNET_NAMESTORE_COMMAND,
+                              '-z', zonename,
+                              '-a', '-n', dnsname_str,
+                              '-t', rtype_str,
+                              '-V', str(value),
+                              '-e', '%ds' % ttl])
+            print(debug)
+            sp.run([GNUNET_NAMESTORE_COMMAND,
+                    '-z', zonename,
+                    '-a', '-n', dnsname_str,
+                    '-t', rtype_str,
+                    '-V', str(value),
+                    '-e', '%ds' % ttl])
+
     @staticmethod
     def add_a_aaaa_record_to_gns(record, zonename, domain):
         """
@@ -246,10 +269,11 @@ class BaseMigrator():
         """
         if not BaseMigrator.check_if_record_exists_in_zone(record, zonename):
             dnsname, ttl, rdata = record
+            rtype_str = str(dns.rdatatype.to_text(rdata.rdtype))
             sp.run([GNUNET_NAMESTORE_COMMAND,
                     '-z', zonename,
                     '-a', '-n', str(dnsname),
-                    '-t', str(dns.rdatatype.to_text(rdata.rdtype)),
+                    '-t', rtype_str,
                     '-V', str(rdata),
                     '-e', '%ds' % ttl])
             sp.run([GNUNET_NAMESTORE_COMMAND,
@@ -270,6 +294,10 @@ class BaseMigrator():
             zonetuple = str(rdata).split(' ')
             domain = str(".".join(domain.split('.')[:-1]))
             authns, owner, serial, refresh, retry, expiry, irefresh = zonetuple
+            if authns[-1] == '.':
+                authns = authns[:-1]
+            if owner[-1] == '.':
+                owner = owner[:-1]
             sp.call([GNUNET_NAMESTORE_COMMAND,
                      '-z', zonename,
                      '-a', '-n', '@',
@@ -344,13 +372,14 @@ class BaseMigrator():
         """
         Checks if the given record exists in GNS
         """
-        dnsname, _, rtype = record
+        dnsname, _, rdata = record
+        rtype_str = str(dns.rdatatype.to_text(rdata.rdtype))
         ret = sp.check_output([GNUNET_GNS_COMMAND,
-                               '-t', str(rtype),
+                               '-t', rtype_str,
                                '-u', '%s.%s' %
                                (dnsname, zonename)]
                              )
-        if 'Got:'.encode() in ret:
+        if 'Got '.encode() in ret:
             return True
         return False
 

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



reply via email to

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