MCPcopy
hub / github.com/redis/go-redis / replaceZeroPort

Function replaceZeroPort

osscluster.go:895–904  ·  view source on GitHub ↗

replaceZeroPort substitutes originPort for a node port of "0", which is what CLUSTER SLOTS reports for TLS-only clusters started with `--port 0 --tls-port <port>`. Non-zero ports and addresses without a recoverable origin port are returned unchanged.

(nodeAddr, originPort string)

Source from the content-addressed store, hash-verified

893// `--port 0 --tls-port <port>`. Non-zero ports and addresses without a
894// recoverable origin port are returned unchanged.
895func replaceZeroPort(nodeAddr, originPort string) string {
896 if originPort == "" || originPort == "0" {
897 return nodeAddr
898 }
899 nodeHost, nodePort, err := net.SplitHostPort(nodeAddr)
900 if err != nil || nodePort != "0" {
901 return nodeAddr
902 }
903 return net.JoinHostPort(nodeHost, originPort)
904}
905
906// isLoopback returns true if the host is a loopback address.
907// For IP addresses, it uses net.IP.IsLoopback().

Callers 1

newClusterStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected