Documentation
¶
Index ¶
- Variables
- func HostPort(hp string) (string, int)
- func IPFromHostPort(hp string) string
- func IPsFromForwarded(dst []string, values []string) ([]string, error)
- func IPsFromXForwardedFor(dst []string, values []string) ([]string, error)
- func IsValidAuthority(authority string) bool
- func LocalAddress(req *http.Request) string
- func NewTraceRoundTripper(rt http.RoundTripper) http.RoundTripper
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidForwardedIP = errors.New("invalid forwarded ip")
)
Functions ¶
func IPFromHostPort ¶
func IPsFromForwarded ¶ added in v0.17.17
func IPsFromXForwardedFor ¶ added in v0.17.17
func IsValidAuthority ¶ added in v0.17.17
IsValidAuthority reports whether authority is safe to use as an HTTP Host value for proxying and Forwarded header construction.
This is intentionally a pragmatic ASCII allowlist, not a full DNS/IP validator. It accepts hostname-like reg-names, IPv4-like values, and bracketed IPv6 literals with an optional port. Its primary purpose is to reject Forwarded header delimiters, quoting characters, whitespace, control characters, and other bytes that could change the structure of a Forwarded header.
In particular, ',' and ';' are rejected to prevent Forwarded header element/parameter injection.
func LocalAddress ¶
func NewTraceRoundTripper ¶
func NewTraceRoundTripper(rt http.RoundTripper) http.RoundTripper
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.