Skip to content

Commit

Permalink
moved public IP filter to default config
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumemichel committed May 23, 2023
1 parent e94c190 commit 2b961bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions dual/dual.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 2b961bb

Please sign in to comment.