Skip to content

Commit

Permalink
fix: enable holepunching
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann authored and hacdias committed Apr 8, 2024
1 parent 4ff9f0e commit 19723fe
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,22 @@ func Setup(ctx context.Context, cfg Config, key crypto.PrivKey, dnsCache *cached
}

opts := []libp2p.Option{
libp2p.ListenAddrStrings(cfg.ListenAddrs...),
libp2p.NATPortMap(),
libp2p.ConnectionManager(cmgr),
libp2p.Identity(key),
libp2p.BandwidthReporter(bwc),
libp2p.DefaultTransports,
libp2p.DefaultMuxers,
libp2p.ResourceManager(bitswapRcMgr),
libp2p.EnableHolePunching(),
}

if len(cfg.ListenAddrs) == 0 {
// Note: because the transports are set above we must also set the listen addresses
// We need to set listen addresses in order for hole punching to work
opts = append(opts, libp2p.DefaultListenAddrs)
} else {
opts = append(opts, libp2p.ListenAddrStrings(cfg.ListenAddrs...))
}

if len(cfg.AnnounceAddrs) > 0 {
Expand Down

0 comments on commit 19723fe

Please sign in to comment.