Skip to content

Instantly share code, notes, and snippets.

@jerryc05
Last active July 17, 2021 02:02
Show Gist options
  • Save jerryc05/b9285909bd84fde371a80c3f248e5aa0 to your computer and use it in GitHub Desktop.
Save jerryc05/b9285909bd84fde371a80c3f248e5aa0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# pip3 install dnspython pythonping
# github.global.ssl.fastly.net
#
# github.com
# gist.github.com
# assets-cdn.github.com
#
# githubusercontent.com
# raw.githubusercontent.com
# gist.githubusercontent.com
# camo.githubusercontent.com
# avatars.githubusercontent.com
# avatars0.githubusercontent.com
# avatars1.githubusercontent.com
# avatars2.githubusercontent.com
# avatars3.githubusercontent.com
# avatars4.githubusercontent.com
# avatars5.githubusercontent.com
# avatars6.githubusercontent.com
# avatars7.githubusercontent.com
# avatars8.githubusercontent.com
#
# github.io
import sys
import typing as t
from dns.resolver import Answer, Resolver, get_default_resolver
from dns.exception import Timeout, DNSException
from pythonping import ping
if __name__ == '__main__':
if len(sys.argv) < 2:
print('ERR: Url not specified!')
ip_set: 'set[str]' = set()
for ns in get_default_resolver().nameservers + [
'8.8.8.8', '8.8.4.4', '9.9.9.9', '9.9.9.10', '1.1.1.1', '1.0.0.1',
'77.88.8.8', '77.88.8.1', '208.67.222.222', '208.67.220.220',
'208.67.222.220', '208.67.220.222', '185.121.177.177',
'169.239.202.202', '114.114.114.114', '114.114.115.115', '223.5.5.5',
'223.6.6.6', '199.85.126.10', '199.85.127.10', '8.26.56.26',
'8.20.247.20', '119.29.29.29', '182.254.118.118', '180.76.76.76',
'1.2.4.8', '210.2.4.8', '117.50.10.10', '52.80.52.52']:
my_resolver = Resolver(configure=False)
my_resolver.nameservers = [ns]
try:
answer = t.cast(Answer, my_resolver.resolve(sys.argv[1], 'a'))
for x in answer:
x = str(x)
if x not in ip_set:
ip_set.add(x)
print(f'{x} \t {ping(x).rtt_avg_ms:>6.2f} ms \t from {ns}')
except (Timeout, DNSException):
print(f'{ns} is not available')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment