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

Method ClientIP

modules/caddyhttp/templates/tplcontext.go:292–299  ·  view source on GitHub ↗

ClientIP gets the IP address of the real client making the request if the request is trusted (see trusted_proxies), otherwise returns the connection's remote IP.

()

Source from the content-addressed store, hash-verified

290// if the request is trusted (see trusted_proxies), otherwise returns
291// the connection's remote IP.
292func (c TemplateContext) ClientIP() string {
293 address := caddyhttp.GetVar(c.Req.Context(), caddyhttp.ClientIPVarKey).(string)
294 clientIP, _, err := net.SplitHostPort(address)
295 if err != nil {
296 clientIP = address // no port
297 }
298 return clientIP
299}
300
301// Host returns the hostname portion of the Host header
302// from the HTTP request.

Callers

nothing calls this directly

Calls 1

GetVarFunction · 0.92

Tested by

no test coverage detected