fix: changing file checking functionality
Some checks failed
forgejo/scripts/pipeline/head This commit looks good
/ desec-script (push) Has been cancelled

This commit is contained in:
devaine 2026-11-12 11:02:25 -06:00
commit 47afc79d53
Signed by: devaine
GPG key ID: 954B1DCAC6FF84EE
2 changed files with 14 additions and 12 deletions

View file

@ -1,4 +1,3 @@
mail._domainkey.mail
mail
_dmarc.mail
skyguy

View file

@ -39,12 +39,14 @@ def getSubDomains():
def filterRecords():
ignoredSubdomains = []
filteredSubdomains = []
ISEMPTY = False
if not os.path.exists("data/ignoredSubdomains"):
with open("data/ignoredSubdomains", "w") as file:
file.close()
if not os.path.isfile("./data/ignoredSubdomains"):
open(os.path.join("./data/", "ignoredSubdomains"), "w").close()
ISEMPTY = True
with open("data/ignoredSubdomains", "r") as ignoredSubdomainsFile:
if not ISEMPTY:
with open(os.path.join("./data/", "ignoredSubdomains"), "r") as ignoredSubdomainsFile:
for subdomain in ignoredSubdomainsFile:
ignoredSubdomains.append(subdomain)
@ -98,8 +100,9 @@ def changeRecords():
def checkIP():
if not os.path.exists("data"):
os.mkdir("data")
with open("data/currentIP", "w") as file:
file.close()
if not os.path.isfile("./data/currentIP"):
open(os.path.join("./data/", "currentIP"), "x").close()
# Request IP from website
global requestIP
@ -107,14 +110,14 @@ def checkIP():
requestIP = getRequestIP.text
# Grab file data and close for data safety.
currentIPFile = open("data/currentIP", "r")
currentIPFile = open(os.path.join("./data/", "currentIP"), "r")
currentIP = currentIPFile.readline().replace("\n", "")
currentIPFile.close()
# If both IP's are differnet (New external IP!)
if requestIP != currentIP:
changeRecords()
with open("data/currentIP", "w") as currentIPFile:
with open(os.path.join("./data/", "currentIP"), "w") as currentIPFile:
currentIPFile.write(requestIP)
currentIPFile.close()
print("All IP's Changed!")
@ -139,7 +142,7 @@ def checkInternet():
def appendSubdomain(args: list):
with open("data/ignoredSubdomains", "a") as ignoredSubdomainsFile:
with open(os.path.join("./data/", "ignoredSubdomains"), "a") as ignoredSubdomainsFile:
for subdomain in args:
ignoredSubdomainsFile.write(subdomain + "\n")
print("Added subdomain: " + subdomain)