diff --git a/go.mod b/go.mod index 94aa258c7..5cbcabbfe 100644 --- a/go.mod +++ b/go.mod @@ -69,7 +69,6 @@ require ( github.com/lib/pq v1.2.0 github.com/libp2p/go-eventbus v0.1.0 github.com/libp2p/go-libp2p v0.9.2 - github.com/libp2p/go-libp2p-circuit v0.2.2 github.com/libp2p/go-libp2p-connmgr v0.2.3 github.com/libp2p/go-libp2p-core v0.5.6 github.com/libp2p/go-libp2p-discovery v0.4.0 diff --git a/node/builder.go b/node/builder.go index af0175294..0154f1494 100644 --- a/node/builder.go +++ b/node/builder.go @@ -169,7 +169,7 @@ func libp2p() Option { Override(DiscoveryHandlerKey, lp2p.DiscoveryHandler), Override(AddrsFactoryKey, lp2p.AddrsFactory(nil, nil)), Override(SmuxTransportKey, lp2p.SmuxTransport(true)), - Override(RelayKey, lp2p.Relay(true, false)), + Override(RelayKey, lp2p.NoRelay()), Override(SecurityKey, lp2p.Security(true, true)), Override(BaseRoutingKey, lp2p.BaseRouting), diff --git a/node/modules/lp2p/relay.go b/node/modules/lp2p/relay.go index 65eeecb9e..a6bedb12b 100644 --- a/node/modules/lp2p/relay.go +++ b/node/modules/lp2p/relay.go @@ -4,29 +4,15 @@ import ( "fmt" "github.com/libp2p/go-libp2p" - circuit "github.com/libp2p/go-libp2p-circuit" coredisc "github.com/libp2p/go-libp2p-core/discovery" routing "github.com/libp2p/go-libp2p-core/routing" discovery "github.com/libp2p/go-libp2p-discovery" - basichost "github.com/libp2p/go-libp2p/p2p/host/basic" - relay "github.com/libp2p/go-libp2p/p2p/host/relay" - "go.uber.org/fx" - - "github.com/filecoin-project/lotus/node/modules/helpers" ) -func Relay(disable, enableHop bool) func() (opts Libp2pOpts, err error) { +func NoRelay() func() (opts Libp2pOpts, err error) { return func() (opts Libp2pOpts, err error) { - if disable { - // Enabled by default. - opts.Opts = append(opts.Opts, libp2p.DisableRelay()) - } else { - relayOpts := []circuit.RelayOpt{circuit.OptDiscovery} - if enableHop { - relayOpts = append(relayOpts, circuit.OptHop) - } - opts.Opts = append(opts.Opts, libp2p.EnableRelay(relayOpts...)) - } + // always disabled, it's an eclipse attack vector + opts.Opts = append(opts.Opts, libp2p.DisableRelay()) return } } @@ -40,17 +26,3 @@ func Discovery(router BaseIpfsRouting) (coredisc.Discovery, error) { return discovery.NewRoutingDiscovery(crouter), nil } - -// NOTE: only set when relayHop is set -func AdvertiseRelay(mctx helpers.MetricsCtx, d coredisc.Discovery) { - relay.Advertise(mctx, d) -} - -// NOTE: only set when relayHop is not set -func AutoRelay(mctx helpers.MetricsCtx, lc fx.Lifecycle, router BaseIpfsRouting, h RawHost, d coredisc.Discovery) error { - ctx := helpers.LifecycleCtx(mctx, lc) - - // TODO: review: LibP2P doesn't set this as host in config.go, why? - _ = relay.NewAutoRelay(ctx, h.(*basichost.BasicHost), d, router, nil) - return nil -}