mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-23 03:17:43 +08:00
Most of the removed options are many years old. In addition, they've all been removed in past iterations of Kubo. Some options were marked as removed in the config.md, but we still had a warning in the code to let users know they have been removed. I think it's been long enough for all of this options, and enough Kubo iterations in order to alert the users. It is good to keep it in the config.md for now so that people can actually check. However, I think it's time to remove them from the code itself.
35 lines
990 B
Go
35 lines
990 B
Go
package libp2p
|
|
|
|
import (
|
|
"github.com/ipfs/kubo/config"
|
|
|
|
"github.com/libp2p/go-libp2p"
|
|
"github.com/libp2p/go-libp2p/p2p/security/noise"
|
|
tls "github.com/libp2p/go-libp2p/p2p/security/tls"
|
|
)
|
|
|
|
func Security(enabled bool, tptConfig config.Transports) interface{} {
|
|
if !enabled {
|
|
return func() (opts Libp2pOpts) {
|
|
log.Errorf(`Your IPFS node has been configured to run WITHOUT ENCRYPTED CONNECTIONS.
|
|
You will not be able to connect to any nodes configured to use encrypted connections`)
|
|
opts.Opts = append(opts.Opts, libp2p.NoSecurity)
|
|
return opts
|
|
}
|
|
}
|
|
|
|
// Using the new config options.
|
|
return func() (opts Libp2pOpts) {
|
|
opts.Opts = append(opts.Opts, prioritizeOptions([]priorityOption{{
|
|
priority: tptConfig.Security.TLS,
|
|
defaultPriority: 200,
|
|
opt: libp2p.Security(tls.ID, tls.New),
|
|
}, {
|
|
priority: tptConfig.Security.Noise,
|
|
defaultPriority: 100,
|
|
opt: libp2p.Security(noise.ID, noise.New),
|
|
}}))
|
|
return opts
|
|
}
|
|
}
|