Skip to content

Commit

Permalink
Fix root addresses in table check fix
Browse files Browse the repository at this point in the history
  • Loading branch information
huitema committed Sep 15, 2023
1 parent 529f8bb commit 644302a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions travis/check-dnsstats-tables.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 644302a

Please sign in to comment.