InProgress Revamp of domainLookup

This commit is contained in:
2026-04-03 23:00:43 +02:00
parent 6a44a36698
commit 5c3f3a5daf
3 changed files with 94 additions and 16 deletions

View File

@@ -6,8 +6,8 @@ from whatDomain import *
# Debian # Debian
DEBMIRRORURL = str(os.getenv("DEBMIRRORURL", "https://www.debian.org/mirror/list")) DEBMIRRORURL = str(os.getenv("DEBMIRRORURL", "https://www.debian.org/mirror/list"))
DEBSECURITYURL = str(os.getenv("DEBSECURITYURL", "https://security.debian.org/debian-security/")) DEBSECURITYURL = str(os.getenv("DEBSECURITYURL", "https://security.debian.org/debian-security/"))
DEBIANMIRRORLISTV4 = "/etc/debmirror/DebianMirrorListV4" DEBIANMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/DebianMirrorListV4"
DEBIANMIRRORLISTV6 = "/etc/debmirror/DebianMirrorListV6" DEBIANMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/DebianMirrorListV6"
target_countries = set([ target_countries = set([
# Europe # Europe
@@ -26,29 +26,29 @@ target_countries = set([
# Proxmox # Proxmox
PROXURL = ["http://download.proxmox.com/debian/", "https://enterprise.proxmox.com/debian/pve/",] PROXURL = ["http://download.proxmox.com/debian/", "https://enterprise.proxmox.com/debian/pve/",]
PROXMOXMIRRORLISTV4 = "/etc/debmirror/ProxmoxMirrorListV4" PROXMOXMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV4"
PROXMOXMIRRORLISTV6 = "/etc/debmirror/ProxmoxMirrorListV6" PROXMOXMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV6"
# Docker # Docker
DOCKERURLS = ["https://download.docker.com/linux/debian/", DOCKERURLS = ["https://download.docker.com/linux/debian/",
"https://nvidia.github.io/libnvidia-container/stable/deb/", "https://nvidia.github.io/libnvidia-container/stable/deb/",
"https://nvidia.github.io/libnvidia-container/experimental/deb/"] "https://nvidia.github.io/libnvidia-container/experimental/deb/"]
DOCKERMIRRORLISTV4 = "/etc/debmirror/DockerMirrorListV4" DOCKERMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/DockerMirrorListV4"
DOCKERMIRRORLISTV6 = "/etc/debmirror/DockerMirrorListV6" DOCKERMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/DockerMirrorListV6"
# OPNsense # OPNsense
OPNSNSMIRRORURL = str(os.getenv("OPNSNSMIRRORURL", "https://opnsense.org/download/#full-mirror-listing")) OPNSNSMIRRORURL = str(os.getenv("OPNSNSMIRRORURL", "https://opnsense.org/download/#full-mirror-listing"))
OPNSENSEMIRRORLISTV4 = "/etc/debmirror/OPNsenseMirrorListV4" OPNSENSEMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV4"
OPNSENSEMIRRORLISTV6 = "/etc/debmirror/OPNsenseMirrorListV6" OPNSENSEMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV6"
# Custom # Custom
EXTRAURL = [] EXTRAURL = []
if os.getenv("EXTRA_REPOS", True): if os.getenv("EXTRA_REPOS", True):
try: try:
with open(os.getenv("REPOFILE", "customRepoList.list"), 'r') as repoListFile: with open(os.getenv("REPOFILE", "/etc/debmirror/customRepoList.list"), 'r') as repoListFile:
for repoUrl in repoListFile: for repoUrl in repoListFile:
# print(repoUrl.strip()) # print(repoUrl.strip())
EXTRAURL.append(repoUrl.strip()) EXTRAURL.append(repoUrl.strip())
@@ -56,8 +56,8 @@ if os.getenv("EXTRA_REPOS", True):
print("File not passed") print("File not passed")
exit(2) exit(2)
CUSTOMMIRRORLISTV4 = "/etc/debmirror/CustomMirrorListV4" CUSTOMMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/CustomMirrorListV4"
CUSTOMMIRRORLISTV6 = "/etc/debmirror/CustomMirrorListV6" CUSTOMMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/CustomMirrorListV6"
# Helper # Helper

View File

@@ -0,0 +1,77 @@
# https://dnspython.readthedocs.io/en/latest/
import subprocess
from typing import Optional, Annotated
# import dns, dns.resolver
class Momoid:
def __init__(
self,
resolverIPaddr: Annotated[int, "IP Address of a DNS server"] = "1.1.1.1",
DoH: Annotated[bool, "If DNS over HTTPS should be used"] = True
):
if DoH:
self.__MOMOID_CMD = ["dig", "+short", "+https", f"@{resolverIPaddr}"]
else:
self.__MOMOID_CMD = ["dig", "+short", f"@{resolverIPaddr}"]
def recordA(self, domain: Annotated[str, "Domain to resolve to a A record"]) -> list:
if not domain:
return 0
outpt = subprocess.run([*self.__MOMOID_CMD, domain, "A"], capture_output=True, text=True)
if outpt.stdout.strip() == "":
return 0
else:
outList = outpt.stdout.strip().split("\n")
return outList
def recordAAAA(self, domain: Annotated[str, "Domain to resolve to a AAAA record"]) -> list:
if not domain:
return 0
outpt = subprocess.run([*self.__MOMOID_CMD, domain, "AAAA"], capture_output=True, text=True)
if outpt.stdout.strip() == "":
return 0
else:
outList = outpt.stdout.strip().split("\n")
return outList
def recordPTR(self, domain: Annotated[str, "Domain to resolve to a PTR record"]) -> list:
# 1.2.3.4 -> 4.3.2.1.in-addr.arpa
if not domain:
return 0
outpt = subprocess.run([*self.__MOMOID_CMD, domain, "PTR"], capture_output=True, text=True)
if outpt.stdout.strip() == "":
return 0
else:
outList = outpt.stdout.strip().split("\n")
return outList
def __ipv4ToPTR(ipString: Annotated[str, "a string with an IPv4 address"]):
arpa = "in-addr.arpa"
ipList = ipa.split(".")
ipList.reverse()
outstr = ""
for thing in ipList:
outstr += thing
outstr += "."
return outstr + arpa
thing = Momoid("1.1.1.1", False)
x = thing.recordA("shupogaki.org")
print(x)

View File

@@ -4,7 +4,8 @@ import dns, dns.resolver
# https://www.codeunderscored.com/nslookup-python/ # https://www.codeunderscored.com/nslookup-python/
def ermWhatATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "Domain name to lookup IP for"]): def ermWhatATheIpFromDomainYaCrazy(
inpDomainNameOrSomething: Annotated[str, "Domain name to lookup IP for"]):
#dns_query = Nslookup() #dns_query = Nslookup()
""" """
Tells you what IPv4 address/es a domain point to. Tells you what IPv4 address/es a domain point to.
@@ -22,19 +23,19 @@ 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:
print("\nDNS ERROR") print("\nDNS ERROR")
print("No answer from dns server.\n") print(f"No answer from dns server when working on {inpDomainNameOrSomething}.\n")
return 1 return 1
except dns.resolver.NoNameservers: except dns.resolver.NoNameservers:
print("\nDNS ERROR") print("\nDNS ERROR")
print("All nameservers failed to answer the query.\n Fix your DNS servers.\n") print(f"All nameservers failed to answer the query when working on {inpDomainNameOrSomething}.\n Fix your DNS servers.\n")
return 1 return 1
except dns.resolver.NXDOMAIN: except dns.resolver.NXDOMAIN:
print("\nDNS ERROR") print("\nDNS ERROR")
print("The DNS query name does not exist.\n") print(f"The DNS query name does not exist for domain {inpDomainNameOrSomething}.\n")
return 1 return 1
except dns.resolver.LifetimeTimeout: except dns.resolver.LifetimeTimeout:
print("\nDNS ERROR") print("\nDNS ERROR")
print("The DNS querry got timed out.\nVerify that your FW or PiHole isn't blocking requests for that domain.\n") print(f"The DNS querry got timed out.\nVerify that your Firewall of DNS AdBlock isn't blocking requests for that domain.\nFailed resolving {inpDomainNameOrSomething}\n")
return 1 return 1
for i, something in enumerate(result): for i, something in enumerate(result):
outDict[i] = something.to_text() outDict[i] = something.to_text()