From 644302a5b75545bf1e41c27129f99b5caee9f78e Mon Sep 17 00:00:00 2001 From: Christian Huitema Date: Fri, 15 Sep 2023 15:41:20 -0700 Subject: [PATCH 1/2] Fix root addresses in table check fix --- travis/check-dnsstats-tables.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/travis/check-dnsstats-tables.py b/travis/check-dnsstats-tables.py index 9a8065f..094d9fc 100755 --- a/travis/check-dnsstats-tables.py +++ b/travis/check-dnsstats-tables.py @@ -1,6 +1,16 @@ #!/usr/bin/env python import re, sys, csv +import ipaddress + +def canonical_ipaddress(addr): + try: + ip = ipaddress.ip_address(addr) + addr = str(ip) + except: + print("Invalid IP: " + addr) + return addr + try: # For Python 3.0 and later from urllib.request import urlopen @@ -57,8 +67,10 @@ try: root_hints = urlopen("https://www.internic.net/domain/named.root") \ .read().decode('utf-8') - root_hints = set([ln.split()[-1] for ln in root_hints.split('\n') - if ln[0].isalpha()]) + print("Got root hints, " + str(len(root_hints)) + " chars."); + root_hints = set([ln.split()[-1] for ln in root_hints.split('\n') + if len(ln) > 0 and ln[0].isalpha()]) + root_hints = set(canonical_ipaddress(ip) for ip in root_hints) if roots != root_hints: if root_hints - roots: fail = True From 4aea7e9a92ae0c63baeab6dcde75bec2a5e12f2b Mon Sep 17 00:00:00 2001 From: Christian Huitema Date: Fri, 15 Sep 2023 15:44:19 -0700 Subject: [PATCH 2/2] Remove debug printf --- travis/check-dnsstats-tables.py | 1 - 1 file changed, 1 deletion(-) diff --git a/travis/check-dnsstats-tables.py b/travis/check-dnsstats-tables.py index 094d9fc..19dce9a 100755 --- a/travis/check-dnsstats-tables.py +++ b/travis/check-dnsstats-tables.py @@ -67,7 +67,6 @@ def canonical_ipaddress(addr): try: root_hints = urlopen("https://www.internic.net/domain/named.root") \ .read().decode('utf-8') - print("Got root hints, " + str(len(root_hints)) + " chars."); root_hints = set([ln.split()[-1] for ln in root_hints.split('\n') if len(ln) > 0 and ln[0].isalpha()]) root_hints = set(canonical_ipaddress(ip) for ip in root_hints)