Commit 647f5907 authored by Felix Yan's avatar Felix Yan

verify: add verbose check function

parent 6cd7659a
...@@ -151,33 +151,54 @@ class ChinaListVerify(object): ...@@ -151,33 +151,54 @@ class ChinaListVerify(object):
else: else:
return None return None
def check_domain_list(self, domain_list, sample=100): def check_domain_verbose(self, domain):
domains = self.load_list(domain_list) try:
if sample:
domains = random.sample(domains, sample)
for domain in domains:
try: try:
self.check_domain(domain) self.check_domain(domain)
except NXDOMAIN: except NXDOMAIN:
print(colored("NXDOMAIN found in (cdnlist or) domain: " + domain, "white", "on_red")) print(colored("NXDOMAIN found in (cdnlist or) domain: " + domain, "white", "on_red"))
raise
except WhitelistMatched: except WhitelistMatched:
print(colored("NS Whitelist matched for domain: " + domain, "green")) print(colored("NS Whitelist matched for domain: " + domain, "green"))
raise
except CDNListVerified: except CDNListVerified:
print(colored("CDNList matched and verified for domain: " + domain, "green")) print(colored("CDNList matched and verified for domain: " + domain, "green"))
raise
except CDNListNotVerified: except CDNListNotVerified:
print(colored("CDNList matched but failed to verify for domain: " + domain, "red")) print(colored("CDNList matched but failed to verify for domain: " + domain, "red"))
raise
except BlacklistMatched: except BlacklistMatched:
print(colored("NS Blacklist matched for domain: " + domain, "red")) print(colored("NS Blacklist matched for domain: " + domain, "red"))
raise
except NSVerified: except NSVerified:
print(colored("NS verified for domain: " + domain, "green")) print(colored("NS verified for domain: " + domain, "green"))
raise
except NSNotVerified: except NSNotVerified:
print(colored("NS failed to verify for domain: " + domain, "red")) print(colored("NS failed to verify for domain: " + domain, "red"))
raise
except ChnroutesNotAvailable: except ChnroutesNotAvailable:
print("Additional Check disabled due to missing chnroutes. domain:", domain) print("Additional Check disabled due to missing chnroutes. domain:", domain)
raise
except NSNotAvailable: except NSNotAvailable:
print("Failed to get correct name server for domain:", domain) print("Failed to get correct name server for domain:", domain)
raise
else: else:
raise NotImplementedError raise NotImplementedError
except OK:
return True
except NotOK:
return False
except:
return None
else:
return None
def check_domain_list(self, domain_list, sample=100):
domains = self.load_list(domain_list)
if sample:
domains = random.sample(domains, sample)
for domain in domains:
self.check_domain_verbose(domain)
if __name__ == "__main__": if __name__ == "__main__":
......
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