2019-07-02 12:40:25 +00:00
|
|
|
package lp2p
|
2019-07-01 09:09:48 +00:00
|
|
|
|
2019-07-01 10:18:00 +00:00
|
|
|
import (
|
|
|
|
"github.com/libp2p/go-libp2p"
|
|
|
|
)
|
|
|
|
|
2019-07-01 09:09:48 +00:00
|
|
|
/*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-quic-transport"
|
|
|
|
"go.uber.org/fx"
|
|
|
|
|
|
|
|
"github.com/ipfs/go-ipfs/repo"
|
|
|
|
|
2019-10-18 04:47:41 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
2019-07-01 09:09:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2019-07-01 10:18:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
var NatPortMap = simpleOpt(libp2p.NATPortMap())
|