diff --git a/dual/dual.go b/dual/dual.go index d75555b30..efaa461da 100644 --- a/dual/dual.go +++ b/dual/dual.go @@ -102,8 +102,6 @@ func New(ctx context.Context, h host.Host, options ...Option) (*DHT, error) { dht.QueryFilter(dht.PublicQueryFilter), dht.RoutingTableFilter(dht.PublicRoutingTableFilter), dht.RoutingTablePeerDiversityFilter(dht.NewRTPeerDiversityFilter(h, maxPrefixCountPerCpl, maxPrefixCount)), - // filter out all private addresses - dht.AddressFilter(func(addrs []ma.Multiaddr) []ma.Multiaddr { return ma.FilterAddrs(addrs, manet.IsPublicAddr) }), ), ) if err != nil { diff --git a/internal/config/config.go b/internal/config/config.go index 530de1014..47e10e984 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,6 +14,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/protocol" ma "github.com/multiformats/go-multiaddr" + manet "github.com/multiformats/go-multiaddr/net" ) // DefaultPrefix is the application specific prefix attached to all DHT protocols by default. @@ -128,6 +129,9 @@ var Defaults = func(o *Config) error { // MAGIC: It makes sense to set it to a multiple of OptProvReturnRatio * BucketSize. We chose a multiple of 4. o.OptimisticProvideJobsPoolSize = 60 + // filter out all private addresses by default + o.AddressFilter = func(addrs []ma.Multiaddr) []ma.Multiaddr { return ma.FilterAddrs(addrs, manet.IsPublicAddr) } + return nil }