diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml new file mode 100644 index 0000000..b43dc86 --- /dev/null +++ b/.gitea/workflows/docker.yaml @@ -0,0 +1,28 @@ +name: ci + +on: + push: + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Login to Docker Hub + uses: docker/login-action@v4 + with: + registry: git.dswd73.duckdns.org + username: ${{ vars.LOCAL_REPO_USER }} + password: ${{ secrets.LOCAL_REPO_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@v7 + with: + push: true + tags: git.dswd73.duckdns.org/dswd/dyndns-updater:latest \ No newline at end of file diff --git a/.gitignore b/.gitignore index d1f30f9..7c1a614 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ state.json -config.json \ No newline at end of file +config.json +login.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 0965144..012dfaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM python:alpine +RUN pip install requests + COPY src/main.py /app/main.py COPY web /app/web @@ -8,4 +10,4 @@ VOLUME /data EXPOSE 8080 -CMD ["python", "/app/main.py", "-c", "/data/config.json", "-s", "/data/state.json", "-w", "/app/web"] \ No newline at end of file +CMD ["python", "/app/main.py", "-v", "-c", "/data/config.json", "-s", "/data/state.json", "-w", "/app/web"] \ No newline at end of file diff --git a/maskfile.md b/maskfile.md new file mode 100644 index 0000000..27076bf --- /dev/null +++ b/maskfile.md @@ -0,0 +1,13 @@ +# Commands + +Needs [mask](https://github.com/jacobdeichert/mask) to run. + + +## publish + +> Publishes the docker image + +```sh +podman build -t git.dswd73.duckdns.org/dswd/dyndns-updater:latest . +podman push git.dswd73.duckdns.org/dswd/dyndns-updater:latest +``` diff --git a/src/main.py b/src/main.py index 27b82c5..200aa2a 100644 --- a/src/main.py +++ b/src/main.py @@ -1,3 +1,4 @@ +import mimetypes import socket import time from typing import Optional @@ -97,7 +98,6 @@ class Updater: def update_domain(self, domain: str, update_info: dict): modes = update_info.get("modes", [Mode.IPv4]) - update_required = False resolved_addrs = {} addrs = {m: self.addrs[m] for m in modes} for mode in modes: @@ -124,7 +124,7 @@ class Updater: response = requests.request(method, url, params=params, headers=headers, timeout=10) success = response.status_code == 200 response_text = response.text - log.info(f"Updated {domain}") + log.info(f"Updated {domain}, response: {response_text}") self.add_to_history(domain, self.addrs if success else resolved_addrs, success, response_text) def update_domains(self): @@ -166,7 +166,11 @@ class Handler(BaseHTTPRequestHandler): path = self.server.args.web + self.path try: data = open(path, 'rb').read() + mimetype = mimetypes.guess_type(path)[0] self.send_response(200) + if mimetype: + self.send_header("Content-Type", mimetype) + self.send_header('Content-Length', str(len(data))) self.end_headers() self.wfile.write(data) except: diff --git a/web/index.html b/web/index.html index 3a7ba45..b8f665e 100644 --- a/web/index.html +++ b/web/index.html @@ -5,13 +5,13 @@