feat(autonat-v2): emit address reachability events#3490
Open
tabcat wants to merge 4 commits into
Open
Conversation
Adds address:verifying, address:reachable, address:unreachable, and address:removed events on the AutoNATv2 service, plus verifying, reachable, and unreachable getters exposing current state. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Member
Author
|
@srene any feedback here is greatly appreciated. |
Replaces coined verb forms (verdicted/unverdicted) that tripped CSpell
with standard English ("new" / "reachable").
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Description
Closes #3472.
Adds an event surface to
@libp2p/protocol-autonat-v2so applicationscan observe per-address reachability state as it changes.
The service now emits:
address:verifying { addr }— first-ever probe of this address has startedaddress:reachable { addr }— verdict reached or flipped to reachableaddress:unreachable { addr }— verdict reached or flipped to unreachableaddress:removed { addr }— an address that was being tracked is nolonger present in the AddressManager
Plus matching getters:
service.verifying: Multiaddr[]— addresses currently being probedfor the first time (no verdict yet)
service.reachable: Multiaddr[]— addresses currently REACHABLEservice.unreachable: Multiaddr[]— addresses currently UNREACHABLESubscribe via
libp2p.services.autoNATv2.addEventListener('address:reachable', evt => …).Notes & open questions
relay:created-reservationetc.), not the main libp2p event bus.address:verifyingfires only on the first probe of an address; TTLre-probes of a verdict'd address stay silent (the verdict persists,
only an actual flip emits a new event).
address:unreachableand
address:removedfire on different ticks —removeObservedAddrhard-deletes the observed entry, and the next reconcile pass detects
its absence. The events convey separate signals (verdict vs lifecycle),
so apps subscribe to whichever they care about.
(e.g. relay reservation drops, UPnP supersedes an observed entry,
transport listener stops). Only
address:removedfires in those cases.Change checklist