#warp #real #ip #filter #remote #client #header

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

#1271 in HTTP server

Download history 14/week @ 2024-08-31 10/week @ 2024-09-07 1/week @ 2024-09-14 27/week @ 2024-09-21 40/week @ 2024-09-28 25/week @ 2024-10-05 46/week @ 2024-10-12 3/week @ 2024-10-19 11/week @ 2024-10-26 84/week @ 2024-11-02 33/week @ 2024-11-09 17/week @ 2024-11-16 8/week @ 2024-11-23 34/week @ 2024-11-30 39/week @ 2024-12-07 17/week @ 2024-12-14

99 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
~247K SLoC