MCPcopy Create free account
hub / github.com/zalando/skipper / remoteHost

Function remoteHost

logging/access.go:72–86  ·  view source on GitHub ↗

The remote host of the client. When the 'X-Forwarded-For' header is set, then its value is used as is.

(r *http.Request)

Source from the content-addressed store, hash-verified

70// The remote host of the client. When the 'X-Forwarded-For'
71// header is set, then its value is used as is.
72func remoteHost(r *http.Request) string {
73 ff := r.Header.Get("X-Forwarded-For")
74 if ff != "" {
75 result := make([]string, 0)
76 for s := range strings.SplitSeq(ff, ", ") {
77 addr, err := netip.ParseAddr(stripPort(s))
78 if err != nil {
79 continue // ignore bogus entries from XFF
80 }
81 result = append(result, addr.String())
82 }
83 return strings.Join(result, ", ")
84 }
85 return stripPort(r.RemoteAddr)
86}
87
88func omitWhitespace(h string) string {
89 if h != "" {

Callers 1

LogAccessMethod · 0.70

Calls 4

JoinMethod · 0.80
stripPortFunction · 0.70
GetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…