3 unstable releases
0.2.0 | Jan 20, 2021 |
---|---|
0.1.1 | Jan 6, 2021 |
0.1.0 | Dec 3, 2020 |
#1170 in HTTP server
154 downloads per month
Used in webb-relayer
6KB
65 lines
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()));
Dependencies
~9–18MB
~245K SLoC