mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 02:47:48 +08:00
Some checks failed
CodeQL / codeql (push) Has been cancelled
Docker Build / docker-build (push) Has been cancelled
Gateway Conformance / gateway-conformance (push) Has been cancelled
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Has been cancelled
Go Build / go-build (push) Has been cancelled
Go Check / go-check (push) Has been cancelled
Go Lint / go-lint (push) Has been cancelled
Go Test / go-test (push) Has been cancelled
Interop / interop-prep (push) Has been cancelled
Sharness / sharness-test (push) Has been cancelled
Interop / helia-interop (push) Has been cancelled
Interop / ipfs-webui (push) Has been cancelled
34 lines
926 B
Go
34 lines
926 B
Go
package libp2p
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
|
|
"github.com/ipfs/kubo/config"
|
|
|
|
"github.com/libp2p/go-libp2p"
|
|
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
|
|
)
|
|
|
|
func makeSmuxTransportOption(tptConfig config.Transports) (libp2p.Option, error) {
|
|
if prefs := os.Getenv("LIBP2P_MUX_PREFS"); prefs != "" {
|
|
return nil, errors.New("configuring muxers with LIBP2P_MUX_PREFS is no longer supported, use Swarm.Transports.Multiplexers")
|
|
}
|
|
if tptConfig.Multiplexers.Yamux < 0 {
|
|
return nil, errors.New("running libp2p with Swarm.Transports.Multiplexers.Yamux disabled is not supported")
|
|
}
|
|
|
|
return libp2p.Muxer(yamux.ID, yamux.DefaultTransport), nil
|
|
}
|
|
|
|
func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error) {
|
|
return func() (opts Libp2pOpts, err error) {
|
|
res, err := makeSmuxTransportOption(tptConfig)
|
|
if err != nil {
|
|
return opts, err
|
|
}
|
|
opts.Opts = append(opts.Opts, res)
|
|
return opts, nil
|
|
}
|
|
}
|