mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
This way, users can disable transports (especially QUIC), and set muxer/security transport priorities.
24 lines
609 B
Go
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()))
|