[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
- [GNUnet-SVN] [ascension] 23/45: fixed non existing file, (continued)
- [GNUnet-SVN] [ascension] 23/45: fixed non existing file, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 19/45: fixed some minor bugs, gnunet, 2019/01/25
- [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 <=
- [GNUnet-SVN] [ascension] 15/45: created baseclass and separated small from big zones, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 27/45: unstable version, port specification possible, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 28/45: refactored code, added debug mode, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 26/45: added definitive support for IXFR, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 44/45: updated README, cleanup, PEP8, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 43/45: updated dependencies, setup.py, removed TODOs, improved error handling, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 12/45: bumped version to 0.1.0, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 03/45: removed GNU from heading in README, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 02/45: Added LICENSE, gnunet, 2019/01/25
- [GNUnet-SVN] [ascension] 30/45: updated gnsmigrator and removed c rebuilds, gnunet, 2019/01/25