Some changes
This commit is contained in:
1 parent
23197e1dcc
commit
50bb5d7e72
6 files changed
+60
-7
No files matched your search
@@ -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
|
||||
+2
-1
@@ -1,2 +1,3 @@
|
||||
state.json
|
||||
config.json
|
||||
config.json
|
||||
login.sh
|
||||
+3
-1
@@ -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"]
|
||||
CMD ["python", "/app/main.py", "-v", "-c", "/data/config.json", "-s", "/data/state.json", "-w", "/app/web"]
|
||||
+13
@@ -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
|
||||
```
|
||||
+6
-2
@@ -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:
|
||||
|
||||
+8
-3
@@ -5,13 +5,13 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>DynDns Updater</title>
|
||||
<link rel="stylesheet" href="beer.min.css">
|
||||
<script src="beer.min.js" defer></script>
|
||||
<script type="module" src="beer.min.js" defer></script>
|
||||
<script src="alpine.min.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main x-data="data" class="responsive">
|
||||
<h1>DynDns Updater</h1>
|
||||
<h2>DynDns Updater</h2>
|
||||
<button class="small float-right" x-on:click="update">
|
||||
<i>refresh</i>
|
||||
<span>Update</span>
|
||||
@@ -114,12 +114,16 @@
|
||||
return `${Math.round(diff / 1000)} seconds ago`;
|
||||
} else if (diff < 3600000) {
|
||||
return `${Math.round(diff / 60000)} minutes ago`;
|
||||
} else if (diff < 86400000) {
|
||||
return `${Math.round(diff / 3600000)} hours ago`;
|
||||
} else if (diff < 604800000) {
|
||||
return `${Math.round(diff / 86400000)} days ago`;
|
||||
} else {
|
||||
return time.toISOString();
|
||||
}
|
||||
},
|
||||
async update() {
|
||||
const res = await fetch('http://localhost:8080/state');
|
||||
const res = await fetch('/state');
|
||||
const data = await res.json();
|
||||
this.addrs = data.addrs;
|
||||
this.lastUpdate = new Date(data.timestamp * 1000);
|
||||
@@ -148,6 +152,7 @@
|
||||
<style>
|
||||
main {
|
||||
overflow: unset;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.float-right {
|
||||
|
||||
Reference in new issue
Block a user