Skip to content

Commit

Permalink
chore: upgrade go-libp2p-kad-dht
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Mar 27, 2024
1 parent 62eb143 commit fe340cb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions client/rpc/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (np NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdent
c.Experimental.FilestoreEnabled = true
n.WriteConfig(c)

n.Runner.Env["LAN_DHT_INCLUDE_LOOPBACK"] = "true"
n.StartDaemon("--enable-pubsub-experiment", "--offline="+strconv.FormatBool(!online))

if online {
Expand Down
10 changes: 8 additions & 2 deletions core/node/libp2p/routingopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,16 @@ func constructDHTRouting(mode dht.ModeOpt) RoutingOption {
if args.OptimisticProvideJobsPoolSize != 0 {
dhtOpts = append(dhtOpts, dht.OptimisticProvideJobsPoolSize(args.OptimisticProvideJobsPoolSize))
}
return dual.New(
args.Ctx, args.Host,
dualOptions := []dual.Option{
dual.DHTOption(dhtOpts...),
dual.WanDHTOption(dht.BootstrapPeers(args.BootstrapPeers...)),
}
if os.Getenv("LAN_DHT_INCLUDE_LOOPBACK") == "true" {
dualOptions = append(dualOptions, dual.LanDHTOption(dht.AddressFilter(nil)))
}
return dual.New(
args.Ctx, args.Host,
dualOptions...,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
github.com/libp2p/go-doh-resolver v0.4.0
github.com/libp2p/go-libp2p v0.33.0
github.com/libp2p/go-libp2p-http v0.5.0
github.com/libp2p/go-libp2p-kad-dht v0.24.4
github.com/libp2p/go-libp2p-kad-dht v0.25.2
github.com/libp2p/go-libp2p-kbucket v0.6.3
github.com/libp2p/go-libp2p-pubsub v0.10.0
github.com/libp2p/go-libp2p-pubsub-router v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ github.com/libp2p/go-libp2p-gostream v0.6.0 h1:QfAiWeQRce6pqnYfmIVWJFXNdDyfiR/qk
github.com/libp2p/go-libp2p-gostream v0.6.0/go.mod h1:Nywu0gYZwfj7Jc91PQvbGU8dIpqbQQkjWgDuOrFaRdA=
github.com/libp2p/go-libp2p-http v0.5.0 h1:+x0AbLaUuLBArHubbbNRTsgWz0RjNTy6DJLOxQ3/QBc=
github.com/libp2p/go-libp2p-http v0.5.0/go.mod h1:glh87nZ35XCQyFsdzZps6+F4HYI6DctVFY5u1fehwSg=
github.com/libp2p/go-libp2p-kad-dht v0.24.4 h1:ktNiJe7ffsJ1wX3ULpMCwXts99mPqGFSE/Qn1i8pErQ=
github.com/libp2p/go-libp2p-kad-dht v0.24.4/go.mod h1:ybWBJ5Fbvz9sSLkNtXt+2+bK0JB8+tRPvhBbRGHegRU=
github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ=
github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo=
github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio=
github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0=
github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0=
Expand Down
2 changes: 2 additions & 0 deletions test/cli/backup_bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
func TestBackupBootstrapPeers(t *testing.T) {
nodes := harness.NewT(t).NewNodes(3).Init()
nodes.ForEachPar(func(n *harness.Node) {
n.Runner.Env["LAN_DHT_INCLUDE_LOOPBACK"] = "true"

n.UpdateConfig(func(cfg *config.Config) {
cfg.Bootstrap = []string{}
cfg.Addresses.Swarm = []string{fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", harness.NewRandPort())}
Expand Down
3 changes: 3 additions & 0 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ ln -sf lib/sharness/lib-sharness .
exit 1
}

# Ensure that the local DHT in the tests contains loopback addresses.
export LAN_DHT_INCLUDE_LOOPBACK=true

# Please put go-ipfs specific shell functions below

###
Expand Down

0 comments on commit fe340cb

Please sign in to comment.