Skip to content

Commit

Permalink
enable hole punching
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored and aschmahmann committed Nov 29, 2021
1 parent 52c177c commit 127edc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option {
fx.Invoke(libp2p.SetupDiscovery(cfg.Discovery.MDNS.Enabled, cfg.Discovery.MDNS.Interval)),
fx.Provide(libp2p.ForceReachability(cfg.Internal.Libp2pForceReachability)),
fx.Provide(libp2p.StaticRelays(cfg.Swarm.RelayClient.StaticRelays)),
fx.Provide(libp2p.HolePunching(cfg.Swarm.EnableHolePunching, cfg.Swarm.RelayService.Enabled.WithDefault(false))),

fx.Provide(libp2p.Security(!bcfg.DisableEncryptedConnections, cfg.Swarm.Transports)),

Expand Down
9 changes: 9 additions & 0 deletions core/node/libp2p/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ func AutoRelay(addDefaultRelays bool) func() (opts Libp2pOpts, err error) {
return
}
}

func HolePunching(flag config.Flag, hasRelayClient bool) func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
if flag.WithDefault(false) hasRelayClient {
opts.Opts = append(opts.Opts, libp2p.EnableHolePunching())
}
return
}
}

0 comments on commit 127edc6

Please sign in to comment.