mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 02:47:48 +08:00
* chore: apply go fix modernizers from Go 1.26
automated refactoring: interface{} to any, slices.Contains,
and other idiomatic updates.
* feat(ci): add `go fix` check to Go analysis workflow
ensures Go 1.26 modernizers are applied, fails CI if `go fix ./...`
produces any changes (similar to existing `go fmt` enforcement)
35 lines
982 B
Go
35 lines
982 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) any {
|
|
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: 100,
|
|
opt: libp2p.Security(tls.ID, tls.New),
|
|
}, {
|
|
priority: tptConfig.Security.Noise,
|
|
defaultPriority: 200,
|
|
opt: libp2p.Security(noise.ID, noise.New),
|
|
}}))
|
|
return opts
|
|
}
|
|
}
|