commit 7e1e8df9145a8524bba10030683e9844dd71b1bc
parent 7e8b3fe81e448734f7cccc96cbeb6163f74bae89
Author: rexxnor <rexxnor+gnunet@brief.li>
Date: Thu, 9 May 2019 21:55:25 +0200
added --dry-run option, bumped version, updated docs
Diffstat:
4 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/README b/README
@@ -38,11 +38,12 @@ Taken from the docstring of the ascension.py file:
Ascension
Usage:
- ascension <domain> [-d] [-p] [-s] [--minimum-ttl=<ttl>]
+ ascension <domain> [-d] [-p] [-s] [--minimum-ttl=<ttl>] [--dry-run]
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 <domain> -n <transferns> [-d] [-p] [-s] [--minimum-ttl=<ttl>] [--dry-run]
+ ascension <domain> -n <transferns> <port> [-d] [-p] [-s] [--minimum-ttl=<ttl>] [--dry-run]
ascension -p | --public
+ ascension -s | --debug
ascension -s | --standalone
ascension -h | --help
ascension -v | --version
@@ -52,6 +53,7 @@ Options:
<port> Port for zone transfer
<transferns> DNS Server that does the zone transfer
--minimum-ttl=<ttl> Minimum TTL for records to migrate [default: 3600]
+ --dry-run Only try if a zone transfer is allowed
-p --public Make records public on the DHT
-s --standalone Run ascension once
-d --debug Enable debugging
diff --git a/ascension.1 b/ascension.1
@@ -21,7 +21,7 @@
.\"
.\" SPDX-License-Identifier: GPL3.0-or-later OR FDL1.3-or-later
.\"
-.Dd May 1, 2019
+.Dd May 9, 2019
.Dt ASCENSION 1
.Os
.Sh NAME
@@ -29,10 +29,10 @@
.Nd migrate existing DNS zones into the GNU Name System
.Sh SYNOPSIS
.Nm
-.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 Ar domain Fl d Fl p Fl s \- minimum-ttl=<ttl> \- dry-run
+.Op Ar domain port Fl d Fl p Fl s \- minimum-ttl=<ttl> \- dry-run
+.Op Ar domain Fl n Ar transferns Fl d Fl p Fl s Fl \- minimum-ttl=<ttl> \- dry-run
+.Op Ar domain Fl n Ar transferns Ar port Fl d Fl p Fl s \- minimum-ttl=<ttl> \- dry-run
.Op Fl d | \-debug
.Op Fl h | \-help
.Op Fl p | \-public
diff --git a/ascension/ascension.py b/ascension/ascension.py
@@ -20,11 +20,12 @@
# Author rexxnor
"""
Usage:
- ascension <domain> [-d] [-p] [-s] [--minimum-ttl=<ttl>]
+ ascension <domain> [-d] [-p] [-s] [--minimum-ttl=<ttl>] [--dry-run]
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 <domain> -n <transferns> [-d] [-p] [-s] [--minimum-ttl=<ttl>] [--dry-run]
+ ascension <domain> -n <transferns> <port> [-d] [-p] [-s] [--minimum-ttl=<ttl>] [--dry-run]
ascension -p | --public
+ ascension -s | --debug
ascension -s | --standalone
ascension -h | --help
ascension -v | --version
@@ -34,6 +35,7 @@ Options:
<port> Port for zone transfer
<transferns> DNS Server that does the zone transfer
--minimum-ttl=<ttl> Minimum TTL for records to migrate [default: 3600]
+ --dry-run Only try if a zone transfer is allowed
-p --public Make records public on the DHT
-s --standalone Run ascension once
-d --debug Enable debugging
@@ -291,7 +293,7 @@ class Ascender():
ttl = values.ttl
gnspkeys = list(filter(lambda record: str(record).startswith('gns--pkey--')
- and illegalchars not in str(record[11:]), values))
+ and illegalchars not in str(record)[11:], values))
num_gnspkeys = len(gnspkeys)
if not num_gnspkeys:
@@ -677,7 +679,7 @@ def main():
Initializes object and handles arguments
"""
# argument parsing from docstring definition
- args = docopt.docopt(__doc__, version='Ascension 0.6.0')
+ args = docopt.docopt(__doc__, version='Ascension 0.6.1')
# argument parsing
debug = args['--debug']
@@ -686,6 +688,7 @@ def main():
port = args['<port>'] if args['<port>'] else "53"
flags = "p" if args.get('--public') else "n"
standalone = bool(args.get('--standalone'))
+ dryrun = bool(args.get('--dry-run'))
minimum = args['--minimum-ttl']
# Change logging severity to debug
@@ -721,6 +724,12 @@ def main():
port=ascender.port)
dns_zone_serial = ascender.get_dns_zone_serial(ascender.domain,
ascender.transferns)
+
+ if dryrun:
+ if dns_zone_serial:
+ return 0
+ return 1
+
if not dns_zone_serial:
logging.error("Could not get DNS zone serial")
if standalone:
diff --git a/setup.py b/setup.py
@@ -28,7 +28,7 @@ with open("README", "r") as fh:
setuptools.setup(
name="ascension",
- version="0.6.0",
+ version="0.6.1",
author="rexxnor",
author_email="rexxnor+gnunet@brief.li",
description="Tool to migrate DNS Zones to the GNU Name System",