MCPcopy
hub / github.com/caddyserver/caddy / isTrustedClientIP

Function isTrustedClientIP

modules/caddyhttp/server.go:1081–1085  ·  view source on GitHub ↗

isTrustedClientIP returns true if the given IP address is in the list of trusted IP ranges.

(ipAddr netip.Addr, trusted []netip.Prefix)

Source from the content-addressed store, hash-verified

1079// isTrustedClientIP returns true if the given IP address is
1080// in the list of trusted IP ranges.
1081func isTrustedClientIP(ipAddr netip.Addr, trusted []netip.Prefix) bool {
1082 return slices.ContainsFunc(trusted, func(prefix netip.Prefix) bool {
1083 return prefix.Contains(ipAddr)
1084 })
1085}
1086
1087// trustedRealClientIP finds the client IP from the request assuming it is
1088// from a trusted client. If there is no client IP headers, then the

Callers 2

determineTrustedProxyFunction · 0.85
strictUntrustedClientIpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected