From 0a064c1b3d845d4c7e4abf27d40f5bdb003f8c40 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 10 May 2023 10:51:08 +0300 Subject: [PATCH] libp2p: add QUIC and WebTransport to default listen addresses --- documentation/en/default-lotus-config.toml | 2 +- documentation/en/default-lotus-miner-config.toml | 2 +- itests/net_test.go | 14 ++++++++++---- node/config/def.go | 4 ++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/documentation/en/default-lotus-config.toml b/documentation/en/default-lotus-config.toml index cd93323560..960a55fd01 100644 --- a/documentation/en/default-lotus-config.toml +++ b/documentation/en/default-lotus-config.toml @@ -38,7 +38,7 @@ # # type: []string # env var: LOTUS_LIBP2P_LISTENADDRESSES - #ListenAddresses = ["/ip4/0.0.0.0/tcp/0", "/ip6/::/tcp/0"] + #ListenAddresses = ["/ip4/0.0.0.0/tcp/0", "/ip6/::/tcp/0", "/ip4/0.0.0.0/udp/0/quic-v1", "/ip6/::/udp/0/quic-v1", "/ip4/0.0.0.0/udp/0/quic-v1/webtransport", "/ip6/::/udp/0/quic-v1/webtransport"] # Addresses to explicitally announce to other peers. If not specified, # all interface addresses are announced diff --git a/documentation/en/default-lotus-miner-config.toml b/documentation/en/default-lotus-miner-config.toml index 0c8ef44118..f4df62bef5 100644 --- a/documentation/en/default-lotus-miner-config.toml +++ b/documentation/en/default-lotus-miner-config.toml @@ -38,7 +38,7 @@ # # type: []string # env var: LOTUS_LIBP2P_LISTENADDRESSES - #ListenAddresses = ["/ip4/0.0.0.0/tcp/0", "/ip6/::/tcp/0"] + #ListenAddresses = ["/ip4/0.0.0.0/tcp/0", "/ip6/::/tcp/0", "/ip4/0.0.0.0/udp/0/quic-v1", "/ip6/::/udp/0/quic-v1", "/ip4/0.0.0.0/udp/0/quic-v1/webtransport", "/ip6/::/udp/0/quic-v1/webtransport"] # Addresses to explicitally announce to other peers. If not specified, # all interface addresses are announced diff --git a/itests/net_test.go b/itests/net_test.go index 2ee8f60b9c..47cd4caed9 100644 --- a/itests/net_test.go +++ b/itests/net_test.go @@ -220,14 +220,17 @@ func TestNetBlockIPAddr(t *testing.T) { firstAddrInfo, _ := firstNode.NetAddrsListen(ctx) secondAddrInfo, _ := secondNode.NetAddrsListen(ctx) - var secondNodeIPs []string - + secondNodeIPsMap := map[string]struct{}{} // so we can deduplicate for _, addr := range secondAddrInfo.Addrs { ip, err := manet.ToIP(addr) if err != nil { continue } - secondNodeIPs = append(secondNodeIPs, ip.String()) + secondNodeIPsMap[ip.String()] = struct{}{} + } + var secondNodeIPs []string + for s := range secondNodeIPsMap { + secondNodeIPs = append(secondNodeIPs, s) } // Sanity check that we're not already connected somehow @@ -243,6 +246,8 @@ func TestNetBlockIPAddr(t *testing.T) { list, err := firstNode.NetBlockList(ctx) require.NoError(t, err) + fmt.Println(list.IPAddrs) + fmt.Println(secondNodeIPs) require.Equal(t, len(list.IPAddrs), len(secondNodeIPs), "expected %d blocked IPs", len(secondNodeIPs)) for _, blockedIP := range list.IPAddrs { found := false @@ -256,7 +261,8 @@ func TestNetBlockIPAddr(t *testing.T) { require.True(t, found, "blocked IP %s is not one of secondNodeIPs", blockedIP) } - require.Error(t, secondNode.NetConnect(ctx, firstAddrInfo), "shouldn't be able to connect to second node") + // a QUIC connection might still succeed when gated, but will be killed right after the handshake + _ = secondNode.NetConnect(ctx, firstAddrInfo) connectedness, err = secondNode.NetConnectedness(ctx, firstAddrInfo.ID) require.NoError(t, err, "failed to determine connectedness") require.NotEqual(t, connectedness, network.Connected) diff --git a/node/config/def.go b/node/config/def.go index 7032882880..42b035c66a 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -57,6 +57,10 @@ func defCommon() Common { ListenAddresses: []string{ "/ip4/0.0.0.0/tcp/0", "/ip6/::/tcp/0", + "/ip4/0.0.0.0/udp/0/quic-v1", + "/ip6/::/udp/0/quic-v1", + "/ip4/0.0.0.0/udp/0/quic-v1/webtransport", + "/ip6/::/udp/0/quic-v1/webtransport", }, AnnounceAddresses: []string{}, NoAnnounceAddresses: []string{},