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

Function replaceLoopbackHost

osscluster.go:872–889  ·  view source on GitHub ↗
(nodeAddr, originHost string)

Source from the content-addressed store, hash-verified

870}
871
872func replaceLoopbackHost(nodeAddr, originHost string) string {
873 nodeHost, nodePort, err := net.SplitHostPort(nodeAddr)
874 if err != nil {
875 return nodeAddr
876 }
877
878 nodeIP := net.ParseIP(nodeHost)
879 if nodeIP == nil {
880 return nodeAddr
881 }
882
883 if !nodeIP.IsLoopback() {
884 return nodeAddr
885 }
886
887 // Use origin host which is not loopback and node port.
888 return net.JoinHostPort(originHost, nodePort)
889}
890
891// replaceZeroPort substitutes originPort for a node port of "0", which is
892// what CLUSTER SLOTS reports for TLS-only clusters started with

Callers 1

newClusterStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected