add QUIC v1 addresses to the default listen addresses
@@ -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")
+ 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",
+ }
+ listenAddrs := make([]multiaddr.Multiaddr, 0, len(addrs))
+ for _, s := range addrs {
+ addr, err := multiaddr.NewMultiaddr(s)
if err != nil {
return err
}
- 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 = append(listenAddrs, addr)
}
- return cfg.Apply(ListenAddrs(
- defaultIP4TCPListenAddr,
- defaultIP4QUICListenAddr,
- defaultIP6TCPListenAddr,
- defaultIP6QUICListenAddr,
- ))
+ return cfg.Apply(ListenAddrs(listenAddrs...))
}
// DefaultEnableRelay enables relay dialing and listening by default.
