mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-17 06:57:40 +08:00
chore: upgrade go-libp2p-kad-dht (#10378)
* chore: upgrade go-libp2p-kad-dht * config: make LoopbackAddressesOnLanDHT a Flag * config: add DefaultLoopbackAddressesOnLanDHT * docs(config): Routing.LoopbackAddressesOnLanDHT --------- Co-authored-by: Marcin Rataj <lidel@lidel.org>
This commit is contained in:
@ -46,7 +46,6 @@ func (np NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdent
|
||||
c := n.ReadConfig()
|
||||
c.Experimental.FilestoreEnabled = true
|
||||
n.WriteConfig(c)
|
||||
|
||||
n.StartDaemon("--enable-pubsub-experiment", "--offline="+strconv.FormatBool(!online))
|
||||
|
||||
if online {
|
||||
|
@ -82,6 +82,7 @@ is useful when using the daemon in test environments.`,
|
||||
}
|
||||
|
||||
c.Swarm.DisableNatPortMap = true
|
||||
c.Routing.LoopbackAddressesOnLanDHT = True
|
||||
|
||||
c.Bootstrap = []string{}
|
||||
c.Discovery.MDNS.Enabled = false
|
||||
|
@ -7,7 +7,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultAcceleratedDHTClient = false
|
||||
DefaultAcceleratedDHTClient = false
|
||||
DefaultLoopbackAddressesOnLanDHT = false
|
||||
)
|
||||
|
||||
// Routing defines configuration options for libp2p routing.
|
||||
@ -21,6 +22,8 @@ type Routing struct {
|
||||
|
||||
AcceleratedDHTClient Flag `json:",omitempty"`
|
||||
|
||||
LoopbackAddressesOnLanDHT Flag `json:",omitempty"`
|
||||
|
||||
Routers Routers
|
||||
|
||||
Methods Methods
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/libp2p/go-libp2p/core/routing"
|
||||
routedhost "github.com/libp2p/go-libp2p/p2p/host/routed"
|
||||
|
||||
"github.com/ipfs/kubo/config"
|
||||
"github.com/ipfs/kubo/core/node/helpers"
|
||||
"github.com/ipfs/kubo/repo"
|
||||
|
||||
@ -60,6 +61,7 @@ func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (out P2PHo
|
||||
BootstrapPeers: bootstrappers,
|
||||
OptimisticProvide: cfg.Experimental.OptimisticProvide,
|
||||
OptimisticProvideJobsPoolSize: cfg.Experimental.OptimisticProvideJobsPoolSize,
|
||||
LoopbackAddressesOnLanDHT: cfg.Routing.LoopbackAddressesOnLanDHT.WithDefault(config.DefaultLoopbackAddressesOnLanDHT),
|
||||
}
|
||||
opts = append(opts, libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) {
|
||||
args := routingOptArgs
|
||||
|
@ -26,6 +26,7 @@ type RoutingOptionArgs struct {
|
||||
BootstrapPeers []peer.AddrInfo
|
||||
OptimisticProvide bool
|
||||
OptimisticProvideJobsPoolSize int
|
||||
LoopbackAddressesOnLanDHT bool
|
||||
}
|
||||
|
||||
type RoutingOption func(args RoutingOptionArgs) (routing.Routing, error)
|
||||
@ -116,10 +117,18 @@ func constructDHTRouting(mode dht.ModeOpt) RoutingOption {
|
||||
if args.OptimisticProvideJobsPoolSize != 0 {
|
||||
dhtOpts = append(dhtOpts, dht.OptimisticProvideJobsPoolSize(args.OptimisticProvideJobsPoolSize))
|
||||
}
|
||||
wanOptions := []dht.Option{
|
||||
dht.BootstrapPeers(args.BootstrapPeers...),
|
||||
}
|
||||
lanOptions := []dht.Option{}
|
||||
if args.LoopbackAddressesOnLanDHT {
|
||||
lanOptions = append(lanOptions, dht.AddressFilter(nil))
|
||||
}
|
||||
return dual.New(
|
||||
args.Ctx, args.Host,
|
||||
dual.DHTOption(dhtOpts...),
|
||||
dual.WanDHTOption(dht.BootstrapPeers(args.BootstrapPeers...)),
|
||||
dual.WanDHTOption(wanOptions...),
|
||||
dual.LanDHTOption(lanOptions...),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
- [RPC client: removed deprecated DHT API](#rpc-client-removed-deprecated-dht-api)
|
||||
- [Gateway: `/api/v0` is removed](#gateway-apiv0-is-removed)
|
||||
- [Removed deprecated Object API commands](#removed-deprecated-object-api-commands)
|
||||
- [No longer publishes loopback and private addresses on DHT](#no-longer-publishes-loopback-and-private-addresses-on-dht)
|
||||
- [📝 Changelog](#-changelog)
|
||||
- [👨👩👧👦 Contributors](#-contributors)
|
||||
|
||||
@ -28,6 +29,12 @@ If you have a legacy software that relies on this behavior, and want to expose p
|
||||
|
||||
The Object API commands deprecated back in [2021](https://github.com/ipfs/kubo/issues/7936) have been removed, except for `object diff`, `object patch add-link` and `object patch rm-link`, whose alternatives have not yet been built (see issues [4801](https://github.com/ipfs/kubo/issues/4801) and [4782](https://github.com/ipfs/kubo/issues/4782)).
|
||||
|
||||
##### Kubo ignores loopback addresses on LAN DHT and private addresses on WAN DHT
|
||||
|
||||
Kubo no longer keeps track of loopback and private addresses on the LAN and WAN DHTs, respectively. This means that other nodes will not try to dial likely undialable addresses.
|
||||
|
||||
To support testing scenarios where multiple Kubo instances run on the same machine, [`Routing.LoopbackAddressesOnLanDHT`](https://github.com/ipfs/kubo/blob/master/docs/config.md#routingloopbackaddressesonlandht) is set to `true` when the `test` profile is applied.
|
||||
|
||||
### 📝 Changelog
|
||||
|
||||
### 👨👩👧👦 Contributors
|
||||
|
@ -117,6 +117,7 @@ config file at runtime.
|
||||
- [`Routing`](#routing)
|
||||
- [`Routing.Type`](#routingtype)
|
||||
- [`Routing.AcceleratedDHTClient`](#routingaccelerateddhtclient)
|
||||
- [`Routing.LoopbackAddressesOnLanDHT`](#routingloopbackaddressesonlandht)
|
||||
- [`Routing.Routers`](#routingrouters)
|
||||
- [`Routing.Routers: Type`](#routingrouters-type)
|
||||
- [`Routing.Routers: Parameters`](#routingrouters-parameters)
|
||||
@ -1612,6 +1613,18 @@ Default: `false`
|
||||
|
||||
Type: `flag`
|
||||
|
||||
### `Routing.LoopbackAddressesOnLanDHT`
|
||||
|
||||
**EXPERIMENTAL: `Routing.LoopbackAddressesOnLanDHT` configuration may change in future release**
|
||||
|
||||
Whether loopback addresses (e.g. 127.0.0.1) should not be ignored on the local LAN DHT.
|
||||
|
||||
Most users do not need this setting. It can be useful during testing, when multiple Kubo nodes run on the same machine but some of them do not have `Discovery.MDNS.Enabled`.
|
||||
|
||||
Default: `false`
|
||||
|
||||
Type: `bool` (missing means `false`)
|
||||
|
||||
### `Routing.Routers`
|
||||
|
||||
**EXPERIMENTAL: `Routing.Routers` configuration may change in future release**
|
||||
|
2
go.mod
2
go.mod
@ -49,7 +49,7 @@ require (
|
||||
github.com/libp2p/go-doh-resolver v0.4.0
|
||||
github.com/libp2p/go-libp2p v0.33.2
|
||||
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
|
||||
|
4
go.sum
4
go.sum
@ -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=
|
||||
|
@ -208,6 +208,7 @@ func (n *Node) Init(ipfsArgs ...string) *Node {
|
||||
cfg.Addresses.Gateway = []string{n.GatewayListenAddr.String()}
|
||||
cfg.Swarm.DisableNatPortMap = true
|
||||
cfg.Discovery.MDNS.Enabled = n.EnableMDNS
|
||||
cfg.Routing.LoopbackAddressesOnLanDHT = config.True
|
||||
})
|
||||
return n
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ startup_cluster() {
|
||||
other_args="$@"
|
||||
bound=$(expr "$num_nodes" - 1)
|
||||
|
||||
test_expect_success "set Routing.LoopbackAddressesOnLanDHT to true" '
|
||||
iptb run [0-$bound] -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true
|
||||
'
|
||||
|
||||
if test -n "$other_args"; then
|
||||
test_expect_success "start up nodes with additional args" "
|
||||
iptb start -wait [0-$bound] -- ${other_args[@]}
|
||||
|
@ -43,7 +43,8 @@ run_single_file_test() {
|
||||
NNODES=10
|
||||
|
||||
test_expect_success "set up testbed" '
|
||||
iptb testbed create -type localipfs -count $NNODES -force -init
|
||||
iptb testbed create -type localipfs -count $NNODES -force -init &&
|
||||
iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true
|
||||
'
|
||||
|
||||
test_expect_success "start up nodes" '
|
||||
|
@ -13,7 +13,8 @@ AF="/ip4/127.0.0.0/ipcidr/24"
|
||||
NUM_NODES=3
|
||||
|
||||
test_expect_success "set up testbed" '
|
||||
iptb testbed create -type localipfs -count $NUM_NODES -force -init
|
||||
iptb testbed create -type localipfs -count $NUM_NODES -force -init &&
|
||||
iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true
|
||||
'
|
||||
|
||||
test_expect_success 'filter 127.0.0.0/24 on node 1' '
|
||||
|
@ -35,6 +35,7 @@ LIBP2P_FORCE_PNET=1 test_launch_ipfs_daemon
|
||||
|
||||
test_expect_success "set up iptb testbed" '
|
||||
iptb testbed create -type localipfs -count 5 -force -init &&
|
||||
iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true &&
|
||||
iptb run -- ipfs config --json Addresses.Swarm '"'"'["/ip4/127.0.0.1/tcp/0"]'"'"'
|
||||
'
|
||||
|
||||
|
@ -7,7 +7,8 @@ test_description="Test circuit relay"
|
||||
# start iptb + wait for peering
|
||||
NUM_NODES=3
|
||||
test_expect_success 'init iptb' '
|
||||
iptb testbed create -type localipfs -count $NUM_NODES -init
|
||||
iptb testbed create -type localipfs -count $NUM_NODES -init &&
|
||||
iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true
|
||||
'
|
||||
|
||||
# Network toplogy: A <-> Relay <-> B
|
||||
|
@ -142,6 +142,7 @@ function curl_send_multipart_form_request() {
|
||||
|
||||
test_expect_success 'configure nodes' '
|
||||
iptb testbed create -type localipfs -count 2 -force -init &&
|
||||
iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true &&
|
||||
ipfsi 0 config --json Experimental.Libp2pStreamMounting true &&
|
||||
ipfsi 1 config --json Experimental.Libp2pStreamMounting true &&
|
||||
ipfsi 0 config --json Experimental.P2pHttpProxy true &&
|
||||
|
@ -95,7 +95,8 @@ test_expect_success "check that we can access the file when converted to CIDv1"
|
||||
#
|
||||
|
||||
test_expect_success "set up iptb testbed" '
|
||||
iptb testbed create -type localipfs -count 2 -init
|
||||
iptb testbed create -type localipfs -count 2 -init &&
|
||||
iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true
|
||||
'
|
||||
|
||||
test_expect_success "start nodes" '
|
||||
|
Reference in New Issue
Block a user