MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / IsLoopback

Function IsLoopback

internal/util/net.go:12–26  ·  view source on GitHub ↗
(addr string)

Source from the content-addressed store, hash-verified

10)
11
12func IsLoopback(addr string) bool {
13 host, _, err := net.SplitHostPort(addr)
14 if err != nil {
15 // If SplitHostPort fails, it might be just a host without a port.
16 host = strings.Trim(addr, "[]")
17 }
18 if host == "localhost" {
19 return true
20 }
21 ip, err := netip.ParseAddr(host)
22 if err != nil {
23 return false
24 }
25 return ip.IsLoopback()
26}

Callers 5

checkHTTPSOrLoopbackFunction · 0.92
inferApplicationTypeFunction · 0.92
ServeHTTPMethod · 0.92
ServeHTTPMethod · 0.92
TestIsLoopbackFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsLoopbackFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…