feat: updated checks for files
All checks were successful
forgejo/scripts/pipeline/head This commit looks good
All checks were successful
forgejo/scripts/pipeline/head This commit looks good
This commit is contained in:
parent
006b9d2c03
commit
5494b7e273
2 changed files with 18 additions and 51 deletions
|
|
@ -1,41 +0,0 @@
|
||||||
on: [push]
|
|
||||||
jobs:
|
|
||||||
desec-script:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: node:latest
|
|
||||||
steps:
|
|
||||||
- run: |
|
|
||||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
|
||||||
sh get-docker.sh
|
|
||||||
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Login to Forgejo Container Registry
|
|
||||||
uses: docker/login-action@v4
|
|
||||||
with:
|
|
||||||
registry: git.devdoes.work
|
|
||||||
username: devaine
|
|
||||||
password: ${{ secrets.USER_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v4
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: git.devdoes.work/devaine/scripts:desec
|
|
||||||
file: server-scripts/desec-ip-sync/Dockerfile
|
|
||||||
|
|
||||||
|
|
||||||
#- run: |
|
|
||||||
# ls -la
|
|
||||||
# echo "test"
|
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ import argparse
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import requests
|
import requests
|
||||||
import json
|
from collections import Counter
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
|
@ -36,7 +36,16 @@ def getSubDomains():
|
||||||
return subDomainsJSON
|
return subDomainsJSON
|
||||||
|
|
||||||
|
|
||||||
# TODO: Make a file out of the subdomains you'd want ignored
|
def getCurrentIP():
|
||||||
|
rrsetList = []
|
||||||
|
for rrset in getSubDomains():
|
||||||
|
rrsetList.append(rrset["records"][0])
|
||||||
|
|
||||||
|
value, count = Counter(rrsetList).most_common(1)[0]
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
def filterRecords():
|
def filterRecords():
|
||||||
ignoredSubdomains = []
|
ignoredSubdomains = []
|
||||||
filteredSubdomains = []
|
filteredSubdomains = []
|
||||||
|
|
@ -52,10 +61,9 @@ def filterRecords():
|
||||||
ignoredSubdomains.append(subdomain)
|
ignoredSubdomains.append(subdomain)
|
||||||
|
|
||||||
for rrset in getSubDomains():
|
for rrset in getSubDomains():
|
||||||
rrset_loaded = json.loads(rrset)
|
IS_NOT_IGNORED = rrset["name"] not in ignoredSubdomains
|
||||||
IS_NOT_IGNORED = rrset_loaded["name"] not in ignoredSubdomains
|
CONTAINS_A_RECORD = rrset["type"] == "A"
|
||||||
CONTAINS_A_RECORD = rrset_loaded["type"] == "A"
|
NOT_CURRENT_IP = rrset["records"][0] != requestIP
|
||||||
NOT_CURRENT_IP = rrset_loaded["records"][0] != requestIP
|
|
||||||
|
|
||||||
if IS_NOT_IGNORED and CONTAINS_A_RECORD and NOT_CURRENT_IP:
|
if IS_NOT_IGNORED and CONTAINS_A_RECORD and NOT_CURRENT_IP:
|
||||||
filteredSubdomains.append(rrset["subname"])
|
filteredSubdomains.append(rrset["subname"])
|
||||||
|
|
@ -100,11 +108,11 @@ def changeRecords():
|
||||||
|
|
||||||
|
|
||||||
def checkIP():
|
def checkIP():
|
||||||
if not os.path.exists("data"):
|
# Grab the current IP from the desec API
|
||||||
os.mkdir("data")
|
|
||||||
|
|
||||||
if not os.path.isfile("./data/currentIP"):
|
if not os.path.isfile("./data/currentIP"):
|
||||||
open(os.path.join("./data/", "currentIP"), "x").close()
|
with open(os.path.join("./data/", "currentIP"), "w") as currentIPFile:
|
||||||
|
currentIPFile.write(getCurrentIP())
|
||||||
|
currentIPFile.close()
|
||||||
|
|
||||||
# Request IP from website
|
# Request IP from website
|
||||||
global requestIP
|
global requestIP
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue