2021-05-21 12:16:07 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/multiformats/go-multiaddr"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
tlsProtocolName = "tls"
|
|
|
|
)
|
|
|
|
|
|
|
|
// tls var is used for (un)wrapping other multiaddrs around TLS multiaddr.
|
2021-07-30 16:43:22 +00:00
|
|
|
var tls, _ = multiaddr.NewMultiaddr("/" + tlsProtocolName)
|
2021-05-21 12:16:07 +00:00
|
|
|
|
|
|
|
// TLSEnabled searches for wrapped TLS protocol in multiaddr.
|
|
|
|
func (a Address) TLSEnabled() bool {
|
|
|
|
for _, protoc := range a.ma.Protocols() {
|
2021-07-30 16:43:22 +00:00
|
|
|
if protoc.Code == multiaddr.P_TLS {
|
2021-05-21 12:16:07 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|