-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
nat.go
38 lines (31 loc) · 1.07 KB
/
nat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package lp2p
import (
"github.com/libp2p/go-libp2p"
)
/*import (
"github.com/libp2p/go-libp2p"
autonat "github.com/libp2p/go-libp2p-autonat-svc"
host "github.com/libp2p/go-libp2p/core/host"
libp2pquic "github.com/libp2p/go-libp2p/p2p/transport/quic"
"go.uber.org/fx"
"github.com/ipfs/go-ipfs/repo"
"github.com/filecoin-project/lotus/node/modules/helpers"
)
func AutoNATService(quic bool) func(repo repo.Repo, mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) error {
return func(repo repo.Repo, mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) error {
// 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 quic {
opts.Opts = append(opts.Opts, libp2p.DefaultTransports, libp2p.Transport(libp2pquic.NewTransport))
}
_, err = autonat.NewAutoNATService(helpers.LifecycleCtx(mctx, lc), host, opts.Opts...)
return err
}
}
*/
var AutoNATService = simpleOpt(libp2p.EnableNATService())
var NatPortMap = simpleOpt(libp2p.NATPortMap())