No description
Find a file
2021-07-29 16:49:48 +02:00
.github/workflows ci 2020-12-03 16:29:10 +01:00
src fix maybe_bracketd for empty strings 2021-07-29 16:49:48 +02:00
tests minor cleanup 2021-07-29 16:45:38 +02:00
.gitignore init repo 2020-12-03 15:46:21 +01:00
Cargo.lock warp 0.3 2021-01-20 17:29:45 +01:00
Cargo.toml warp 0.3 2021-01-20 17:29:45 +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()));