@cryptotaxi247 / kubo / commits / 346fd9d85

fix: when the relay client is disabled and hole punching is left in its default state silently turn off hole punching instead of panicking

Adin Schmahmann committed May 3, 2022 at 11:39 UTC 346fd9d8544152e906da9eede6f7cde93a5810d5
1 file changed +5 -1
core/node/libp2p/relay.go
+5 -1
@@ -71,7 +71,11 @@ func HolePunching(flag config.Flag, hasRelayClient bool) func() (opts Libp2pOpts
71 return func() (opts Libp2pOpts, err error) {
72 if flag.WithDefault(true) {
73 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 + }
79 return
80 }
81 opts.Opts = append(opts.Opts, libp2p.EnableHolePunching())