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

Function isLoopback

osscluster.go:910–925  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

908// For hostnames, it recognizes well-known loopback hostnames like "localhost"
909// and Docker-specific loopback patterns like "*.docker.internal".
910func 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
927func (c *clusterState) slotMasterNode(slot int) (*clusterNode, error) {
928 nodes := c.slotNodes(slot)

Callers 2

newClusterStateFunction · 0.85
internal_test.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected