isLoopback returns true if the host is a loopback address. For IP addresses, it uses net.IP.IsLoopback(). For hostnames, it recognizes well-known loopback hostnames like "localhost" and Docker-specific loopback patterns like "*.docker.internal".
(host string)
| 908 | // For hostnames, it recognizes well-known loopback hostnames like "localhost" |
| 909 | // and Docker-specific loopback patterns like "*.docker.internal". |
| 910 | func isLoopback(host string) bool { |
| 911 | ip := net.ParseIP(host) |
| 912 | if ip != nil { |
| 913 | return ip.IsLoopback() |
| 914 | } |
| 915 | |
| 916 | if strings.ToLower(host) == "localhost" { |
| 917 | return true |
| 918 | } |
| 919 | |
| 920 | if strings.HasSuffix(strings.ToLower(host), ".docker.internal") { |
| 921 | return true |
| 922 | } |
| 923 | |
| 924 | return false |
| 925 | } |
| 926 | |
| 927 | func (c *clusterState) slotMasterNode(slot int) (*clusterNode, error) { |
| 928 | nodes := c.slotNodes(slot) |
no outgoing calls
no test coverage detected