提交 b57956c5 作者: Steven Allen

core: fix autonat construction

License: MIT
Signed-off-by: 's avatarSteven Allen <steven@stebalien.com>
上级 a59b93b0
...@@ -114,7 +114,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option { ...@@ -114,7 +114,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option {
maybeProvide(libp2p.NatPortMap, !cfg.Swarm.DisableNatPortMap), maybeProvide(libp2p.NatPortMap, !cfg.Swarm.DisableNatPortMap),
maybeProvide(libp2p.AutoRealy, cfg.Swarm.EnableAutoRelay), maybeProvide(libp2p.AutoRealy, cfg.Swarm.EnableAutoRelay),
maybeProvide(libp2p.QUIC, cfg.Experimental.QUIC), maybeProvide(libp2p.QUIC, cfg.Experimental.QUIC),
maybeProvide(libp2p.AutoNATService(cfg.Experimental.QUIC), cfg.Swarm.EnableAutoNATService), maybeInvoke(libp2p.AutoNATService(cfg.Experimental.QUIC), cfg.Swarm.EnableAutoNATService),
connmgr, connmgr,
ps, ps,
) )
......
...@@ -43,6 +43,13 @@ func maybeProvide(opt interface{}, enable bool) fx.Option { ...@@ -43,6 +43,13 @@ func maybeProvide(opt interface{}, enable bool) fx.Option {
return fx.Options() return fx.Options()
} }
func maybeInvoke(opt interface{}, enable bool) fx.Option {
if enable {
return fx.Invoke(opt)
}
return fx.Options()
}
// baseProcess creates a goprocess which is closed when the lifecycle signals it to stop // baseProcess creates a goprocess which is closed when the lifecycle signals it to stop
func baseProcess(lc fx.Lifecycle) goprocess.Process { func baseProcess(lc fx.Lifecycle) goprocess.Process {
p := goprocess.WithParent(goprocess.Background()) p := goprocess.WithParent(goprocess.Background())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论