Working OPNsense thing.
Now to integrate it into main
This commit is contained in:
24
code/main.py
24
code/main.py
@@ -123,13 +123,13 @@ def LeJob():
|
||||
|
||||
ip4Dict = ermWhatATheIpFromDomainYaCrazy(goodurl)
|
||||
|
||||
if ip4Dict == -1:
|
||||
try:
|
||||
for key, ip in ip4Dict.items():
|
||||
print(ip)
|
||||
|
||||
fW.write(ip + "/32" + "\n")
|
||||
except AttributeError:
|
||||
continue
|
||||
|
||||
for key, ip in ip4Dict.items():
|
||||
print(ip)
|
||||
|
||||
fW.write(ip + "/32" + "\n")
|
||||
|
||||
|
||||
with open(IPv6FILE, "r",) as fR, open(IPv6FILE, "w",) as fW:
|
||||
@@ -146,14 +146,14 @@ def LeJob():
|
||||
|
||||
ip6Dict = ermWhatAAAATheIpFromDomainYaCrazy(goodurl)
|
||||
|
||||
if ip6Dict == -1:
|
||||
try:
|
||||
for key, ip in ip6Dict.items():
|
||||
# print(ip)
|
||||
|
||||
fW.write(ip + "/128" + "\n")
|
||||
except AttributeError:
|
||||
continue
|
||||
|
||||
for key, ip in ip6Dict.items():
|
||||
# print(ip)
|
||||
|
||||
fW.write(ip + "/128" + "\n")
|
||||
|
||||
|
||||
# schedule.every().day.at("12:45").do(LeJob)
|
||||
schedule.every().day.at("17:44").do(LeJob)
|
||||
|
||||
@@ -21,7 +21,21 @@ def ermWhatATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "Dom
|
||||
try:
|
||||
result = dns.resolver.resolve(inpDomainNameOrSomething, 'A')
|
||||
except dns.resolver.NoAnswer:
|
||||
return -1
|
||||
print("\nDNS ERROR")
|
||||
print("No answer from dns server.\n")
|
||||
return 1
|
||||
except dns.resolver.NoNameservers:
|
||||
print("\nDNS ERROR")
|
||||
print("All nameservers failed to answer the query.\n Fix your DNS servers.\n")
|
||||
return 1
|
||||
except dns.resolver.NXDOMAIN:
|
||||
print("\nDNS ERROR")
|
||||
print("The DNS query name does not exist.\n")
|
||||
return 1
|
||||
except dns.resolver.LifetimeTimeout:
|
||||
print("\nDNS ERROR")
|
||||
print("The DNS querry got timed out.\nVerify that your FW or PiHole isn't blocking requests for that domain.\n")
|
||||
return 1
|
||||
for i, something in enumerate(result):
|
||||
outDict[i] = something.to_text()
|
||||
# i += 1
|
||||
@@ -46,7 +60,21 @@ def ermWhatAAAATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "
|
||||
try:
|
||||
result = dns.resolver.resolve(inpDomainNameOrSomething, 'AAAA')
|
||||
except dns.resolver.NoAnswer:
|
||||
return -1
|
||||
print("\nDNS ERROR")
|
||||
print("No answer from dns server.\n")
|
||||
return 1
|
||||
except dns.resolver.NoNameservers:
|
||||
print("\nDNS ERROR")
|
||||
print("All nameservers failed to answer the query.\n Fix your DNS servers.\n")
|
||||
return 1
|
||||
except dns.resolver.NXDOMAIN:
|
||||
print("\nDNS ERROR")
|
||||
print("The DNS query name does not exist.\n")
|
||||
return 1
|
||||
except dns.resolver.LifetimeTimeout:
|
||||
print("\nDNS ERROR")
|
||||
print("The DNS querry got timed out.\nVerify that your FW or PiHole isn't blocking requests for that domain.\n")
|
||||
return 1
|
||||
for i, something in enumerate(result):
|
||||
outDict[i] = something.to_text()
|
||||
# i += 1
|
||||
@@ -74,7 +102,21 @@ def ermWhatPTRTheIpFromDomainYaCrazy(inpIpAddressOrSomething: Annotated[str, "IP
|
||||
try:
|
||||
result = dns.resolver.resolve(whatToCheck, 'PTR')
|
||||
except dns.resolver.NoAnswer:
|
||||
return -1
|
||||
print("\nDNS ERROR")
|
||||
print("No answer from dns server.\n")
|
||||
return 1
|
||||
except dns.resolver.NoNameservers:
|
||||
print("\nDNS ERROR")
|
||||
print("All nameservers failed to answer the query.\n Fix your DNS servers.\n")
|
||||
return 1
|
||||
except dns.resolver.NXDOMAIN:
|
||||
print("\nDNS ERROR")
|
||||
print("The DNS query name does not exist.\n")
|
||||
return 1
|
||||
except dns.resolver.LifetimeTimeout:
|
||||
print("\nDNS ERROR")
|
||||
print("The DNS querry got timed out.\nVerify that your FW or PiHole isn't blocking requests for that domain.\n")
|
||||
return 1
|
||||
for i, something in enumerate(result):
|
||||
outDict[i] = something.to_text()
|
||||
# i += 1
|
||||
|
||||
Reference in New Issue
Block a user