Some changes
This commit is contained in:
1 parent
aaa2167791
commit
302a7f57a4
2 files changed
+41
-11
No files matched your search
+3
-3
@@ -97,13 +97,14 @@ class Updater:
|
|||||||
def update_domain(self, domain: str, update_info: dict):
|
def update_domain(self, domain: str, update_info: dict):
|
||||||
modes = update_info.get("modes", [Mode.IPv4])
|
modes = update_info.get("modes", [Mode.IPv4])
|
||||||
update_required = False
|
update_required = False
|
||||||
|
resolved_addrs = {}
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
log.debug(f"Resolving {domain} ({mode})")
|
log.debug(f"Resolving {domain} ({mode})")
|
||||||
resolved = resolve(domain, mode)
|
resolved = resolve(domain, mode)
|
||||||
|
resolved_addrs[mode] = resolved
|
||||||
log.debug(f"Resolved to {resolved}")
|
log.debug(f"Resolved to {resolved}")
|
||||||
if resolved != self.addrs[mode]:
|
if resolved != self.addrs[mode]:
|
||||||
update_required = True
|
update_required = True
|
||||||
break
|
|
||||||
if not update_required:
|
if not update_required:
|
||||||
return
|
return
|
||||||
log.info(f"Updating {domain}")
|
log.info(f"Updating {domain}")
|
||||||
@@ -121,9 +122,8 @@ class Updater:
|
|||||||
response = requests.request(method, url, params=params, headers=headers, timeout=10)
|
response = requests.request(method, url, params=params, headers=headers, timeout=10)
|
||||||
success = response.status_code == 200
|
success = response.status_code == 200
|
||||||
response_text = response.text
|
response_text = response.text
|
||||||
print(response_text)
|
|
||||||
log.info(f"Updated {domain}")
|
log.info(f"Updated {domain}")
|
||||||
self.add_to_history(domain, self.addrs, success, response_text)
|
self.add_to_history(domain, self.addrs if success else resolved_addrs, success, response_text)
|
||||||
|
|
||||||
def update_domains(self):
|
def update_domains(self):
|
||||||
for domain, update_info in self.config["domains"].items():
|
for domain, update_info in self.config["domains"].items():
|
||||||
|
|||||||
+38
-8
@@ -12,6 +12,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<main x-data="data" class="responsive">
|
<main x-data="data" class="responsive">
|
||||||
<h1>DynDns Updater</h1>
|
<h1>DynDns Updater</h1>
|
||||||
|
<button class="small float-right" x-on:click="update">
|
||||||
|
<i>refresh</i>
|
||||||
|
<span>Update</span>
|
||||||
|
</button>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -28,11 +32,15 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<button class="small" x-on:click="update">Update</button>
|
|
||||||
<template x-for="domain in domains">
|
<template x-for="domain in domains">
|
||||||
<article>
|
<article>
|
||||||
<h6>
|
<h6>
|
||||||
<span x-text="domain.success ? '✅' : '❌'"></span>
|
<template x-if="domain.success">
|
||||||
|
<i class="success-text">check_circle</i>
|
||||||
|
</template>
|
||||||
|
<template x-else>
|
||||||
|
<i class="error-text">error</i>
|
||||||
|
</template>
|
||||||
<span x-text="domain.name"></span>
|
<span x-text="domain.name"></span>
|
||||||
</h6>
|
</h6>
|
||||||
<table>
|
<table>
|
||||||
@@ -54,20 +62,34 @@
|
|||||||
<details>
|
<details>
|
||||||
<summary>
|
<summary>
|
||||||
<button class="small">
|
<button class="small">
|
||||||
|
<i>history</i>
|
||||||
<span>History</span>
|
<span>History</span>
|
||||||
<i>expand_more</i>
|
<i>expand_more</i>
|
||||||
</button>
|
</button>
|
||||||
</summary>
|
</summary>
|
||||||
<ul class="list border">
|
<ul class="list border no-space">
|
||||||
<template x-for="update in domain.history">
|
<template x-for="update in domain.history">
|
||||||
<li>
|
<li>
|
||||||
<i>home</i>
|
<template x-if="update.success">
|
||||||
|
<i class="success-text">check_circle</i>
|
||||||
|
</template>
|
||||||
|
<template x-else>
|
||||||
|
<i class="error-text">error</i>
|
||||||
|
</template>
|
||||||
<div class="max">
|
<div class="max">
|
||||||
<h6 class="small" x-text="update.response_text"></h6>
|
<template x-if="update.success">
|
||||||
<div>
|
<div>
|
||||||
<button class="chip">IPv4</button><span x-text="update.addrs.ipv4"></span>
|
<div>
|
||||||
<button class="chip">IPv6</button><span x-text="update.addrs.ipv6"></span>
|
<b>IPv4:</b> <span class="small-text" x-text="update.addrs.ipv4"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<b>IPv6:</b> <span class="small-text" x-text="update.addrs.ipv6"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template x-else>
|
||||||
|
<p x-text="update.response_text"></p>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<label><span x-text="niceTime(update.timestamp)"></span></label>
|
<label><span x-text="niceTime(update.timestamp)"></span></label>
|
||||||
</li>
|
</li>
|
||||||
@@ -125,7 +147,15 @@
|
|||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
main {
|
main {
|
||||||
overflow: auto;
|
overflow: unset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.float-right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-text {
|
||||||
|
color: #006e1c
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in new issue
Block a user