Repository navigation
feat: make ServiceInfo TTL setters public - #556
Merged
keepsimple1 merged 6 commits intoNov 27, 2026
Merged
Conversation
keepsimple1
reviewed
Nov 23, 2026
keepsimple1
left a comment
Owner
There was a problem hiding this comment.
Thanks for your PR! Please see inline comment.
… seconds set_host_ttl and set_other_ttl refuse a TTL outside 10..=2^31-1 and leave the TTL unchanged: 0 would make the records goodbyes, a TTL of a few seconds means constant query traffic, and RFC 2181 section 8 caps a TTL at 2^31-1. The crate-private setters the tests use stay as they are.
PoHsuanLai
force-pushed
the
feat/public-ttl-setters
branch
from
November 25, 2026 10:40
e943cbc to
4d9b5e1
Compare
…setters - Make the TTL bounds public associated constants on ServiceInfo and link them from the set_host_ttl/set_other_ttl docs. - Remove the crate-private _set_host_ttl/_set_other_ttl, so every TTL goes through the range check. The daemon tests now use the public setters with ServiceInfo::MIN_TTL. - Point browsing apps to ServiceDaemon::verify() for faster detection of a vanished service.
keepsimple1
approved these changes
Nov 26, 2026
keepsimple1
left a comment
Owner
There was a problem hiding this comment.
LGTM, thanks! I've also made minor changes on top of it, mainly to export the MIN_TTL and MAX_TTL.
recv_timeout() restarts its timer on every event, and the browse sends SearchStarted at doubling intervals. With the 10 s TTL the 9 s wait kept being extended until a second PTR refresh had gone out, so the refresh counter was 2 instead of 1. Wait with recv_deadline() instead.
The second announcement, about 1 s after the first, restarts the TTL of the cached PTR, so the 80% refresh comes about 9.2 s after resolution: just after the 9 s deadline, which made the counter 0 on all platforms. The next refresh comes about 8 s after the first, so check at 12 s.
The browse's own PTR queries (1, 2, 4, 8, 16 s apart) get answered once the cached PTR is past half of its TTL, and each answer restarts the TTL and pushes the 80% refresh back. With a 10 s TTL that makes the refresh time depend on jitter, so no fixed check time works. Poll the metrics until both the PTR and SRV/TXT refreshes are seen, up to 3 TTLs, then check each was sent exactly once.
3 tasks
Owner
|
FYI, 0.22.1 is released and includes this fix. |
Contributor
Author
Thanks for the heads up and for getting the release out so quickly! Really appreciate the review and merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
ServiceInfo::set_host_ttlandServiceInfo::set_other_ttlpublic. Until now they were the crate-private_set_host_ttland_set_other_ttl, used only by tests. The defaults are unchanged.Why
Some protocols advertised over DNS-SD recommend a shorter TTL than the RFC 6762 defaults. For example, Network MIDI 2.0 (M2-124 §4.6) recommends a Host keep its TTL to one minute or less, so a Host that leaves without a goodbye drops out of browsers quickly. The getters are already public; this adds the matching setters.
Testing
The four tests that used the old names now call the public setters:
test_expired_srv,test_hostname_resolution_address_removed,test_refresh_ptrandtest_cache_only. All pass.