[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
- [GNUnet-SVN] [ascension] branch master created (now 5ea0f07), gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 04/45: Merge branch 'master' of gitlab.ti.bfh.ch:gerbp6/gnsmigrator, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 01/45: added gitignore and README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 07/45: fixes, added a few tests, updated README and requirements, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 14/45: reworked the incremental zone transfer, added notice for bind, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 11/45: added ttl of SOA to zone for later implementation of timer, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 09/45: updated README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 23/45: fixed non existing file, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 19/45: fixed some minor bugs,
gnunet <=
- [GNUnet-SVN] [ascension] 16/45: fixed special cases with GNS2DNS, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 25/45: fixed bugs, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 20/45: fixed zonemaster to zonedata in README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 13/45: added zone merging of full and incremental zones, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 05/45: initial prototype, bootstrapping zones and zone transfer, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 17/45: updated requirements and README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 22/45: finished refactoring, fixed a few bugs, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 10/45: added incremental zone transfer logic, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 06/45: working prototype for A, AAAA, MX, CNAME, TXT and more records, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 15/45: created baseclass and separated small from big zones, gnunet, 2019/01/25