in correlation/inbound_http_options.go [114:143]
func (c *inboundHandlerConfig) shouldPropagate(r *http.Request) bool {
if !c.propagation || c.invalidCIDRsForPropagation {
return false
}
if len(c.trustedCIDRsForPropagation) == 0 {
return true
}
remoteAddr := r.RemoteAddr
if c.xffAllowed != nil {
// Unix domain sockets have a remote addr of @. This will make the
// xff package lookup the X-Forwarded-For address if available.
if remoteAddr == "@" {
r.RemoteAddr = "127.0.0.1:0"
}
remoteAddr = xff.GetRemoteAddrIfAllowed(r, c.xffAllowed)
// If X-Forwarded-For was allowed and returned a different address, check
// the original address against our trusted CIDRs for propagation, in case
// the reverse proxy is trusted
if remoteAddr != r.RemoteAddr && isTrustedAddr(r.RemoteAddr, c.trustedCIDRsForPropagation) {
return true
}
}
return isTrustedAddr(remoteAddr, c.trustedCIDRsForPropagation)
}