diff --git a/components/services/ipfs/ipfs_service_impl.cc b/components/services/ipfs/ipfs_service_impl.cc index 42859798930e..a5a40a5a2020 100644 --- a/components/services/ipfs/ipfs_service_impl.cc +++ b/components/services/ipfs/ipfs_service_impl.cc @@ -164,7 +164,6 @@ void IpfsServiceImpl::Launch(mojom::IpfsConfigPtr config, args.AppendArg("daemon"); args.AppendArg("--migrate=true"); args.AppendArg("--enable-gc"); - args.AppendArg("--routing=dhtclient"); auto version = ipfs::GetVersionFromNodeFilename( config->binary_path.BaseName().MaybeAsASCII()); diff --git a/components/services/ipfs/ipfs_service_utils.cc b/components/services/ipfs/ipfs_service_utils.cc index dbc064bb433a..b3342d0d2207 100644 --- a/components/services/ipfs/ipfs_service_utils.cc +++ b/components/services/ipfs/ipfs_service_utils.cc @@ -49,9 +49,6 @@ bool UpdateConfigJSON(const std::string& source, "Addresses.Gateway", base::StrCat({"/ip4/127.0.0.1/tcp/", config->gateway_port})); dict->SetByDottedPath("Datastore.GCPeriod", "1h"); - dict->SetByDottedPath("Swarm.ConnMgr.GracePeriod", "20s"); - dict->SetByDottedPath("Swarm.ConnMgr.LowWater", 20); - dict->SetByDottedPath("Swarm.ConnMgr.HighWater", 40); dict->SetByDottedPath("Datastore.StorageMax", config->storage_max); base::Value::Dict localhost_gateway_settings; @@ -79,8 +76,19 @@ bool UpdateConfigJSON(const std::string& source, base::Value::List list; list.Append(base::StrCat({"/ip4/0.0.0.0/tcp/", config->swarm_port})); + list.Append(base::ReplaceStringPlaceholders( + "/ip4/0.0.0.0/udp/$1/quic-v1/webtransport", {config->swarm_port}, + nullptr)); + list.Append(base::ReplaceStringPlaceholders("/ip4/0.0.0.0/udp/$1/quic-v1", + {config->swarm_port}, nullptr)); + list.Append(base::ReplaceStringPlaceholders("/ip6/::/udp/$1/quic-v1", + {config->swarm_port}, nullptr)); + list.Append(base::ReplaceStringPlaceholders( + "/ip6/::/udp/$1/quic-v1/webtransport", {config->swarm_port}, nullptr)); list.Append(base::StrCat({"/ip6/::/tcp/", config->swarm_port})); + dict->SetByDottedPath("Addresses.Swarm", std::move(list)); + dict->RemoveByDottedPath("Swarm.ConnMgr"); std::string json_string; if (!base::JSONWriter::Write(records_v.value(), &json_string) || diff --git a/components/services/ipfs/ipfs_service_utils_unittest.cc b/components/services/ipfs/ipfs_service_utils_unittest.cc index eada76e42bce..65ab0e186d91 100644 --- a/components/services/ipfs/ipfs_service_utils_unittest.cc +++ b/components/services/ipfs/ipfs_service_utils_unittest.cc @@ -26,14 +26,16 @@ TEST_F(IPFSServiceUtils, UpdateConfigJSONTest) { std::string expect = "{\"Addresses\":{\"API\":\"/ip4/127.0.0.1/tcp/APIPort\"," - "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\",\"Swarm\":" - "[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip6/::/tcp/SwarmPort\"" - "]},\"Datastore\":{\"GCPeriod\":\"1h\",\"StorageMax\":" + "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\"," + "\"Swarm\":[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip4/0.0.0.0/udp/SwarmPort/" + "quic-v1/webtransport\"," + "\"/ip4/0.0.0.0/udp/SwarmPort/quic-v1\",\"/ip6/::/udp/SwarmPort/" + "quic-v1\",\"/ip6/::/udp/SwarmPort/quic-v1/webtransport\",\"/ip6/::/tcp/" + "SwarmPort\"]}," + "\"Datastore\":{\"GCPeriod\":\"1h\",\"StorageMax\":" "\"StorageSize\"}," "\"Gateway\":{\"PublicGateways\":{\"localhost\":{\"InlineDNSLink\":true," - "\"Paths\":[\"/ipfs\",\"/ipns\",\"/api\"],\"UseSubdomains\":true}}}," - "\"Swarm\":{\"ConnMgr\":{\"GracePeriod\":\"20s\"," - "\"HighWater\":40,\"LowWater\":20}}}"; + "\"Paths\":[\"/ipfs\",\"/ipns\",\"/api\"],\"UseSubdomains\":true}}}}"; ASSERT_TRUE(UpdateConfigJSON(json, config.get(), &updated)); EXPECT_EQ(updated, expect); updated.clear(); @@ -80,17 +82,19 @@ TEST_F(IPFSServiceUtils, DNSResolversRemove) { std::string expect = "{\"Addresses\":{\"API\":\"/ip4/127.0.0.1/tcp/APIPort\"," - "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\",\"Swarm\":" - "[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip6/::/tcp/SwarmPort\"" - "]},\"DNS\":{\"Resolvers\":{\".\":\"https://cloudflare.com/" + "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\"," + "\"Swarm\":[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip4/0.0.0.0/udp/" + "SwarmPort/quic-v1/webtransport\"," + "\"/ip4/0.0.0.0/udp/SwarmPort/quic-v1\",\"/ip6/::/udp/SwarmPort/" + "quic-v1\",\"/ip6/::/udp/SwarmPort/quic-v1/webtransport\",\"/ip6/::/" + "tcp/SwarmPort\"]}," + "\"DNS\":{\"Resolvers\":{\".\":\"https://cloudflare.com/" "dns-query\"}}," "\"Datastore\":{\"GCPeriod\":\"1h\",\"StorageMax\":" "\"StorageSize\"}," "\"Gateway\":{\"PublicGateways\":{\"localhost\":{\"InlineDNSLink\":" "true,\"Paths\":[\"/ipfs\",\"/ipns\",\"/" - "api\"],\"UseSubdomains\":true}}}," - "\"Swarm\":{\"ConnMgr\":{\"GracePeriod\":\"20s\"," - "\"HighWater\":40,\"LowWater\":20}}}"; + "api\"],\"UseSubdomains\":true}}}}"; EXPECT_TRUE(UpdateConfigJSON(json, config.get(), &updated)); EXPECT_EQ(updated, expect); @@ -104,15 +108,16 @@ TEST_F(IPFSServiceUtils, DNSResolversRemove) { std::string expect = "{\"Addresses\":{\"API\":\"/ip4/127.0.0.1/tcp/APIPort\"," - "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\",\"Swarm\":" - "[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip6/::/tcp/SwarmPort\"" - "]}," + "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\"," + "\"Swarm\":[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip4/0.0.0.0/udp/SwarmPort/" + "quic-v1/webtransport\"," + "\"/ip4/0.0.0.0/udp/SwarmPort/quic-v1\",\"/ip6/::/udp/SwarmPort/" + "quic-v1\",\"/ip6/::/udp/SwarmPort/quic-v1/webtransport\",\"/ip6/::/tcp/" + "SwarmPort\"]}," "\"Datastore\":{\"GCPeriod\":\"1h\",\"StorageMax\":" "\"StorageSize\"},\"Gateway\":{\"PublicGateways\":{\"localhost\":{" "\"InlineDNSLink\":true,\"Paths\":[\"/ipfs\",\"/ipns\",\"/" - "api\"],\"UseSubdomains\":true}}}," - "\"Swarm\":{\"ConnMgr\":{\"GracePeriod\":\"20s\"," - "\"HighWater\":40,\"LowWater\":20}}}"; + "api\"],\"UseSubdomains\":true}}}}"; EXPECT_TRUE(UpdateConfigJSON(json, config.get(), &updated)); ASSERT_EQ(updated, expect); @@ -128,15 +133,17 @@ TEST_F(IPFSServiceUtils, DNSResolversUpdate) { std::string expect = "{\"Addresses\":{\"API\":\"/ip4/127.0.0.1/tcp/APIPort\"," - "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\",\"Swarm\":" - "[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip6/::/tcp/SwarmPort\"" - "]},\"DNS\":{\"Resolvers\":{\".\":\"https://cloudflare.com/dns-query\"}}," + "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\"," + "\"Swarm\":[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip4/0.0.0.0/udp/SwarmPort/" + "quic-v1/webtransport\"," + "\"/ip4/0.0.0.0/udp/SwarmPort/quic-v1\",\"/ip6/::/udp/SwarmPort/" + "quic-v1\",\"/ip6/::/udp/SwarmPort/quic-v1/webtransport\",\"/ip6/::/tcp/" + "SwarmPort\"]}," + "\"DNS\":{\"Resolvers\":{\".\":\"https://cloudflare.com/dns-query\"}}," "\"Datastore\":{\"GCPeriod\":\"1h\",\"StorageMax\":" "\"StorageSize\"},\"Gateway\":{\"PublicGateways\":{\"localhost\":{" "\"InlineDNSLink\":true,\"Paths\":[\"/ipfs\",\"/ipns\",\"/" - "api\"],\"UseSubdomains\":true}}}," - "\"Swarm\":{\"ConnMgr\":{\"GracePeriod\":\"20s\"," - "\"HighWater\":40,\"LowWater\":20}}}"; + "api\"],\"UseSubdomains\":true}}}}"; ASSERT_TRUE(UpdateConfigJSON(json, config.get(), &updated)); EXPECT_EQ(updated, expect); } @@ -151,15 +158,17 @@ TEST_F(IPFSServiceUtils, DNSResolversUpdate_DnsHasRFC8484Template) { std::string expect = "{\"Addresses\":{\"API\":\"/ip4/127.0.0.1/tcp/APIPort\"," - "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\",\"Swarm\":" - "[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip6/::/tcp/SwarmPort\"" - "]},\"DNS\":{\"Resolvers\":{\".\":\"https://cloudflare.com/dns-query\"}}," + "\"Gateway\":\"/ip4/127.0.0.1/tcp/GatewayPort\"," + "\"Swarm\":[\"/ip4/0.0.0.0/tcp/SwarmPort\",\"/ip4/0.0.0.0/udp/SwarmPort/" + "quic-v1/webtransport\"," + "\"/ip4/0.0.0.0/udp/SwarmPort/quic-v1\",\"/ip6/::/udp/SwarmPort/" + "quic-v1\",\"/ip6/::/udp/SwarmPort/quic-v1/webtransport\",\"/ip6/::/tcp/" + "SwarmPort\"]}," + "\"DNS\":{\"Resolvers\":{\".\":\"https://cloudflare.com/dns-query\"}}," "\"Datastore\":{\"GCPeriod\":\"1h\",\"StorageMax\":" "\"StorageSize\"}," "\"Gateway\":{\"PublicGateways\":{\"localhost\":{\"InlineDNSLink\":true," - "\"Paths\":[\"/ipfs\",\"/ipns\",\"/api\"],\"UseSubdomains\":true}}}," - "\"Swarm\":{\"ConnMgr\":{\"GracePeriod\":\"20s\"," - "\"HighWater\":40,\"LowWater\":20}}}"; + "\"Paths\":[\"/ipfs\",\"/ipns\",\"/api\"],\"UseSubdomains\":true}}}}"; ASSERT_TRUE(UpdateConfigJSON(json, config.get(), &updated)); EXPECT_EQ(updated, expect); }