Skip to content

Commit 5a4d5ab

Browse files
committed
fix: when the relay client is disabled and hole punching is left in its default state silently turn off hole punching instead of panicking
1 parent 4e92f74 commit 5a4d5ab

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/node/libp2p/relay.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ func HolePunching(flag config.Flag, hasRelayClient bool) func() (opts Libp2pOpts
7171
return func() (opts Libp2pOpts, err error) {
7272
if flag.WithDefault(true) {
7373
if !hasRelayClient {
74-
log.Fatal("Failed to enable `Swarm.EnableHolePunching`, it requires `Swarm.RelayClient.Enabled` to be true.")
74+
// If hole punching is explicitly enabled but the relay client is disabled then panic,
75+
// otherwise just silently disable hole punching
76+
if flag != config.Default {
77+
log.Fatal("Failed to enable `Swarm.EnableHolePunching`, it requires `Swarm.RelayClient.Enabled` to be true.")
78+
}
7579
return
7680
}
7781
opts.Opts = append(opts.Opts, libp2p.EnableHolePunching())

0 commit comments

Comments
 (0)