This commit is contained in:
2021-08-30 12:58:04 +02:00
parent e892152b0c
commit e64ce32d92
3 changed files with 35 additions and 35 deletions

View File

@@ -15,21 +15,21 @@ from dns import resolver
# list of puzzle authoritative name servers
pitc_nameservers = [
'ns1.dnsimple.com.',
'ns2.dnsimple.com.',
'ns3.dnsimple.com.',
'ns4.dnsimple.com.',
'ns5.dnsmadeeasy.com.',
'ns6.dnsmadeeasy.com.',
'ns7.dnsmadeeasy.com.'
]
'ns1.dnsimple.com.',
'ns2.dnsimple.com.',
'ns3.dnsimple.com.',
'ns4.dnsimple.com.',
'ns5.dnsmadeeasy.com.',
'ns6.dnsmadeeasy.com.',
'ns7.dnsmadeeasy.com.'
]
# list of puzzle managed zone files
pitc_domains = [
'puzzle.ch.yaml',
'puzzle.yaml',
'nonpuzzle.yaml'
]
'puzzle.ch.yaml',
'puzzle.yaml',
'nonpuzzle.yaml'
]
# configure opendns resolver
resolver = resolver.Resolver()
@@ -37,13 +37,13 @@ resolver.nameservers = ['208.67.222.222','208.67.220.220']
def do_check(domains, nameservers, verbose=False):
'''
dsc: Implementatin of the check loop which writes output if verbose is set.
Checks if the authoritative ns returned for domain x is in the list
of nameservers provided as argument.
arg: [list], domains to check
arg: [list], verified nameservers
arg: [boolean], verbose printing or not
ret: [boolean], true if all checked nameservers are ok, false otherwise
dsc: Implementatin of the check loop which writes output if verbose is set.
Checks if the authoritative ns returned for domain x is in the list
of nameservers provided as argument.
arg: [list], domains to check
arg: [list], verified nameservers
arg: [boolean], verbose printing or not
ret: [boolean], true if all checked nameservers are ok, false otherwise
'''
for domain in domains:
returned_nameservers = get_authoritative_ns(domain)
@@ -63,9 +63,9 @@ def do_check(domains, nameservers, verbose=False):
def get_authoritative_ns(domain):
'''
dsc: Query the domain and return the authoritative name servers.
arg: [str], domain to query
ret: [list], list of nameservers or empty list on error.
dsc: Query the domain and return the authoritative name servers.
arg: [str], domain to query
ret: [list], list of nameservers or empty list on error.
'''
try:
answer = resolver.resolve(domain,'NS')
@@ -78,9 +78,9 @@ def get_authoritative_ns(domain):
def get_domains_from_yaml(filenames):
'''
dsc: Loads domain names from a list of yaml files.
arg: [list], filenames
ret: [list], arbitrary list of domain names, emptylist on err
dsc: Loads domain names from a list of yaml files.
arg: [list], filenames
ret: [list], arbitrary list of domain names, emptylist on err
'''
domains = []
try:
@@ -97,10 +97,10 @@ def get_domains_from_yaml(filenames):
def verify_authoritative_ns(nameserver, verified_nameservers):
'''
dsc: Verifies if the authoritative NS belongs to the puzzle managed NS.
arg: [str], nameserver to test
arg: [list], a list of verified nameservers
ret: [boolean], true if ok; false if nok.
dsc: Verifies if the authoritative NS belongs to the puzzle managed NS.
arg: [str], nameserver to test
arg: [list], a list of verified nameservers
ret: [boolean], true if ok; false if nok.
'''
if not isinstance(nameserver, str):
print("Type of nameserver must be string!")