More opnsense
This commit is contained in:
		
							parent
							
								
									8a5375c5c8
								
							
						
					
					
						commit
						6beadaba5f
					
				| @ -1,6 +1,6 @@ | |||||||
| import requests, schedule, time | import requests, schedule, time | ||||||
| from bs4 import BeautifulSoup | from bs4 import BeautifulSoup | ||||||
| from whatDomain import * | from whatDomain import ermWhatAAAATheIpFromDomainYaCrazy, ermWhatATheIpFromDomainYaCrazy | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -9,25 +9,9 @@ IPv4FILE = "./OPNS_MirrorListV4" | |||||||
| IPv6FILE = "./OPNS_MirrorListV6" | 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): | def sanitizeURL(inpurl: str): | ||||||
|     # if not "/" in inpurl[:-1]: |     if not "/" in inpurl[:-1]: | ||||||
|     #     inpurl += "/"  |         inpurl += "/"  | ||||||
|     if "https://" in inpurl: |     if "https://" in inpurl: | ||||||
|         outurl = inpurl[8:] |         outurl = inpurl[8:] | ||||||
|     elif "http://" in inpurl: |     elif "http://" in inpurl: | ||||||
| @ -159,6 +143,25 @@ def LeJob(): | |||||||
| #     time.sleep(30)  #Wait one minute | #     time.sleep(30)  #Wait one minute | ||||||
| #     # LeJob() | #     # 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 = [] | gigalist = [] | ||||||
| 
 | 
 | ||||||
| payload = requests.get(OPNSNSMIRRORURL) | payload = requests.get(OPNSNSMIRRORURL) | ||||||
| @ -179,11 +182,12 @@ for data in soup.find_all('div', class_='download_section'): | |||||||
|         IPv4Dict = ermWhatATheIpFromDomainYaCrazy(saniturl) |         IPv4Dict = ermWhatATheIpFromDomainYaCrazy(saniturl) | ||||||
|         IPv6Dict = ermWhatAAAATheIpFromDomainYaCrazy(saniturl) |         IPv6Dict = ermWhatAAAATheIpFromDomainYaCrazy(saniturl) | ||||||
| 
 | 
 | ||||||
|         if IPv4Dict == -1: | 
 | ||||||
|             print(f"ERROR RESOLVING {saniturl} IPv4 address") |         if type(IPv4Dict) == int: | ||||||
|  |             print(f"{DNSerrHandling(IPv4Dict)}") | ||||||
|             continue |             continue | ||||||
|         elif IPv6Dict == -1: |         elif type(IPv6Dict) == int: | ||||||
|             print(f"ERROR RESOLVING {saniturl} IPv6 address") |             print(f"ERROR RESOLVING {saniturl} IPv6 address with error code {IPv6Dict}") | ||||||
|             continue |             continue | ||||||
|          |          | ||||||
|         for key, ip in IPv4Dict.items(): |         for key, ip in IPv4Dict.items(): | ||||||
|  | |||||||
| @ -22,8 +22,12 @@ def ermWhatATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "Dom | |||||||
|         result = dns.resolver.resolve(inpDomainNameOrSomething, 'A') |         result = dns.resolver.resolve(inpDomainNameOrSomething, 'A') | ||||||
|     except dns.resolver.NoAnswer: |     except dns.resolver.NoAnswer: | ||||||
|         return -1 |         return -1 | ||||||
|     except dns.resolver.NoNameservers or dns.resolver.LifetimeTimeout: |     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): |     for i, something in enumerate(result): | ||||||
|         outDict[i] = something.to_text() |         outDict[i] = something.to_text() | ||||||
|         # i += 1 |         # i += 1 | ||||||
| @ -49,8 +53,12 @@ def ermWhatAAAATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, " | |||||||
|         result = dns.resolver.resolve(inpDomainNameOrSomething, 'AAAA') |         result = dns.resolver.resolve(inpDomainNameOrSomething, 'AAAA') | ||||||
|     except dns.resolver.NoAnswer: |     except dns.resolver.NoAnswer: | ||||||
|         return -1 |         return -1 | ||||||
|     except dns.resolver.NoNameservers or dns.resolver.LifetimeTimeout: |     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): |     for i, something in enumerate(result): | ||||||
|         outDict[i] = something.to_text() |         outDict[i] = something.to_text() | ||||||
|         # i += 1 |         # i += 1 | ||||||
| @ -80,7 +88,11 @@ def ermWhatPTRTheIpFromDomainYaCrazy(inpIpAddressOrSomething: Annotated[str, "IP | |||||||
|     except dns.resolver.NoAnswer: |     except dns.resolver.NoAnswer: | ||||||
|         return -1 |         return -1 | ||||||
|     except dns.resolver.NoNameservers: |     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): |     for i, something in enumerate(result): | ||||||
|         outDict[i] = something.to_text() |         outDict[i] = something.to_text() | ||||||
|         # i += 1 |         # i += 1 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 YuruC3
						YuruC3