No description
Find a file
2021-01-06 14:54:55 +01:00
.github/workflows ci 2020-12-03 16:29:10 +01:00
src add support for rfc7239 forwarded 2021-01-06 14:52:52 +01:00
tests add support for rfc7239 forwarded 2021-01-06 14:52:52 +01:00
.gitignore init repo 2020-12-03 15:46:21 +01:00
Cargo.lock add support for rfc7239 forwarded 2021-01-06 14:52:52 +01:00
Cargo.toml add support for rfc7239 forwarded 2021-01-06 14:52:52 +01:00
README.md readme 2021-01-06 14:54:55 +01:00

wrap-real-ip

Warp filter to get the "real ip" of the remote client

This uses the "x-forwarded-for", "x-real-ip" or "forwarded" headers set by reverse proxies. To stop clients from abusing these headers, only headers set by trusted remotes will be accepted.

Example

use warp::Filter;
use warp_real_ip::real_ip;
use std::net::IpAddr;

let proxy_addr = [127, 10, 0, 1].into();
warp::any()
    .and(real_ip(vec![proxy_addr]))
    .map(|addr: Option<IpAddr>| format!("Hello {}", addr.unwrap()));