mirror of
https://github.com/icewind1991/warp-real-ip.git
synced 2026-06-03 18:54:06 +02:00
Allow specifying IP networks for permitted proxies in place of IP addresses.
This commit is contained in:
parent
75a2f210c9
commit
c6af4e7ae9
4 changed files with 45 additions and 5 deletions
|
|
@ -1,10 +1,10 @@
|
|||
use std::net::IpAddr;
|
||||
use warp::Filter;
|
||||
use warp_real_ip::real_ip;
|
||||
use warp_real_ip::{IpNetworks, real_ip};
|
||||
|
||||
fn serve<'a>(trusted: Vec<IpAddr>) -> impl Filter<Extract = (String,)> + 'a {
|
||||
warp::any()
|
||||
.and(real_ip(trusted))
|
||||
.and(real_ip(IpNetworks::from_ipaddr_iter(trusted.iter())))
|
||||
.map(|addr: Option<IpAddr>| addr.unwrap().to_string())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue