| 870 | } |
| 871 | |
| 872 | func 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 |