mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-12 19:57:55 +08:00
fix prioritization of stream muxers
This commit is contained in:
parent
3ea5631f9a
commit
ec46f1e6e4
@ -58,7 +58,7 @@ type priorityOption struct {
|
||||
|
||||
func prioritizeOptions(opts []priorityOption) libp2p.Option {
|
||||
type popt struct {
|
||||
priority int64
|
||||
priority int64 // lower priority values mean higher priority
|
||||
opt libp2p.Option
|
||||
}
|
||||
enabledOptions := make([]popt, 0, len(opts))
|
||||
@ -71,7 +71,7 @@ func prioritizeOptions(opts []priorityOption) libp2p.Option {
|
||||
}
|
||||
}
|
||||
sort.Slice(enabledOptions, func(i, j int) bool {
|
||||
return enabledOptions[i].priority > enabledOptions[j].priority
|
||||
return enabledOptions[i].priority < enabledOptions[j].priority
|
||||
})
|
||||
p2pOpts := make([]libp2p.Option, len(enabledOptions))
|
||||
for i, opt := range enabledOptions {
|
||||
|
||||
@ -30,11 +30,11 @@ func Security(enabled bool, tptConfig config.Transports) interface{} {
|
||||
return func() (opts Libp2pOpts) {
|
||||
opts.Opts = append(opts.Opts, prioritizeOptions([]priorityOption{{
|
||||
priority: tptConfig.Security.TLS,
|
||||
defaultPriority: 100,
|
||||
defaultPriority: 200,
|
||||
opt: libp2p.Security(tls.ID, tls.New),
|
||||
}, {
|
||||
priority: tptConfig.Security.Noise,
|
||||
defaultPriority: 300,
|
||||
defaultPriority: 100,
|
||||
opt: libp2p.Security(noise.ID, noise.New),
|
||||
}}))
|
||||
return opts
|
||||
|
||||
Loading…
Reference in New Issue
Block a user