warp-real-ip

Crates.iowarp-real-ip
lib.rswarp-real-ip
version0.2.0
sourcesrc
created_at2020-12-03 15:42:16.661617
updated_at2021-01-20 16:30:28.409174
descriptionWarp filter to get the "real ip" of the remote client
homepage
repositoryhttps://github.com/icewind1991/warp-real-ip
max_upload_size
id319308
size8,456
Robin Appelman (icewind1991)

documentation

https://docs.rs/warp-real-ip

README

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()));
Commit count: 25

cargo fmt