[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [ascension] 01/02: further refactoring, type defintions and
From: |
gnunet |
Subject: |
[GNUnet-SVN] [ascension] 01/02: further refactoring, type defintions and version bump, updated manpage |
Date: |
Wed, 01 May 2019 21:22:06 +0200 |
This is an automated email from the git hooks/post-receive script.
rexxnor pushed a commit to branch master
in repository ascension.
commit c1ee00c35074ef188ecd9a416dd98fe55aa37b7a
Author: rexxnor <address@hidden>
AuthorDate: Wed May 1 17:38:45 2019 +0200
further refactoring, type defintions and version bump, updated manpage
---
README | 25 ++++++++++++----------
ascension.1 | 33 ++++++++++++++++-------------
ascension/ascension.py | 57 ++++++++++++++++++++++++++++----------------------
setup.py | 2 +-
4 files changed, 66 insertions(+), 51 deletions(-)
diff --git a/README b/README
index 784536f..28e3e1f 100644
--- a/README
+++ b/README
@@ -38,22 +38,25 @@ Taken from the docstring of the ascension.py file:
Ascension
Usage:
- ascension <domain> [-d] [-p]
- ascension <domain> <port> [-d] [-p]
- ascension <domain> -n <transferns> [-d] [-p]
- ascension <domain> -n <transferns> <port> [-d] [-p]
+ ascension <domain> [-d] [-p] [-s] [--minimum-ttl=<ttl>]
+ ascension <domain> <port> [-d] [-p] [-s] [--minimum-ttl=<ttl>]
+ ascension <domain> -n <transferns> [-d] [-p] [-s] [--minimum-ttl=<ttl>]
+ ascension <domain> -n <transferns> <port> [-d] [-p] [-s]
[--minimum-ttl=<ttl>]
ascension -p | --public
+ ascension -s | --standalone
ascension -h | --help
ascension -v | --version
Options:
- <domain> Domain to migrate
- <port> Port for zone transfer
- <transferns> DNS Server that does the zone transfer
- -p --public Make records public on the DHT
- -d --debug Enable debugging
- -h --help Show this screen.
- -v --version Show version.
+ <domain> Domain to migrate
+ <port> Port for zone transfer
+ <transferns> DNS Server that does the zone transfer
+ --minimum-ttl=<ttl> Minimum TTL for records to migrate [default: 3600]
+ -p --public Make records public on the DHT
+ -s --standalone Run ascension once
+ -d --debug Enable debugging
+ -h --help Show this screen.
+ -v --version Show version.
```
Example use:
diff --git a/ascension.1 b/ascension.1
index c3b7f73..b50fbd7 100644
--- a/ascension.1
+++ b/ascension.1
@@ -21,7 +21,7 @@
.\"
.\" SPDX-License-Identifier: GPL3.0-or-later OR FDL1.3-or-later
.\"
-.Dd March 7, 2019
+.Dd Mai 1, 2019
.Dt ASCENSION 1
.Os
.Sh NAME
@@ -29,14 +29,15 @@
.Nd migrate existing DNS zones into the GNU Name System
.Sh SYNOPSIS
.Nm
-.Op Ar domain Fl d Fl p
-.Op Ar domain port Fl d Fl p
-.Op Ar domain Fl n Ar transferns Fl d Fl p
-.Op Ar domain Fl n Ar transferns Ar port Fl d Fl p
+.Op Ar domain Fl d Fl p Fl s Fl minimum-ttl=<ttl>
+.Op Ar domain port Fl d Fl p Fl s Fl minimum-ttl=<ttl>
+.Op Ar domain Fl n Ar transferns Fl d Fl p Fl s Fl minimum-ttl=<ttl>
+.Op Ar domain Fl n Ar transferns Ar port Fl d Fl p Fl s Fl minimum-ttl=<ttl>
.Op Fl d | \-debug
.Op Fl h | \-help
.Op Fl p | \-public
.Op Fl v | \-version
+.Op Fl s | \-standalone
.Sh DESCRIPTION
.Nm
is a tool to migrate existing DNS Zones into the GNU Name System (GNS) using
incremental zone transfers (AXFR/IXFR).
@@ -50,18 +51,20 @@ relies on these 3 GNUnet services,
.Xr gnunet-arm 1
must be installed and running.
.Bl -tag -width Ds
-.It Ar domain Fl d Fl p
+.It Ar domain Fl d Fl p Fl s Fl minimum-ttl=<ttl>
Migrate the DOMAIN passed as domain.
-The debug and public options are optional.
-.It Ar domain port Fl d Fl p
+The debug, public and standalone options are optional.
+.It Ar domain port Fl d Fl p Fl s Fl minimum-ttl=<ttl>
Migrate the DOMAIN domain, using port for zone transfer.
-The debug and public options are optional.
-.It Ar domain Fl n Ar transferns Fl d Fl p
+The debug, public and standalone options are optional.
+.It Ar domain Fl n Ar transferns Fl d Fl p Fl s Fl minimum-ttl=<ttl>
Migrate the DOMAIN domain from the DNS server transferns.
-The debug and public options are optional.
-.It Ar domain Fl n Ar transferns Ar port Fl d Fl p
+The debug, public and standalone options are optional.
+.It Ar domain Fl n Ar transferns Ar port Fl d Fl p Fl s Fl minimum-ttl=<ttl>
Migrate the DOMAIN domain from the DNS server transferns using port for the
zone transfer.
-The debug and public options are optional.
+The debug, public and standalone options are optional.
+.It Fl s | \-standalone
+Run Ascension once
.It Fl d | \-debug
Enable debugging
.It Fl h | \-help
@@ -92,7 +95,9 @@ tool was designed and written in 2018 by
.An rexxnor Aq Mt address@hidden .
.Sh AUTHORS
This man page was written by
-.An ng0 Aq Mt address@hidden ,
+.An ng0 Aq Mt address@hidden
+and updated by
+.An rexxnor Aq Mt address@hidden
it first appeared in
.Nm
0.5.1.
diff --git a/ascension/ascension.py b/ascension/ascension.py
index 3f035db..8815d5f 100644
--- a/ascension/ascension.py
+++ b/ascension/ascension.py
@@ -82,7 +82,12 @@ class Ascender():
"""
Class that provides migration for any given domain
"""
- def __init__(self, domain, transferns, port, flags, minimum):
+ def __init__(self,
+ domain: str,
+ transferns: str,
+ port: str,
+ flags: str,
+ minimum: str) -> None:
self.domain = domain
if domain[-1] == '.':
self.domain = self.domain[:-1]
@@ -97,7 +102,7 @@ class Ascender():
self.minimum = int(minimum)
self.subzonedict = dict()
- def bootstrap_zone(self):
+ def bootstrap_zone(self) -> None:
"""
Creates the zone in gnunet
"""
@@ -108,7 +113,9 @@ class Ascender():
except sp.CalledProcessError:
logging.info("Zone %s already exists!", self.domain)
- def get_dns_zone_serial(self, domain, resolver=None):
+ def get_dns_zone_serial(self,
+ domain: str,
+ resolver=None) -> dns.rdatatype.SOA:
"""
Gets the current serial for a given zone
:param domain: Domain to query for in DNS
@@ -154,7 +161,7 @@ class Ascender():
self.transferns = str(soa_record[2].mname)
return soa_record[2].serial
- def add_records_to_gns(self):
+ def add_records_to_gns(self) -> None:
"""
Extracts records from zone and adds them to GNS
:raises AttributeError: When getting incomplete data
@@ -347,7 +354,9 @@ class Ascender():
logging.info("All records have been added!")
@staticmethod
- def add_recordline_to_gns(recordline, zonename, label):
+ def add_recordline_to_gns(recordline: list,
+ zonename: str,
+ label: str) -> None:
"""
Replaces records in zone or adds them if not
:param recordline: records to replace as list in form
@@ -370,7 +379,11 @@ class Ascender():
logging.info("successfully added record with command %s",
' '.join(ret.args))
- def transform_to_gns_format(self, record, rdtype, zonename, label):
+ def transform_to_gns_format(self,
+ record: dns.rdata.Rdata,
+ rdtype: dns.rdata.Rdata,
+ zonename: str,
+ label: str) -> tuple:
"""
Transforms value of record to GNS compatible format
:param record: record to transform
@@ -469,7 +482,7 @@ class Ascender():
logging.info("Did not transform record of type: %s", rdtype)
return (rdtype, value, label)
- def get_gns_zone_serial(self):
+ def get_gns_zone_serial(self) -> int:
"""
Fetches the zones serial from GNS
:returns: serial of the SOA record in GNS
@@ -481,24 +494,16 @@ class Ascender():
serial = serial.decode()
except sp.CalledProcessError:
serial = ""
- soa_serial = None
+ soa_serial = 0
soapattern = re.compile(r'.+\s(\d+),\d+,\d+,\d+,\d+', re.M)
if re.findall(soapattern, serial):
soa_serial = re.findall(soapattern, serial)[0]
else:
- soa_serial = None
+ soa_serial = 0
return soa_serial
- def get_zone_soa_expiry(self):
- """
- Extracts the current serial from the class SOA
- :returns: refresh time of the current SOA record
- """
- ttlpattern = re.compile(r'.+\s\d+\s(\d+)\s\d+\s\d+\s\d+', re.M)
- return re.findall(ttlpattern, str(self.soa[2]))
-
@staticmethod
- def get_zone_soa(zone):
+ def get_zone_soa(zone) -> dns.rdatatype.SOA:
"""
Fetches soa record from zone a given zone
:param zone: A dnspython zone
@@ -510,7 +515,7 @@ class Ascender():
soa = soarecord
return soa
- def add_soa_record_to_gns(self, record):
+ def add_soa_record_to_gns(self, record) -> None:
"""
Adds a SOA record to GNS
:param record: The record to add
@@ -539,7 +544,7 @@ class Ascender():
self.add_recordline_to_gns(recordline, self.domain, str(label))
@staticmethod
- def create_zone_and_get_pkey(zonestring):
+ def create_zone_and_get_pkey(zonestring: str) -> str:
"""
Creates the zone in zonestring and returns pkey
:param zonestring: The label name of the zone
@@ -569,7 +574,10 @@ class Ascender():
return pkey_zone
@staticmethod
- def add_pkey_record_to_zone(pkey, domain, label, ttl):
+ def add_pkey_record_to_zone(pkey: str,
+ domain: str,
+ label: str,
+ ttl: str) -> None:
"""
Adds the pkey of the subzone to the parent zone
:param pkey: the public key of the child zone
@@ -600,10 +608,9 @@ class Ascender():
label, domain)
#logging.warning("PKEY record %s already exists in %s", label, domain)
- def create_zone_hierarchy(self):
+ def create_zone_hierarchy(self) -> None:
"""
Creates the zone hierarchy in GNS for label
- :param label: the split record to create zones for
"""
domain = self.domain
@@ -624,13 +631,13 @@ def main():
Initializes object and handles arguments
"""
# argument parsing from docstring definition
- args = docopt.docopt(__doc__, version='Ascension 0.5.0')
+ args = docopt.docopt(__doc__, version='Ascension 0.6.0')
# argument parsing
debug = args['--debug']
domain = args.get('<domain>', None)
transferns = args['<transferns>'] if args['<transferns>'] else None
- port = args['<port>'] if args['<port>'] else 53
+ port = args['<port>'] if args['<port>'] else "53"
flags = "p" if args.get('--public') else "n"
standalone = bool(args.get('--standalone'))
minimum = args['--minimum-ttl']
diff --git a/setup.py b/setup.py
index cd0b403..94d6b14 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ with open("README", "r") as fh:
setuptools.setup(
name="ascension",
- version="0.5.0",
+ version="0.6.0",
author="rexxnor",
author_email="address@hidden",
description="Tool to migrate DNS Zones to the GNU Name System",
--
To stop receiving notification emails like this one, please contact
address@hidden