-
Notifications
You must be signed in to change notification settings - Fork 1
/
dnsviz.py
executable file
·41 lines (34 loc) · 1.24 KB
/
dnsviz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3
import argparse
import logging
import subprocess
import sys
from respdiff import cli
import respdiff.dnsviz
def main():
cli.setup_logging()
parser = argparse.ArgumentParser(
description="use dnsviz to categorize domains (perfect, warnings, errors)")
cli.add_arg_config(parser)
cli.add_arg_dnsviz(parser)
parser.add_argument('input', type=str, help='input file with domains (one qname per line)')
args = parser.parse_args()
njobs = args.cfg['sendrecv']['jobs']
try:
probe = subprocess.run([
'dnsviz', 'probe', '-A', '-R', respdiff.dnsviz.TYPES, '-f',
args.input, '-t', str(njobs)], check=True, stdout=subprocess.PIPE)
except subprocess.CalledProcessError as exc:
logging.critical("dnsviz probe failed: %s", exc)
sys.exit(1)
except FileNotFoundError:
logging.critical("'dnsviz' tool is not installed!")
sys.exit(1)
try:
subprocess.run(['dnsviz', 'grok', '-o', args.dnsviz], input=probe.stdout,
check=True, stdout=subprocess.PIPE)
except subprocess.CalledProcessError as exc:
logging.critical("dnsviz grok failed: %s", exc)
sys.exit(1)
if __name__ == '__main__':
main()