ascension

Migrate DNS zones to the GNU Name System
Log | Files | Refs | README | LICENSE

commit 6c119818deba8524d848d79eb7540f24ed04e1eb
parent 37e34e07857b86b5e20b265808fbbcea818f7029
Author: rexxnor <rexxnor+gnunet@brief.li>
Date:   Sun, 20 Jan 2019 14:38:31 +0100

updated README, cleanup, PEP8

Diffstat:
MREADME.md | 13+++++++++----
Mascension/ascension.py | 46++++++++++++++--------------------------------
Msetup.py | 2+-
3 files changed, 24 insertions(+), 37 deletions(-)

diff --git a/README.md b/README.md @@ -1,10 +1,11 @@ # Ascension -The main goal is to develop a tool to easily migrate existing DNS Zones to the -GNU Name System using (incremental) Zone Transfers. (AXFR/IXFR) +Tool to easily migrate existing DNS Zones into the GNU Name System using +incremental zone transfers (AXFR/IXFR). ## How to install -To install the ascension simply execute one of the following commands: +To install the ascension simply execute one of the following commands in the +freshly cloned directory: ```bash # System wide installation @@ -17,6 +18,10 @@ python3 setup.py install ``` ## How to install (Developer) +A developer installation is very handy when you are making changes to the source +code as this way you don't need to re-run the installation procedure every time +you make a change. + ```bash # installation through virtualenv python3 -m venv .venv @@ -28,7 +33,7 @@ python3 setup.py develop If you have installed it, simply execute ascension with one of several options. You can also just run the file ascension.py itself directly. -Taken from the dosctring of the ascension.py file: +Taken from the docstring of the ascension.py file: ``` Ascension diff --git a/ascension/ascension.py b/ascension/ascension.py @@ -38,6 +38,8 @@ GNUNET_ZONE_CREATION_COMMAND = 'gnunet-identity' GNUNET_NAMESTORE_COMMAND = 'gnunet-namestore' GNUNET_GNS_COMMAND = 'gnunet-gns' GNUNET_ARM_COMMAND = 'gnunet-arm' +# TODO find better solution for allowed protocols +SUPPORTED_PROTOCOLS = {'_tcp': 6, '_udp': 17} # TODO find better solution for ignoring DNSSEC record types SUPPORTED_RECORD_TYPES = [ "A", "AAAA", "NS", "MX", "SRV", "TXT", "CNAME" @@ -218,7 +220,11 @@ class Ascender(): # build recordline recordline.append("-R") - recordline.append("%d %s %s %s" % + + # TODO possible regression here; maybe use a separate + # list to pass those arguments to prevent quoting + # issues in the future. + recordline.append('%d %s %s %s' % (int(ttl), rdtype, flags, value)) # add recordline to gns @@ -272,15 +278,18 @@ class Ascender(): :param zonename: zonename of zone to add records to :param label: label under which to add the records """ - logging.info("trying to add %d records with name %s", len(recordline)/2, label) + logging.info("trying to add %d records with name %s", + len(recordline)/2, label) ret = sp.run([GNUNET_NAMESTORE_COMMAND, '-z', zonename, '-n', str(label), ] + recordline) if ret.returncode != 0: - logging.warning("failed adding record with name %s", ' '.join(ret.args)) + logging.warning("failed adding record with name %s", + ' '.join(ret.args)) else: - logging.info("successfully added record with name %s", ' '.join(ret.args)) + logging.info("successfully added record with name %s", + ' '.join(ret.args)) @staticmethod def transform_to_gns_format(record, rdtype, zonename, label): @@ -337,7 +346,6 @@ class Ascender(): # this is the number for a SRV record rdtype = 'BOX' srv = 33 - protocols = {'_tcp': 6, '_udp': 17} # tearing the record apart try: @@ -347,7 +355,7 @@ class Ascender(): return (rdtype, None, None) priority, weight, destport, target = value.split(' ') - protonum = protocols.get(proto) + protonum = SUPPORTED_PROTOCOLS.get(proto) if protonum is None: logging.warning("invalid protocol: %s", proto) return (rdtype, None, None) @@ -447,32 +455,6 @@ class Ascender(): return ret @staticmethod - def add_srv_record_to_gns(record, zonename): - """ - Adds a SRV record to GNS - """ - if not Ascender.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]) - ret = sp.run([GNUNET_NAMESTORE_COMMAND, - '-z', zonename, - '-a', '-n', dnsname_str, - '-t', rtype_str, - '-V', str(value), - '-e', '%ds' % ttl]) - logging.info("executed command: %s", debug) - if ret.returncode != 0: - logging.warning("failed to add %s record %s", - rtype_str, dnsname_str) - - @staticmethod def add_soa_record_to_gns(record, zonename): """ Adds a SOA record to GNS diff --git a/setup.py b/setup.py @@ -10,7 +10,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="ascension", - version="0.3.0", + version="0.4.0", author="rexxnor", author_email="rexxnor+gnunet@brief.li", description="Tool to migrate DNS Zones to the GNU Name System",