More opnsense
This commit is contained in:
parent
8a5375c5c8
commit
6beadaba5f
@ -1,6 +1,6 @@
|
||||
import requests, schedule, time
|
||||
from bs4 import BeautifulSoup
|
||||
from whatDomain import *
|
||||
from whatDomain import ermWhatAAAATheIpFromDomainYaCrazy, ermWhatATheIpFromDomainYaCrazy
|
||||
|
||||
|
||||
|
||||
@ -9,25 +9,9 @@ IPv4FILE = "./OPNS_MirrorListV4"
|
||||
IPv6FILE = "./OPNS_MirrorListV6"
|
||||
|
||||
|
||||
# Define EU and American countries as well as Security for security updates
|
||||
target_countries = set([
|
||||
# Europe
|
||||
"Austria", "Belgium", "Bulgaria", "Croatia", "Czech Republic", "Denmark",
|
||||
"Estonia", "Finland", "France", "Germany", "Greece", "Hungary", "Iceland",
|
||||
"Ireland", "Italy", "Latvia", "Lithuania", "Netherlands", "Norway", "Poland",
|
||||
"Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Sweden", "Switzerland",
|
||||
"United Kingdom", "Moldova",
|
||||
# America
|
||||
"Argentina", "Brazil", "Canada", "Chile", "Colombia", "Costa Rica", "Ecuador",
|
||||
"Mexico", "Peru", "United States", "Uruguay", "Venezuela",
|
||||
# Others
|
||||
"Security", "Extras"
|
||||
])
|
||||
|
||||
|
||||
def sanitizeURL(inpurl: str):
|
||||
# if not "/" in inpurl[:-1]:
|
||||
# inpurl += "/"
|
||||
if not "/" in inpurl[:-1]:
|
||||
inpurl += "/"
|
||||
if "https://" in inpurl:
|
||||
outurl = inpurl[8:]
|
||||
elif "http://" in inpurl:
|
||||
@ -159,6 +143,25 @@ def LeJob():
|
||||
# time.sleep(30) #Wait one minute
|
||||
# # LeJob()
|
||||
|
||||
|
||||
def DNSerrHandling(inpErrorCode: int):
|
||||
|
||||
match inpErrorCode:
|
||||
case -1:
|
||||
return "No answer from dns server."
|
||||
case -2:
|
||||
# return "All nameservers failed to answer the query."
|
||||
print("All nameservers failed to answer the query.\n Fix your DNS servers.")
|
||||
exit(-1)
|
||||
case -3:
|
||||
return "The DNS query name does not exist."
|
||||
case -4:
|
||||
return "The DNS querry got timed out."
|
||||
case _:
|
||||
return "Not implemented"
|
||||
|
||||
|
||||
|
||||
gigalist = []
|
||||
|
||||
payload = requests.get(OPNSNSMIRRORURL)
|
||||
@ -179,11 +182,12 @@ for data in soup.find_all('div', class_='download_section'):
|
||||
IPv4Dict = ermWhatATheIpFromDomainYaCrazy(saniturl)
|
||||
IPv6Dict = ermWhatAAAATheIpFromDomainYaCrazy(saniturl)
|
||||
|
||||
if IPv4Dict == -1:
|
||||
print(f"ERROR RESOLVING {saniturl} IPv4 address")
|
||||
|
||||
if type(IPv4Dict) == int:
|
||||
print(f"{DNSerrHandling(IPv4Dict)}")
|
||||
continue
|
||||
elif IPv6Dict == -1:
|
||||
print(f"ERROR RESOLVING {saniturl} IPv6 address")
|
||||
elif type(IPv6Dict) == int:
|
||||
print(f"ERROR RESOLVING {saniturl} IPv6 address with error code {IPv6Dict}")
|
||||
continue
|
||||
|
||||
for key, ip in IPv4Dict.items():
|
||||
|
@ -22,8 +22,12 @@ def ermWhatATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "Dom
|
||||
result = dns.resolver.resolve(inpDomainNameOrSomething, 'A')
|
||||
except dns.resolver.NoAnswer:
|
||||
return -1
|
||||
except dns.resolver.NoNameservers or dns.resolver.LifetimeTimeout:
|
||||
return -1
|
||||
except dns.resolver.NoNameservers:
|
||||
return -2
|
||||
except dns.resolver.NXDOMAIN:
|
||||
return -3
|
||||
except dns.resolver.LifetimeTimeout:
|
||||
return -4
|
||||
for i, something in enumerate(result):
|
||||
outDict[i] = something.to_text()
|
||||
# i += 1
|
||||
@ -49,8 +53,12 @@ def ermWhatAAAATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "
|
||||
result = dns.resolver.resolve(inpDomainNameOrSomething, 'AAAA')
|
||||
except dns.resolver.NoAnswer:
|
||||
return -1
|
||||
except dns.resolver.NoNameservers or dns.resolver.LifetimeTimeout:
|
||||
return -1
|
||||
except dns.resolver.NoNameservers:
|
||||
return -2
|
||||
except dns.resolver.NXDOMAIN:
|
||||
return -3
|
||||
except dns.resolver.LifetimeTimeout:
|
||||
return -4
|
||||
for i, something in enumerate(result):
|
||||
outDict[i] = something.to_text()
|
||||
# i += 1
|
||||
@ -80,7 +88,11 @@ def ermWhatPTRTheIpFromDomainYaCrazy(inpIpAddressOrSomething: Annotated[str, "IP
|
||||
except dns.resolver.NoAnswer:
|
||||
return -1
|
||||
except dns.resolver.NoNameservers:
|
||||
return -1
|
||||
return -2
|
||||
except dns.resolver.NXDOMAIN:
|
||||
return -3
|
||||
except dns.resolver.LifetimeTimeout:
|
||||
return -4
|
||||
for i, something in enumerate(result):
|
||||
outDict[i] = something.to_text()
|
||||
# i += 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user