diff --git a/AiO_Container/code/main.py b/AiO_Container/code/main.py index 9b39279..33fdb11 100644 --- a/AiO_Container/code/main.py +++ b/AiO_Container/code/main.py @@ -6,8 +6,8 @@ from whatDomain import * # Debian DEBMIRRORURL = str(os.getenv("DEBMIRRORURL", "https://www.debian.org/mirror/list")) DEBSECURITYURL = str(os.getenv("DEBSECURITYURL", "https://security.debian.org/debian-security/")) -DEBIANMIRRORLISTV4 = "/etc/debmirror/DebianMirrorListV4" -DEBIANMIRRORLISTV6 = "/etc/debmirror/DebianMirrorListV6" +DEBIANMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/DebianMirrorListV4" +DEBIANMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/DebianMirrorListV6" target_countries = set([ # Europe @@ -26,29 +26,29 @@ target_countries = set([ # Proxmox PROXURL = ["http://download.proxmox.com/debian/", "https://enterprise.proxmox.com/debian/pve/",] -PROXMOXMIRRORLISTV4 = "/etc/debmirror/ProxmoxMirrorListV4" -PROXMOXMIRRORLISTV6 = "/etc/debmirror/ProxmoxMirrorListV6" +PROXMOXMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV4" +PROXMOXMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV6" # Docker DOCKERURLS = ["https://download.docker.com/linux/debian/", "https://nvidia.github.io/libnvidia-container/stable/deb/", "https://nvidia.github.io/libnvidia-container/experimental/deb/"] -DOCKERMIRRORLISTV4 = "/etc/debmirror/DockerMirrorListV4" -DOCKERMIRRORLISTV6 = "/etc/debmirror/DockerMirrorListV6" +DOCKERMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/DockerMirrorListV4" +DOCKERMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/DockerMirrorListV6" # OPNsense OPNSNSMIRRORURL = str(os.getenv("OPNSNSMIRRORURL", "https://opnsense.org/download/#full-mirror-listing")) -OPNSENSEMIRRORLISTV4 = "/etc/debmirror/OPNsenseMirrorListV4" -OPNSENSEMIRRORLISTV6 = "/etc/debmirror/OPNsenseMirrorListV6" +OPNSENSEMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV4" +OPNSENSEMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV6" # Custom EXTRAURL = [] if os.getenv("EXTRA_REPOS", True): 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: # print(repoUrl.strip()) EXTRAURL.append(repoUrl.strip()) @@ -56,8 +56,8 @@ if os.getenv("EXTRA_REPOS", True): print("File not passed") exit(2) -CUSTOMMIRRORLISTV4 = "/etc/debmirror/CustomMirrorListV4" -CUSTOMMIRRORLISTV6 = "/etc/debmirror/CustomMirrorListV6" +CUSTOMMIRRORLISTV4 = "/etc/debmirror/Repo-IP-lists/CustomMirrorListV4" +CUSTOMMIRRORLISTV6 = "/etc/debmirror/Repo-IP-lists/CustomMirrorListV6" # Helper diff --git a/AiO_Container/code/momoid.py b/AiO_Container/code/momoid.py new file mode 100644 index 0000000..e4c7c85 --- /dev/null +++ b/AiO_Container/code/momoid.py @@ -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) + + diff --git a/AiO_Container/code/whatDomain.py b/AiO_Container/code/whatDomain.py index 084d4b7..4a5506e 100644 --- a/AiO_Container/code/whatDomain.py +++ b/AiO_Container/code/whatDomain.py @@ -4,7 +4,8 @@ import dns, dns.resolver # 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() """ 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') except dns.resolver.NoAnswer: print("\nDNS ERROR") - print("No answer from dns server.\n") + print(f"No answer from dns server when working on {inpDomainNameOrSomething}.\n") return 1 except dns.resolver.NoNameservers: 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 except dns.resolver.NXDOMAIN: 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 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") + 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 for i, something in enumerate(result): outDict[i] = something.to_text()