[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [ascension] 06/57: working prototype for A, AAAA, MX, CNAME
From: |
gnunet |
Subject: |
[GNUnet-SVN] [ascension] 06/57: working prototype for A, AAAA, MX, CNAME, TXT and more records |
Date: |
Sat, 13 Apr 2019 13:32:03 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 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
- [GNUnet-SVN] [ascension] branch master created (now e08203d), gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 01/57: added gitignore and README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 04/57: Merge branch 'master' of gitlab.ti.bfh.ch:gerbp6/gnsmigrator, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 03/57: removed GNU from heading in README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 09/57: updated README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 06/57: working prototype for A, AAAA, MX, CNAME, TXT and more records,
gnunet <=
- [GNUnet-SVN] [ascension] 20/57: fixed zonemaster to zonedata in README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 12/57: bumped version to 0.1.0, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 16/57: fixed special cases with GNS2DNS, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 14/57: reworked the incremental zone transfer, added notice for bind, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 11/57: added ttl of SOA to zone for later implementation of timer, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 05/57: initial prototype, bootstrapping zones and zone transfer, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 24/57: fixed zone serialisation, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 17/57: updated requirements and README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 36/57: some experimental fixes, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 19/57: fixed some minor bugs, gnunet, 2019/04/13