Commit 5bdcde4a authored by Maxime Bombar's avatar Maxime Bombar
Browse files

[dnssec_generate] add verbose mode

parent 9f9e950d
......@@ -4,6 +4,7 @@ import json
import os
import re
import subprocess
import argparse
path = os.path.dirname(os.path.abspath(__file__))
......@@ -13,10 +14,21 @@ try:
except:
zones = []
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Gestion de DNSSEC")
parser.add_argument('-v', '--verbose', help="Mode verbeux", action="store_true")
args = parser.parse_args()
verbose = args.verbose
ds_records = {}
for zone in zones:
cdss = subprocess.check_output(['/usr/sbin/knotc', 'zone-read', zone, '@', 'CDS'])[:-1].decode('utf-8').split('\n')
if verbose:
print("Getting CDS of %s:" % (zone,))
print("/usr/sbin/knotcs zone-read %s @ CDS" % (zone,))
cdss = subprocess.check_output(['/usr/sbin/knotc', 'zone-read', zone, '@', 'CDS'])[:-1].decode('utf-8').split('\n')
if verbose:
print("CDS of %s = %s" % (zone, cdss))
for cds in cdss:
ds = {}
try:
......@@ -33,5 +45,8 @@ if __name__ == '__main__':
if not zone in ds_records:
ds_records[zone] = []
ds_records[zone].append(ds)
if verbose:
print("DS record of %s : %s" % (zone, ds))
print("\n\n")
with open('dnssec.json', 'w') as dnssec:
json.dump(ds_records, dnssec)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment