|
lintel 0.2.0
|
#include <ClientIpResolver.h>
Public Member Functions | |
| ClientIpResolver ()=default | |
| ClientIpResolver (std::vector< std::string > trustedProxies) | |
| void | setTrustedProxies (std::vector< std::string > trustedProxies) |
| std::string | resolveClientIp (const std::string &remoteAddress, const std::string &forwardedFor) const |
Resolves the client IP address of an HTTP request.
The X-Forwarded-For header is only honored when the direct peer (the socket remote address) is a configured trusted proxy. Untrusted peers cannot spoof their IP, so the header is ignored by default. Trusted proxies are matched as exact IPs or CIDR ranges (e.g. "10.0.0.0/8").
|
default |
|
explicit |
| trustedProxies | IPs or CIDR ranges allowed to forward X-Forwarded-For |
| std::string lintel::ClientIpResolver::resolveClientIp | ( | const std::string & | remoteAddress, |
| const std::string & | forwardedFor | ||
| ) | const |
Determine the client IP of a request.
| remoteAddress | the direct peer address (socket remote address) |
| forwardedFor | the raw X-Forwarded-For header value (may be empty) |
| void lintel::ClientIpResolver::setTrustedProxies | ( | std::vector< std::string > | trustedProxies | ) |
Replace the list of trusted proxies (exact IPs or CIDR ranges).