Pull request: Fix review findings (CloudDNS errors, failure messages, hardening) #4
No reviewers
Labels
No labels
apps
bug
digest
duplicate
enhancement
help wanted
invalid
major
manual interaction
minor
patch
pin
question
renovate
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Homelab/goDynDNS!4
Loading…
Reference in a new issue
No description provided.
Delete branch "review-fixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Changes, one commit each
Only readable JSON with status "success" is a success. Anything else is a
911, and the address is not cached, so the next request retries.The message text now only decides between
goodandnochg. A wrongguess there changes the answer word, not the record.
away. While a host keeps failing, at most one message per hour. The first
success afterwards sends one "working again" message. Messages contain the
host, the requested address, a short error (max. 200 characters) and the
client, and never contain credentials. netcup credentials are only ever
sent in request bodies, so they cannot appear in error texts.
The start of a lockout is now logged once.
MIN_UPDATE_INTERVALmust be at least5s, and0is refused.NTFY_URLis now parsedat startup.
ALLOWED_NETSrecommendation,gen-tokenrequirement, plus the lockout behaviour, the interval minimumand the failure messages.
Assumption: netcup's CloudDNS answer format
The format of wsDynDns.php answers has not been verified against the real
service, and this setup uses the legacy API. The code therefore treats every
answer it does not recognise as a failure. If netcup ever answers success in
another form (for example a different status word), updates will fail with a
clear error, and a single test case covers the new form.
Lockout: why neither variant from the review
Both proposed variants have the same effect. One evaluates the lockout only
after the credential check, and the other lets a correct token lift the
lockout. Either way, a locked-out client's tokens are tested again, and the
answer differs between a right and a wrong guess. A guesser could then keep
trying during the lockout and would see when a guess is right, so the lockout
would no longer limit guessing. That would weaken it, which the review rules
out.
The cost of keeping it is small. A lockout needs 5 wrong tokens from an
address in
ALLOWED_CLIENTS. After fixing a wrong token in the router, wait15 minutes or restart dynrelay. The new log line shows when this happened, and
a test asserts that the right and a wrong token get identical answers while
locked out.
Verification
go vet ./... && go test -race ./...pass (Go 1.24.7, linux/amd64). New tests:TestCloudDNSAnswersTestCloudDNSErrorWith200IsNotCachedTestFailureNotificationsTestMinUpdateIntervalTestNtfyErrorsHideURLTestLockoutGivesNoOracleThe CloudDNS and ntfy tests fail against the previous code. The Docker build
(Go 1.27 image) runs the same tests.
Open question: TLS
The token still travels over plain HTTP on the LAN.
ALLOWED_CLIENTSandALLOWED_NETSlimit the damage, but TLS (or keeping the service on asegment nobody else can sniff) remains open and is not part of this PR.