@@ -3,13 +3,11 @@ package libp2p
3
3
import (
4
4
"fmt"
5
5
"os"
6
- "strings"
7
6
8
7
"github.com/ipfs/kubo/config"
9
8
10
9
"github.com/libp2p/go-libp2p"
11
10
"github.com/libp2p/go-libp2p/core/network"
12
- "github.com/libp2p/go-libp2p/p2p/muxer/mplex"
13
11
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
14
12
)
15
13
@@ -23,45 +21,17 @@ func yamuxTransport() network.Multiplexer {
23
21
}
24
22
25
23
func makeSmuxTransportOption (tptConfig config.Transports ) (libp2p.Option , error ) {
26
- const yamuxID = "/yamux/1.0.0"
27
- const mplexID = "/mplex/6.7.0"
28
-
29
24
if prefs := os .Getenv ("LIBP2P_MUX_PREFS" ); prefs != "" {
30
- // Using legacy LIBP2P_MUX_PREFS variable.
31
- log .Error ("LIBP2P_MUX_PREFS is now deprecated." )
32
- log .Error ("Use the `Swarm.Transports.Multiplexers' config field." )
33
- muxers := strings .Fields (prefs )
34
- enabled := make (map [string ]bool , len (muxers ))
35
-
36
- var opts []libp2p.Option
37
- for _ , tpt := range muxers {
38
- if enabled [tpt ] {
39
- return nil , fmt .Errorf (
40
- "duplicate muxer found in LIBP2P_MUX_PREFS: %s" ,
41
- tpt ,
42
- )
43
- }
44
- switch tpt {
45
- case yamuxID :
46
- opts = append (opts , libp2p .Muxer (tpt , yamuxTransport ()))
47
- case mplexID :
48
- opts = append (opts , libp2p .Muxer (tpt , mplex .DefaultTransport ))
49
- default :
50
- return nil , fmt .Errorf ("unknown muxer: %s" , tpt )
51
- }
52
- }
53
- return libp2p .ChainOptions (opts ... ), nil
54
- } else {
55
- return prioritizeOptions ([]priorityOption {{
56
- priority : tptConfig .Multiplexers .Yamux ,
57
- defaultPriority : 100 ,
58
- opt : libp2p .Muxer (yamuxID , yamuxTransport ()),
59
- }, {
60
- priority : tptConfig .Multiplexers .Mplex ,
61
- defaultPriority : 200 ,
62
- opt : libp2p .Muxer (mplexID , mplex .DefaultTransport ),
63
- }}), nil
25
+ return nil , fmt .Errorf ("configuring muxers with LIBP2P_MUX_PREFS is no longer supported" )
64
26
}
27
+ if tptConfig .Multiplexers .Mplex != 0 {
28
+ return nil , fmt .Errorf ("Swarm.Transports.Multiplexers.Mplex is no longer supported" )
29
+ }
30
+ if tptConfig .Multiplexers .Yamux < 0 {
31
+ return nil , fmt .Errorf ("Swarm.Transports.Multiplexers.Yamux is disabled even tho it is the only multiplexer available" )
32
+ }
33
+
34
+ return libp2p .Muxer (yamux .ID , yamuxTransport ()), nil
65
35
}
66
36
67
37
func SmuxTransport (tptConfig config.Transports ) func () (opts Libp2pOpts , err error ) {
0 commit comments