Skip to content

fix(autonatv2): honor forced reachability#3527

Open
pengqima wants to merge 1 commit into
libp2p:masterfrom
pengqima:fix-forced-reachability-autonatv2
Open

fix(autonatv2): honor forced reachability#3527
pengqima wants to merge 1 commit into
libp2p:masterfrom
pengqima:fix-forced-reachability-autonatv2

Conversation

@pengqima

Copy link
Copy Markdown

Summary

Make AutoNAT v2 honor the existing ForceReachabilityPublic and ForceReachabilityPrivate options.

This change:

  • adds an AutoNAT v2 WithReachability option;
  • passes the configured reachability override to AutoNAT v2;
  • returns the forced result without waiting for peers or performing dial-back checks;
  • keeps the AutoNAT v2 server active so the host can still serve requests from other peers;
  • adds unit and top-level regression coverage.

Fixes #3515.

Root cause

The top-level forced reachability value was only passed to AutoNAT v1.

When AutoNAT v2 was enabled, the basic host also used its per-address reachability tracker. That tracker never received the configured override, so addresses could remain unknown or be classified by automatic dial-back checks even though the host had explicitly been forced private or public.

Behavior after this change

When forced reachability is configured, AutoNAT v2 reports that fixed status for local address checks. AutoNAT v2 server functionality remains enabled for remote peers.

Existing behavior is unchanged when no reachability override is configured.

Testing

go test ./config ./p2p/host/basic ./p2p/protocol/autonatv2 . -count=1
go test -race . ./p2p/protocol/autonatv2 -run '^(TestAutoNATv2ForcedReachability|TestForcedReachability)$' -count=1
go vet ./config ./p2p/host/basic ./p2p/protocol/autonatv2 .

Signed-off-by: pengqima <pengqima@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ForceReachabilityPrivate does not work when EnableAutoNATv2 is enabled

1 participant