Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add QUIC v1 addresses to the default listen addresses #1914

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down