From fd65820f3539e8ee98df00067911e43d685f5f92 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 27 Mar 2024 15:18:44 +0100 Subject: [PATCH 1/6] chore: upgrade go-libp2p-kad-dht --- client/rpc/api_test.go | 1 + core/node/libp2p/routingopt.go | 10 ++++++++-- go.mod | 2 +- go.sum | 4 ++-- test/cli/backup_bootstrap_test.go | 2 ++ test/sharness/lib/test-lib.sh | 3 +++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/client/rpc/api_test.go b/client/rpc/api_test.go index 25bd26ceea6..3b8179c4bf4 100644 --- a/client/rpc/api_test.go +++ b/client/rpc/api_test.go @@ -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 { diff --git a/core/node/libp2p/routingopt.go b/core/node/libp2p/routingopt.go index a58a8c49885..2bd701835d0 100644 --- a/core/node/libp2p/routingopt.go +++ b/core/node/libp2p/routingopt.go @@ -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..., ) } } diff --git a/go.mod b/go.mod index 736901ae5a0..d02a8d8bcce 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index 17e57d5618c..dc33871f7dc 100644 --- a/go.sum +++ b/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= diff --git a/test/cli/backup_bootstrap_test.go b/test/cli/backup_bootstrap_test.go index 017499f3d63..464ebedab78 100644 --- a/test/cli/backup_bootstrap_test.go +++ b/test/cli/backup_bootstrap_test.go @@ -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())} diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 69fd2e66cf8..e9fae99d5a8 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -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 ### From 31388b58636ebec07d2f82154cad380abfdac3cd Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 2 Apr 2024 16:27:30 +0200 Subject: [PATCH 2/6] refactor to use config options --- client/rpc/api_test.go | 2 -- config/profile.go | 1 + config/routing.go | 3 +++ core/node/libp2p/host.go | 2 ++ core/node/libp2p/routingopt.go | 19 +++++++++++++------ docs/changelogs/v0.28.md | 5 +++++ docs/config.md | 19 +++++++++++++++++++ test/cli/backup_bootstrap_test.go | 2 -- test/cli/harness/node.go | 1 + test/sharness/lib/iptb-lib.sh | 4 ++++ test/sharness/lib/test-lib.sh | 3 --- .../t0131-multinode-client-routing.sh | 3 ++- test/sharness/t0142-testfilter.sh | 3 ++- test/sharness/t0181-private-network.sh | 1 + test/sharness/t0182-circuit-relay.sh | 3 ++- test/sharness/t0184-http-proxy-over-p2p.sh | 1 + test/sharness/t0276-cidv0v1.sh | 3 ++- 17 files changed, 58 insertions(+), 17 deletions(-) diff --git a/client/rpc/api_test.go b/client/rpc/api_test.go index 3b8179c4bf4..c0da3d7b04e 100644 --- a/client/rpc/api_test.go +++ b/client/rpc/api_test.go @@ -46,8 +46,6 @@ func (np NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdent c := n.ReadConfig() 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 { diff --git a/config/profile.go b/config/profile.go index 24bbe1533fa..700b58f162d 100644 --- a/config/profile.go +++ b/config/profile.go @@ -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 diff --git a/config/routing.go b/config/routing.go index f8941f84877..da142d8bc4d 100644 --- a/config/routing.go +++ b/config/routing.go @@ -21,6 +21,9 @@ type Routing struct { AcceleratedDHTClient Flag `json:",omitempty"` + LoopbackAddressesOnLanDHT bool + PrivateAddressesOnWanDHT bool + Routers Routers Methods Methods diff --git a/core/node/libp2p/host.go b/core/node/libp2p/host.go index afbd2080c07..4086fe4e62d 100644 --- a/core/node/libp2p/host.go +++ b/core/node/libp2p/host.go @@ -60,6 +60,8 @@ 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, + PrivateAddressesOnWanDHT: cfg.Routing.PrivateAddressesOnWanDHT, } opts = append(opts, libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) { args := routingOptArgs diff --git a/core/node/libp2p/routingopt.go b/core/node/libp2p/routingopt.go index 2bd701835d0..d81c267cfbd 100644 --- a/core/node/libp2p/routingopt.go +++ b/core/node/libp2p/routingopt.go @@ -26,6 +26,8 @@ type RoutingOptionArgs struct { BootstrapPeers []peer.AddrInfo OptimisticProvide bool OptimisticProvideJobsPoolSize int + LoopbackAddressesOnLanDHT bool + PrivateAddressesOnWanDHT bool } type RoutingOption func(args RoutingOptionArgs) (routing.Routing, error) @@ -116,16 +118,21 @@ func constructDHTRouting(mode dht.ModeOpt) RoutingOption { if args.OptimisticProvideJobsPoolSize != 0 { dhtOpts = append(dhtOpts, dht.OptimisticProvideJobsPoolSize(args.OptimisticProvideJobsPoolSize)) } - dualOptions := []dual.Option{ - dual.DHTOption(dhtOpts...), - dual.WanDHTOption(dht.BootstrapPeers(args.BootstrapPeers...)), + wanOptions := []dht.Option{ + dht.BootstrapPeers(args.BootstrapPeers...), + } + if args.PrivateAddressesOnWanDHT { + wanOptions = append(wanOptions, dht.AddressFilter(nil)) } - if os.Getenv("LAN_DHT_INCLUDE_LOOPBACK") == "true" { - dualOptions = append(dualOptions, dual.LanDHTOption(dht.AddressFilter(nil))) + lanOptions := []dht.Option{} + if args.LoopbackAddressesOnLanDHT { + lanOptions = append(lanOptions, dht.AddressFilter(nil)) } return dual.New( args.Ctx, args.Host, - dualOptions..., + dual.DHTOption(dhtOpts...), + dual.WanDHTOption(wanOptions...), + dual.LanDHTOption(lanOptions...), ) } } diff --git a/docs/changelogs/v0.28.md b/docs/changelogs/v0.28.md index 0d399c6ec13..892de6d619f 100644 --- a/docs/changelogs/v0.28.md +++ b/docs/changelogs/v0.28.md @@ -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,10 @@ 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. If, for some reason, you need this, we have added two new boolean options to the configuration: `Routing.LoopbackAddressesOnLanDHT` and `Routing.PrivateAddressesOnWanDHT`. + ### ๐Ÿ“ Changelog ### ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributors diff --git a/docs/config.md b/docs/config.md index d9addc7134a..e4143f63dcc 100644 --- a/docs/config.md +++ b/docs/config.md @@ -117,6 +117,8 @@ config file at runtime. - [`Routing`](#routing) - [`Routing.Type`](#routingtype) - [`Routing.AcceleratedDHTClient`](#routingaccelerateddhtclient) + - [`Routing.LoopbackAddressesOnLanDHT`](#routingloopbackaddressesonlandht) + - [`Routing.PrivateAddressesOnWanDHT`](#routingprivateaddressesonwandht) - [`Routing.Routers`](#routingrouters) - [`Routing.Routers: Type`](#routingrouters-type) - [`Routing.Routers: Parameters`](#routingrouters-parameters) @@ -1612,6 +1614,23 @@ Default: `false` Type: `flag` +### `Routing.LoopbackAddressesOnLanDHT` + +Whether loopback addresses (e.g. 127.0.0.1) should not be ignored on the local LAN DHT. +This can be useful if, for example, you run multiple Kubo nodes on the same machine. + +Default: `false` + +Type: `bool` (missing means `false`) + +### `Routing.PrivateAddressesOnWanDHT` + +Whether private addresses should not be ignored on the WAN DHT. + +Default: `false` + +Type: `bool` (missing means `false`) + ### `Routing.Routers` **EXPERIMENTAL: `Routing.Routers` configuration may change in future release** diff --git a/test/cli/backup_bootstrap_test.go b/test/cli/backup_bootstrap_test.go index 464ebedab78..017499f3d63 100644 --- a/test/cli/backup_bootstrap_test.go +++ b/test/cli/backup_bootstrap_test.go @@ -13,8 +13,6 @@ 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())} diff --git a/test/cli/harness/node.go b/test/cli/harness/node.go index d030c7c9404..18514c517e3 100644 --- a/test/cli/harness/node.go +++ b/test/cli/harness/node.go @@ -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 = true }) return n } diff --git a/test/sharness/lib/iptb-lib.sh b/test/sharness/lib/iptb-lib.sh index 3d2e95a4916..8b2d956c2e9 100644 --- a/test/sharness/lib/iptb-lib.sh +++ b/test/sharness/lib/iptb-lib.sh @@ -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[@]} diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index e9fae99d5a8..69fd2e66cf8 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -42,9 +42,6 @@ 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 ### diff --git a/test/sharness/t0131-multinode-client-routing.sh b/test/sharness/t0131-multinode-client-routing.sh index b62c9790b9c..8949a1bdfd8 100755 --- a/test/sharness/t0131-multinode-client-routing.sh +++ b/test/sharness/t0131-multinode-client-routing.sh @@ -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" ' diff --git a/test/sharness/t0142-testfilter.sh b/test/sharness/t0142-testfilter.sh index 971aa68397a..bdd7e4f76b1 100755 --- a/test/sharness/t0142-testfilter.sh +++ b/test/sharness/t0142-testfilter.sh @@ -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' ' diff --git a/test/sharness/t0181-private-network.sh b/test/sharness/t0181-private-network.sh index 86c6151d3e4..46dc45cdf3c 100755 --- a/test/sharness/t0181-private-network.sh +++ b/test/sharness/t0181-private-network.sh @@ -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"]'"'"' ' diff --git a/test/sharness/t0182-circuit-relay.sh b/test/sharness/t0182-circuit-relay.sh index d6e439ae318..c79edfc8ea8 100755 --- a/test/sharness/t0182-circuit-relay.sh +++ b/test/sharness/t0182-circuit-relay.sh @@ -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 diff --git a/test/sharness/t0184-http-proxy-over-p2p.sh b/test/sharness/t0184-http-proxy-over-p2p.sh index 9c5308277c2..98e2f3ab20c 100755 --- a/test/sharness/t0184-http-proxy-over-p2p.sh +++ b/test/sharness/t0184-http-proxy-over-p2p.sh @@ -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 && diff --git a/test/sharness/t0276-cidv0v1.sh b/test/sharness/t0276-cidv0v1.sh index 2058a9d5497..c810f45449d 100755 --- a/test/sharness/t0276-cidv0v1.sh +++ b/test/sharness/t0276-cidv0v1.sh @@ -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" ' From 34fbe89301a38fb967ad8e5d9e66f8e3ce9e057f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 2 Apr 2024 16:28:16 +0200 Subject: [PATCH 3/6] remove PrivateAddressesOnWanDHT --- config/routing.go | 1 - core/node/libp2p/host.go | 1 - core/node/libp2p/routingopt.go | 4 ---- docs/changelogs/v0.28.md | 2 +- docs/config.md | 9 --------- 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/config/routing.go b/config/routing.go index da142d8bc4d..403c3c0ffdc 100644 --- a/config/routing.go +++ b/config/routing.go @@ -22,7 +22,6 @@ type Routing struct { AcceleratedDHTClient Flag `json:",omitempty"` LoopbackAddressesOnLanDHT bool - PrivateAddressesOnWanDHT bool Routers Routers diff --git a/core/node/libp2p/host.go b/core/node/libp2p/host.go index 4086fe4e62d..8a275743276 100644 --- a/core/node/libp2p/host.go +++ b/core/node/libp2p/host.go @@ -61,7 +61,6 @@ func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (out P2PHo OptimisticProvide: cfg.Experimental.OptimisticProvide, OptimisticProvideJobsPoolSize: cfg.Experimental.OptimisticProvideJobsPoolSize, LoopbackAddressesOnLanDHT: cfg.Routing.LoopbackAddressesOnLanDHT, - PrivateAddressesOnWanDHT: cfg.Routing.PrivateAddressesOnWanDHT, } opts = append(opts, libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) { args := routingOptArgs diff --git a/core/node/libp2p/routingopt.go b/core/node/libp2p/routingopt.go index d81c267cfbd..869b7ef0652 100644 --- a/core/node/libp2p/routingopt.go +++ b/core/node/libp2p/routingopt.go @@ -27,7 +27,6 @@ type RoutingOptionArgs struct { OptimisticProvide bool OptimisticProvideJobsPoolSize int LoopbackAddressesOnLanDHT bool - PrivateAddressesOnWanDHT bool } type RoutingOption func(args RoutingOptionArgs) (routing.Routing, error) @@ -121,9 +120,6 @@ func constructDHTRouting(mode dht.ModeOpt) RoutingOption { wanOptions := []dht.Option{ dht.BootstrapPeers(args.BootstrapPeers...), } - if args.PrivateAddressesOnWanDHT { - wanOptions = append(wanOptions, dht.AddressFilter(nil)) - } lanOptions := []dht.Option{} if args.LoopbackAddressesOnLanDHT { lanOptions = append(lanOptions, dht.AddressFilter(nil)) diff --git a/docs/changelogs/v0.28.md b/docs/changelogs/v0.28.md index 892de6d619f..89a40416eab 100644 --- a/docs/changelogs/v0.28.md +++ b/docs/changelogs/v0.28.md @@ -31,7 +31,7 @@ The Object API commands deprecated back in [2021](https://github.com/ipfs/kubo/i ##### 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. If, for some reason, you need this, we have added two new boolean options to the configuration: `Routing.LoopbackAddressesOnLanDHT` and `Routing.PrivateAddressesOnWanDHT`. +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. ### ๐Ÿ“ Changelog diff --git a/docs/config.md b/docs/config.md index e4143f63dcc..3127726a36a 100644 --- a/docs/config.md +++ b/docs/config.md @@ -118,7 +118,6 @@ config file at runtime. - [`Routing.Type`](#routingtype) - [`Routing.AcceleratedDHTClient`](#routingaccelerateddhtclient) - [`Routing.LoopbackAddressesOnLanDHT`](#routingloopbackaddressesonlandht) - - [`Routing.PrivateAddressesOnWanDHT`](#routingprivateaddressesonwandht) - [`Routing.Routers`](#routingrouters) - [`Routing.Routers: Type`](#routingrouters-type) - [`Routing.Routers: Parameters`](#routingrouters-parameters) @@ -1623,14 +1622,6 @@ Default: `false` Type: `bool` (missing means `false`) -### `Routing.PrivateAddressesOnWanDHT` - -Whether private addresses should not be ignored on the WAN DHT. - -Default: `false` - -Type: `bool` (missing means `false`) - ### `Routing.Routers` **EXPERIMENTAL: `Routing.Routers` configuration may change in future release** From 90b0f7af66c2580bd5368a2a08dcf16139584cd6 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Apr 2024 17:05:41 +0200 Subject: [PATCH 4/6] config: make LoopbackAddressesOnLanDHT a Flag --- config/profile.go | 2 +- config/routing.go | 2 +- core/node/libp2p/host.go | 2 +- docs/changelogs/v0.28.md | 2 ++ test/cli/harness/node.go | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config/profile.go b/config/profile.go index 700b58f162d..068498715c5 100644 --- a/config/profile.go +++ b/config/profile.go @@ -82,7 +82,7 @@ is useful when using the daemon in test environments.`, } c.Swarm.DisableNatPortMap = true - c.Routing.LoopbackAddressesOnLanDHT = true + c.Routing.LoopbackAddressesOnLanDHT = True c.Bootstrap = []string{} c.Discovery.MDNS.Enabled = false diff --git a/config/routing.go b/config/routing.go index 403c3c0ffdc..eb5de5156ec 100644 --- a/config/routing.go +++ b/config/routing.go @@ -21,7 +21,7 @@ type Routing struct { AcceleratedDHTClient Flag `json:",omitempty"` - LoopbackAddressesOnLanDHT bool + LoopbackAddressesOnLanDHT Flag `json:",omitempty"` Routers Routers diff --git a/core/node/libp2p/host.go b/core/node/libp2p/host.go index 8a275743276..dd240a3706b 100644 --- a/core/node/libp2p/host.go +++ b/core/node/libp2p/host.go @@ -60,7 +60,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, + LoopbackAddressesOnLanDHT: cfg.Routing.LoopbackAddressesOnLanDHT.WithDefault(false), } opts = append(opts, libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) { args := routingOptArgs diff --git a/docs/changelogs/v0.28.md b/docs/changelogs/v0.28.md index 89a40416eab..7e5361eb570 100644 --- a/docs/changelogs/v0.28.md +++ b/docs/changelogs/v0.28.md @@ -33,6 +33,8 @@ The Object API commands deprecated back in [2021](https://github.com/ipfs/kubo/i 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 diff --git a/test/cli/harness/node.go b/test/cli/harness/node.go index 18514c517e3..ad8ac263bad 100644 --- a/test/cli/harness/node.go +++ b/test/cli/harness/node.go @@ -208,7 +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 = true + cfg.Routing.LoopbackAddressesOnLanDHT = config.True }) return n } From 324424f53b632e844412086a3b0de6c04ee82787 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Apr 2024 17:07:01 +0200 Subject: [PATCH 5/6] config: add DefaultLoopbackAddressesOnLanDHT --- config/routing.go | 3 ++- core/node/libp2p/host.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/routing.go b/config/routing.go index eb5de5156ec..231cbca732c 100644 --- a/config/routing.go +++ b/config/routing.go @@ -7,7 +7,8 @@ import ( ) var ( - DefaultAcceleratedDHTClient = false + DefaultAcceleratedDHTClient = false + DefaultLoopbackAddressesOnLanDHT = false ) // Routing defines configuration options for libp2p routing. diff --git a/core/node/libp2p/host.go b/core/node/libp2p/host.go index dd240a3706b..7950f3dc6bc 100644 --- a/core/node/libp2p/host.go +++ b/core/node/libp2p/host.go @@ -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,7 +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(false), + LoopbackAddressesOnLanDHT: cfg.Routing.LoopbackAddressesOnLanDHT.WithDefault(config.DefaultLoopbackAddressesOnLanDHT), } opts = append(opts, libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) { args := routingOptArgs From bc873c498f6d84d12a2b470d604b42cd8205471d Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 4 Apr 2024 14:45:12 +0200 Subject: [PATCH 6/6] docs(config): Routing.LoopbackAddressesOnLanDHT --- docs/config.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index 3127726a36a..ad308b18c5b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1615,8 +1615,11 @@ 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. -This can be useful if, for example, you run multiple Kubo nodes on the same machine. + +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`