Skip to content

Commit

Permalink
Merge pull request #6251 from requilence/autonat-pnet
Browse files Browse the repository at this point in the history
Fix AutoNAT service for private network
  • Loading branch information
Stebalien authored Apr 25, 2019
2 parents 2385ccc + 28c0013 commit a3501a4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions core/node/libp2p/libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,16 +524,23 @@ func PubsubRouter(mctx helpers.MetricsCtx, lc fx.Lifecycle, in p2pPSRoutingIn) (
}, psRouter
}

func AutoNATService(mctx helpers.MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host host.Host) error {
func AutoNATService(repo repo.Repo, mctx helpers.MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host host.Host) error {
if !cfg.Swarm.EnableAutoNATService {
return nil
}
var opts []libp2p.Option

// collect private net option in case swarm.key is presented
opts, _, err := PNet(repo)
if err != nil {
// swarm key exists but was failed to decode
return err
}

if cfg.Experimental.QUIC {
opts = append(opts, libp2p.DefaultTransports, libp2p.Transport(libp2pquic.NewTransport))
opts.Opts = append(opts.Opts, libp2p.DefaultTransports, libp2p.Transport(libp2pquic.NewTransport))
}

_, err := autonat.NewAutoNATService(helpers.LifecycleCtx(mctx, lc), host, opts...)
_, err = autonat.NewAutoNATService(helpers.LifecycleCtx(mctx, lc), host, opts.Opts...)
return err
}

Expand Down

0 comments on commit a3501a4

Please sign in to comment.