-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdnsviz.py
executable file
·60 lines (53 loc) · 1.46 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/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()