Created
December 31, 2014 23:30
-
-
Save rajbot/b8f4459e721b54f65582 to your computer and use it in GitHub Desktop.
Query DNS servers to see which ones are blocking archive.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dns.resolver | |
from dns.exception import Timeout | |
import json | |
import time | |
f = open('in.json') | |
ips = json.load(f) | |
good = set() | |
bad = set() | |
timeout = set() | |
res = dns.resolver.Resolver() | |
res.timeout = 2 | |
res.lifetime = 2 | |
for ip in ips: | |
if ip['state'] != 'valid': | |
continue | |
res.nameservers = [ip['ip']] | |
print 'checking', ip['ip'] | |
try: | |
a = res.query('archive.org') | |
except Timeout: | |
timeout.add(ip['ip']) | |
print ' timeout' | |
continue | |
except Exception: | |
print ' fail' | |
continue | |
for rdata in a: | |
if rdata.address == '207.241.224.2': | |
good.add(ip['ip']) | |
else: | |
bad.add(ip['ip']) | |
print ' BAD', ip['ip'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment