Skip to content

feat(autonatv2): expose AllowPrivateAddrs via an Option#3513

Open
gmelodie wants to merge 1 commit into
libp2p:masterfrom
gmelodie:master
Open

feat(autonatv2): expose AllowPrivateAddrs via an Option#3513
gmelodie wants to merge 1 commit into
libp2p:masterfrom
gmelodie:master

Conversation

@gmelodie
Copy link
Copy Markdown

@gmelodie gmelodie commented May 28, 2026

Summary

Expose AutoNATv2's allowPrivateAddrs setting through the top-level libp2p
package so callers can opt in without patching the library.

Changes

  • p2p/protocol/autonatv2

    • Rename the private allowPrivateAddrs field/option to the exported
      AllowPrivateAddrs (commit e3a1d72d).
  • config, options.go

    • Add Config.AutoNATv2AllowPrivateAddrs.
    • Add a new libp2p.AutoNATv2AllowPrivateAddrs() option.
    • When used alongside EnableAutoNATv2(), the fx provider passes
      autonatv2.AllowPrivateAddrs to autonatv2.New
      (commit b85ffade).
  • libp2p_test.go

    • Add a smoke test verifying that:

      New(
          EnableAutoNATv2(),
          AutoNATv2AllowPrivateAddrs(),
      )

      successfully builds a host.

Motivation

nim-libp2p's AutoNATv2 interop tests currently maintain a patch against
go-libp2p to disable private-address filtering:

  • disable-filtering-of-private-ip-addresses.patch
    (interop/autonatv2/go-peer/...)

The setting already exists internally; this change simply exposes it through the
public API so the patch can be removed (see nim-libp2p#1699).

Notes

@gmelodie gmelodie marked this pull request as ready for review May 28, 2026 12:04
// autoNATSettings is used to configure AutoNAT
type autoNATSettings struct {
allowPrivateAddrs bool
AllowPrivateAddrs bool
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why does this field (and other similar fields across this diff) need to be public?

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.

3 participants