feat!: complete refactoring of server #1

Merged
mxmehl merged 10 commits from v2 into master 2026-10-22 15:35:55 +02:00
2 changed files with 21 additions and 1 deletions
Showing only changes of commit ccfe8f37c9 - Show all commits

No files matched your search

+1 -1
View File
@@ -259,7 +259,7 @@ def handle(env, cfg, update=inwx_update, note=None):
update(cfg, zone, host, rtype, ip)
except NoHost as e:
# shortcut: missing records are not created, add nameserver.createRecord if wanted
note(f"{host}: nohost: {e}")
note(f"{host}: nohost: {e}, create it at INWX first")
return 404, "nohost"
except (InwxError, OSError, ValueError) as e:
note(f"{host}: 911: {rtype} update to {ip} failed: {e}")
+20
View File
@@ -449,6 +449,26 @@ token_sha256 = "{hashlib.sha256(TOKEN.encode()).hexdigest()}"
_, log = self.logged(server, **xff)
self.assertIn("1.2.3.4: 200 - home.example.com: good A unknown -> 1.2.3.4", log)
def test_log_names_the_missing_record(self):
server = self.start(client_ip_header="X-Forwarded-For")
# Only an A record exists, the device also reports IPv6
response, log = self.logged(
server, **{"X-Forwarded-For": "2606:4700:4700::1111"}
)
self.assertEqual(response[0], 404)
self.assertIn(
"2606:4700:4700::1111: 404 - home.example.com: nohost: "
"no AAAA record home.example.com in zone example.com, create it at INWX first",
log,
)
def test_log_reports_both_results_of_a_combined_request(self):
server = self.start()
query = f"/nic/update?hostname={HOST}&myip=1.2.3.4&myipv6=2606:4700:4700::1111"
_, log = self.logged(server, query)
self.assertIn("good A unknown -> 1.2.3.4; ", log)
self.assertIn("nohost: no AAAA record", log)
def test_nochg_is_not_logged(self):
server = self.start(client_ip_header="X-Forwarded-For")
xff = {"X-Forwarded-For": "1.2.3.4"}