add support for /16,/8 + show critical error if 'dnspython' isn't installed
This commit is contained in:
parent
e60a2b1927
commit
86c7a00b5b
1 changed files with 19 additions and 9 deletions
|
@ -8,12 +8,18 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import dns.name
|
try:
|
||||||
import dns.query
|
import dns.name
|
||||||
import dns.dnssec
|
import dns.query
|
||||||
import dns.message
|
import dns.dnssec
|
||||||
import dns.resolver
|
import dns.message
|
||||||
import dns.rdatatype
|
import dns.resolver
|
||||||
|
import dns.rdatatype
|
||||||
|
except ImportError:
|
||||||
|
print()
|
||||||
|
print("CRITICAL: this script requires the 'dnspython' libary, please install it using `python3 -m pip install dnspython`")
|
||||||
|
print()
|
||||||
|
exit(1)
|
||||||
|
|
||||||
# import errors so they could be try/catched
|
# import errors so they could be try/catched
|
||||||
import dns.exception
|
import dns.exception
|
||||||
|
@ -79,11 +85,15 @@ def get_domain_by_mntner(mntner):
|
||||||
line = line[20:]
|
line = line[20:]
|
||||||
_domain_name = ".".join(
|
_domain_name = ".".join(
|
||||||
line.split(".")[::-1]) + ".in-addr.arpa"
|
line.split(".")[::-1]) + ".in-addr.arpa"
|
||||||
if int(line.split("/")[1]) ==24:
|
if int(line.split("/")[1]) == 24:
|
||||||
_domain_name.replace("/24", "")
|
_domain_name = _domain_name.replace("0/24.", "")
|
||||||
|
elif int(line.split("/")[1]) == 16:
|
||||||
|
_domain_name = _domain_name.replace("0/16.0.", "")
|
||||||
|
elif int(line.split("/")[1]) == 8:
|
||||||
|
_domain_name = _domain_name.replace("0/8.0.0.", "")
|
||||||
elif int(line.split("/")[1]) <=24:
|
elif int(line.split("/")[1]) <=24:
|
||||||
# TODO: implement creation of multiple zones for every /24 within
|
# TODO: implement creation of multiple zones for every /24 within
|
||||||
pass
|
print(f"WARN: currently only ipv4 subnets with length >=24 or 16 or 8 are possible to be checked: relavent inetnum {line}")
|
||||||
elif line.startswith("nserver"):
|
elif line.startswith("nserver"):
|
||||||
nserver = line[20:].split(" ")
|
nserver = line[20:].split(" ")
|
||||||
# handle edge case where
|
# handle edge case where
|
||||||
|
|
Loading…
Add table
Reference in a new issue