@cryptotaxi247 / kubo / commits / ec46f1e6e

fix prioritization of stream muxers

Marten Seemann committed Feb 25, 2022 at 11:44 UTC ec46f1e6e4b6375bb098e33dc7cb779a143705f8
2 files changed +4 -4
core/node/libp2p/libp2p.go
+2 -2
@@ -58,7 +58,7 @@ type priorityOption struct {
58
59 func prioritizeOptions(opts []priorityOption) libp2p.Option {
60 type popt struct {
61 - priority int64
61 + priority int64 // lower priority values mean higher priority
62 opt libp2p.Option
63 }
64 enabledOptions := make([]popt, 0, len(opts))
@@ -71,7 +71,7 @@ func prioritizeOptions(opts []priorityOption) libp2p.Option {
71 }
72 }
73 sort.Slice(enabledOptions, func(i, j int) bool {
74 - return enabledOptions[i].priority > enabledOptions[j].priority
74 + return enabledOptions[i].priority < enabledOptions[j].priority
75 })
76 p2pOpts := make([]libp2p.Option, len(enabledOptions))
77 for i, opt := range enabledOptions {
core/node/libp2p/sec.go
+2 -2
@@ -30,11 +30,11 @@ func Security(enabled bool, tptConfig config.Transports) interface{} {
30 return func() (opts Libp2pOpts) {
31 opts.Opts = append(opts.Opts, prioritizeOptions([]priorityOption{{
32 priority: tptConfig.Security.TLS,
33 - defaultPriority: 100,
33 + defaultPriority: 200,
34 opt: libp2p.Security(tls.ID, tls.New),
35 }, {
36 priority: tptConfig.Security.Noise,
37 - defaultPriority: 300,
37 + defaultPriority: 100,
38 opt: libp2p.Security(noise.ID, noise.New),
39 }}))
40 return opts