forked from TrueCloudLab/frostfs-node
cd545f0160
In previous implementation NeoFS CLI app used `network.Address.HostAddr` as a server URI, which caused scheme loss since host address doesn't contain it. Rename `HostAddr` to `URIAddr` and make it to return URI address with `grpcs` scheme if TLS is enabled. Make `TLSEnabled` unexported since it was used to provide default `tls.Config` only (it is used by default in SDK). Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
23 lines
463 B
Go
23 lines
463 B
Go
package network
|
|
|
|
import (
|
|
"github.com/multiformats/go-multiaddr"
|
|
)
|
|
|
|
const (
|
|
tlsProtocolName = "tls"
|
|
)
|
|
|
|
// tls var is used for (un)wrapping other multiaddrs around TLS multiaddr.
|
|
var tls, _ = multiaddr.NewMultiaddr("/" + tlsProtocolName)
|
|
|
|
// isTLSEnabled searches for wrapped TLS protocol in multiaddr.
|
|
func (a Address) isTLSEnabled() bool {
|
|
for _, protoc := range a.ma.Protocols() {
|
|
if protoc.Code == multiaddr.P_TLS {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|