No description
Find a file
Robin Appelman 69df28d0ad
Merge pull request #1 from moriyoshi/allowing-ipnetwork-instead-of-ipaddr
Allow specifying IP networks for permitted proxies in place of IP addresses.
2021-08-18 15:02:55 +00:00
.github/workflows ci 2020-12-03 16:29:10 +01:00
src Merge pull request #1 from moriyoshi/allowing-ipnetwork-instead-of-ipaddr 2021-08-18 15:02:55 +00: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 Allow specifying IP networks for permitted proxies in place of IP addresses. 2021-07-12 10:32:46 +09:00
Cargo.toml Allow specifying IP networks for permitted proxies in place of IP addresses. 2021-07-12 10:32:46 +09: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()));