package dms3p2p import ( config "gitlab.dms3.io/dms3/go-dms3-config" "gitlab.dms3.io/p2p/go-p2p" noise "gitlab.dms3.io/p2p/go-p2p-noise" secio "gitlab.dms3.io/p2p/go-p2p-secio" tls "gitlab.dms3.io/p2p/go-p2p-tls" ) func Security(enabled bool, tptConfig config.Transports) interface{} { if !enabled { return func() (opts P2pOpts) { log.Errorf(`Your DMS3 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, p2p.NoSecurity) return opts } } // Using the new config options. return func() (opts P2pOpts) { opts.Opts = append(opts.Opts, prioritizeOptions([]priorityOption{{ priority: tptConfig.Security.TLS, defaultPriority: 100, opt: p2p.Security(tls.ID, tls.New), }, { priority: tptConfig.Security.SECIO, defaultPriority: config.Disabled, opt: p2p.Security(secio.ID, secio.New), }, { priority: tptConfig.Security.Noise, defaultPriority: 300, opt: p2p.Security(noise.ID, noise.New), }})) return opts } }