From 50eecb6854716ba43bba3c918f679b2fe4c75292 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 22 Nov 2022 12:04:01 +1300 Subject: [PATCH] add QUIC v1 addresses to the default listen addresses --- defaults.go | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/defaults.go b/defaults.go index c36c760ccc..86f51a4b73 100644 --- a/defaults.go +++ b/defaults.go @@ -65,29 +65,23 @@ var RandomIdentity = func(cfg *Config) error { // DefaultListenAddrs configures libp2p to use default listen address. var DefaultListenAddrs = func(cfg *Config) error { - defaultIP4TCPListenAddr, err := multiaddr.NewMultiaddr("/ip4/0.0.0.0/tcp/0") - if err != nil { - return err + addrs := []string{ + "/ip4/0.0.0.0/tcp/0", + "/ip4/0.0.0.0/udp/0/quic", + "/ip4/0.0.0.0/udp/0/quic-v1", + "/ip6/::/tcp/0", + "/ip6/::/udp/0/quic", + "/ip6/::/udp/0/quic-v1", } - defaultIP4QUICListenAddr, err := multiaddr.NewMultiaddr("/ip4/0.0.0.0/udp/0/quic") - if err != nil { - return err - } - - defaultIP6TCPListenAddr, err := multiaddr.NewMultiaddr("/ip6/::/tcp/0") - if err != nil { - return err - } - defaultIP6QUICListenAddr, err := multiaddr.NewMultiaddr("/ip6/::/udp/0/quic") - if err != nil { - return err + listenAddrs := make([]multiaddr.Multiaddr, 0, len(addrs)) + for _, s := range addrs { + addr, err := multiaddr.NewMultiaddr(s) + if err != nil { + return err + } + listenAddrs = append(listenAddrs, addr) } - return cfg.Apply(ListenAddrs( - defaultIP4TCPListenAddr, - defaultIP4QUICListenAddr, - defaultIP6TCPListenAddr, - defaultIP6QUICListenAddr, - )) + return cfg.Apply(ListenAddrs(listenAddrs...)) } // DefaultEnableRelay enables relay dialing and listening by default.