#warp #real #ip #filter #remote #client #forwarded

warp-real-ip

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

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

Download history 43/week @ 2024-07-21 91/week @ 2024-07-28 16/week @ 2024-08-04 45/week @ 2024-08-11 7/week @ 2024-08-18 20/week @ 2024-08-25 12/week @ 2024-09-01 10/week @ 2024-09-08 36/week @ 2024-09-22 34/week @ 2024-09-29 24/week @ 2024-10-06 45/week @ 2024-10-13 2/week @ 2024-10-20 12/week @ 2024-10-27 93/week @ 2024-11-03

154 downloads per month
Used in webb-relayer

MIT/Apache

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