Skip to content

fix(desec): only send dynDNS updates when the public IP changed - #9079

Merged
szaimen merged 7 commits into
mainfrom
desec-avoid-noop-updates
Nov 25, 2026
Merged

szaimen merged 7 commits into
mainfrom
desec-avoid-noop-updates

Conversation

@szaimen

@szaimen szaimen commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

deSEC's terms of use ask clients to only send update requests when there is something to update. Look up the current public addresses via deSEC's check-IP services and compare them to the addresses last sent (kept locally, since AIO's token is the only client changing these records), so no update is sent when nothing changed.

Also send myipv4/myipv6 explicitly, using 'preserve' for a family that is unchanged or could not be determined, so a manually added record of the other address family is no longer deleted. Add a random 10-60s delay to the updater loop to spread out requests.

Summary

  • The PR was tested and verified that it works locally
  • Or will be tested after merge on a dedicated test instance (available for maintainers)
  • Sign-off message is added to all commits
  • Tests (playwright if possible) are included
  • Screenshots before/after for front-end changes
  • Documentation has been updated or is not required
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature component)
  • Milestone next added

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@szaimen szaimen added this to the next milestone Nov 19, 2026
@szaimen szaimen added 3. to review Waiting for reviews enhancement New feature or request labels Nov 19, 2026
@szaimen szaimen modified the milestones: v15.1.1, next Nov 19, 2026
@peterthomassen

peterthomassen commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Looks good. Nits:

  • Stale AAAA: an AAAA that AIO itself published is never removed if the host later loses IPv6, since "could not determine" causes the IPv6 parameter to be set to preserve. preserve is really only needed when the IPv4 and IPv6 records are set in different updates. But they can be simultaneously, in which case I guess you don't need preserve, because an IP address that cannot be determined / has no connectivity should probably be removed (so then you would send an empty parameter).
  • Re-registration: register() does not clear the stored state. If a domain is deleted at deSEC and re-created under the same name, the config survives and no update is sent until the IP changes. Clearing the state on registration would fix it.

Also, I noticed that an invalid token or deleted domain is retried every 10 minutes indefinitely. It's unrelated to #8997, but maybe you have an idea how it could be addressed as well.

@szaimen

szaimen commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks for the review!

Looks good. Nits:

  • Stale AAAA: an AAAA that AIO itself published is never removed if the host later loses IPv6, since "could not determine" causes the IPv6 parameter to be set to preserve. preserve is really only needed when the IPv4 and IPv6 records are set in different updates. But they can be simultaneously, in which case I guess you don't need preserve, because an IP address that cannot be determined / has no connectivity should probably be removed (so then you would send an empty parameter).
  • Re-registration: register() does not clear the stored state. If a domain is deleted at deSEC and re-created under the same name, the config survives and no update is sent until the IP changes. Clearing the state on registration would fix it.

Thanks! Should be addressed by the latest commit. Please have another look :)

Also, I noticed that an invalid token or deleted domain is retried every 10 minutes indefinitely. It's unrelated to #8997, but maybe you have an idea how it could be addressed as well.

I moved this to an issue for now so that we dont forget and address this going forward: #9097

@szaimen
szaimen requested a review from pabzm November 23, 2026 11:27
@szaimen
szaimen marked this pull request as ready for review November 23, 2026 11:27
@szaimen szaimen mentioned this pull request Nov 23, 2026
6 of 9 tasks
@szaimen
szaimen force-pushed the desec-avoid-noop-updates branch from 6657da1 to 26a013d Compare November 24, 2026 11:09
@szaimen

szaimen commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

rebased and fixed conflicts

Comment thread php/src/Data/ConfigurationManager.php Resolved
@szaimen

szaimen commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@pabzm should be fixed now! Please check again! :)

@szaimen

szaimen commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Playwright failure is unrelated

@pabzm pabzm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the adaptions! I have two suggestions for how to make the code much less verbose and also more comprehensible.

Comment thread php/src/Desec/DesecManager.php Resolved
Comment thread php/src/Desec/DesecManager.php Outdated
Comment on lines +686 to +693
$packed = inet_pton($ip);
if ($packed === false) {
return $ip;
}

$normalized = inet_ntop($packed);

return $normalized === false ? $ip : $normalized;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be reduced to

Suggested change
$packed = inet_pton($ip);
if ($packed === false) {
return $ip;
}
$normalized = inet_ntop($packed);
return $normalized === false ? $ip : $normalized;
return inet_ntop(inet_pton($ip) ?: '');

And since it's then a oneliner method, that is called only from one other line of code, it could be inlined there.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjusted in 80c8218. please check again!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really dislike that new code, it is not comprehensible and not well structured in my eyes. But I'm tired of arguing against such AI code, so I'll stop here.

From a functional point of view it probably does what it should, I guess.

szaimen and others added 7 commits November 25, 2026 10:09
deSEC's terms of use ask clients to only send update requests when there
is something to update. Look up the current public addresses via deSEC's
check-IP services and compare them to the addresses last sent (kept
locally, since AIO's token is the only client changing these records), so
no update is sent when nothing changed.

Also send myipv4/myipv6 explicitly, using 'preserve' for a family that is
unchanged or could not be determined, so a manually added record of the
other address family is no longer deleted. Add a random 10-60s delay to
the updater loop to spread out requests.

See #8997

Signed-off-by: Simon L. <szaimen@e.mail.de>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Send both address families together whenever an update is needed. A
family whose address can no longer be determined is now sent empty, so a
record that AIO itself published earlier is removed (e.g. when the host
lost IPv6). 'preserve' is only used for a family AIO never published, so
manually added records are still kept.

Clear the remembered addresses on registration, so a domain that was
deleted at deSEC and re-created under the same name gets its records
again right away instead of only once the IP changes.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Container start times are not synchronised across instances, so the delay
did not spread out requests to deSEC in practice.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Simon L. <szaimen@e.mail.de>
The addresses stored locally miss changes made to the records outside of
AIO, which would then never be corrected. Querying deSEC's authoritative
nameservers directly compares against the real records and is not affected
by caching or split-brain DNS of the local resolver. Locally, only which
address families AIO published is kept, so that a manually added record
is never removed.

The test mock answers DNS queries itself, so tests never query deSEC.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Simon L. <szaimen@e.mail.de>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Simon L. <szaimen@e.mail.de>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Simon L. <szaimen@e.mail.de>
Both the check-IP and the DNS lookup validated addresses and then
normalised them separately; one helper keeps that logic in one place.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Simon L. <szaimen@e.mail.de>
@szaimen
szaimen force-pushed the desec-avoid-noop-updates branch from 80c8218 to 5985801 Compare November 25, 2026 09:09
@szaimen

szaimen commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Just rebased to hopefully fix the playwright test

@pabzm pabzm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good code, but I guess it does what it's supposed to do.

@szaimen
szaimen merged commit a13b5ef into main Nov 25, 2026
9 checks passed
@szaimen
szaimen deleted the desec-avoid-noop-updates branch November 25, 2026 14:53
@szaimen

szaimen commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

This is now released with v15.2.0 Beta. Testing and feedback is welcome! See https://github.com/nextcloud/all-in-one#how-to-switch-the-channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants