Refactor.

This commit is contained in:
Moriyoshi Koizumi 2021-07-14 18:52:28 +09:00
commit 6825c6da12
2 changed files with 12 additions and 3 deletions

View file

@ -1,10 +1,10 @@
use std::net::IpAddr;
use warp::Filter;
use warp_real_ip::{IpNetworks, real_ip};
use warp_real_ip::real_ip;
fn serve<'a>(trusted: Vec<IpAddr>) -> impl Filter<Extract = (String,)> + 'a {
warp::any()
.and(real_ip(IpNetworks::from_ipaddr_iter(trusted.iter())))
.and(real_ip((&trusted).into()))
.map(|addr: Option<IpAddr>| addr.unwrap().to_string())
}