kubo/core/node/libp2p/relay.go
Steven Allen e164af1f2a feat: add a transport config section
This way, users can disable transports (especially QUIC), and set muxer/security
transport priorities.
2020-06-16 15:15:47 -07:00

24 lines
609 B
Go

package libp2p
import (
"github.com/libp2p/go-libp2p"
relay "github.com/libp2p/go-libp2p-circuit"
)
func Relay(enableRelay, enableHop bool) func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
if enableRelay {
relayOpts := []relay.RelayOpt{}
if enableHop {
relayOpts = append(relayOpts, relay.OptHop)
}
opts.Opts = append(opts.Opts, libp2p.EnableRelay(relayOpts...))
} else {
opts.Opts = append(opts.Opts, libp2p.DisableRelay())
}
return
}
}
var AutoRelay = simpleOpt(libp2p.ChainOptions(libp2p.EnableAutoRelay(), libp2p.DefaultStaticRelays()))