Commit fe4b48c0 authored by Sven Van Dyck's avatar Sven Van Dyck

See #1

parent cfed1905
Pipeline #44279 passed with stage
in 4 minutes and 30 seconds
......@@ -11,6 +11,8 @@ from typing import Counter, Dict, List, Iterable, Iterator, NamedTuple, Set, Uni
import ipaddress
class EDNSResult(IntEnum):
EDNS evaluation result for single zone
......@@ -58,10 +60,17 @@ def eval_edns_nsset(nsips: Iterable[str], nsstats: Dict[str, Counter[EDNSResult]
"""combined result for the whole nsset"""
set_results = []
for ip in nsips:
#try: # this is an error in ednscomp input generation
#except KeyError as ex:
# print('IP {} not found in ednscomp stats'.format(ip))
#print (str(ip))
if ip.startswith("::ffff"):
#Convert this to match how genreport manipulates such an ip
#print (ip)
ip="::ffff:" + str(ip)
try: # this is an error in ednscomp input generation
except KeyError as ex:
print('ERROR ERROR: IP {} not found in ednscomp stats'.format(ip))
if len(set_results) == 0:
raise KeyError('no IPs')
......@@ -165,7 +174,7 @@ class ResultTable():
return '\n'.join(lines)
def text(self) -> str:
def text(self) -> str:
output = '{:13s}| {:.20s} | {:.20s}\n'.format(*self.header)
output += '{:.13s}+-{:.20s}--+--{:.20s}\n'.format(*['-'*30]*3)
for mode, modename in self.names.items():
......@@ -9,6 +9,8 @@ import
import dns.rdatatype
import dns.resolver
import ipaddress
def yield_ns_name(nsnames, mapping):
returns: stream of NS names
......@@ -27,14 +29,15 @@ def resolve(qname:, qtype) -> Set[str]:
return set(ip.address for ip in answer)
return set(ipaddress.ip_address(ip.address).compressed for ip in answer)
def get_ips(nsname: -> Tuple[, Set[str]]:
ips = set() # type: Set[str]
ips = resolve(nsname, dns.rdatatype.A)
ips = ips.union(resolve(nsname, dns.rdatatype.AAAA))
except Exception: # return empty address set
except Exception as e: # return empty address set
return nsname, ips
......@@ -44,7 +47,7 @@ def load_nsnames() -> Set[]:
nslist = pickle.load(nslist_file)'loaded %s NS names', len(nslist))
return nslist
def load_nsname2ipset() -> Dict[, Set[str]]:'loading previous mapping')
......@@ -93,3 +96,4 @@ if __name__ == "__main__":
# machine readable output: total # of NS names
\ No newline at end of file
......@@ -9,6 +9,7 @@ import sys
from typing import Dict, List, Iterable, Set, Tuple
import ipaddress
import dataapi
......@@ -44,7 +45,7 @@ def glue_ns2ipset(nslist: Set[], zoneobj: \
for rdtype in (dns.rdatatype.A, dns.rdatatype.AAAA):
rrset = node.get_rdataset(dns.rdataclass.IN, rdtype)
if rrset:
ipset = ipset.union(set(ip.address for ip in rrset))
ipset = ipset.union(set(ipaddress.ip_address(ip.address).compressed for ip in rrset))
if ipset: # do not store glueless names
ns2ipset[nsname] = ipset
return ns2ipset
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