mirror of
https://github.com/icewind1991/warp-real-ip.git
synced 2026-06-04 03:04:06 +02:00
support nested proxies
This commit is contained in:
parent
14e7393db6
commit
a04638e1f6
2 changed files with 51 additions and 14 deletions
|
|
@ -39,3 +39,25 @@ async fn test_trusted() {
|
|||
.await;
|
||||
assert_eq!(res.body(), "10.10.10.10");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_nested_denied() {
|
||||
let remote: IpAddr = [1, 2, 3, 4].into();
|
||||
let res = warp::test::request()
|
||||
.remote_addr((remote, 80).into())
|
||||
.header("x-forwarded-for", "10.10.10.10, 11.11.11.11")
|
||||
.reply(&serve(vec![remote]))
|
||||
.await;
|
||||
assert_eq!(res.body(), "11.11.11.11");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_nested_allowed() {
|
||||
let remote: IpAddr = [1, 2, 3, 4].into();
|
||||
let res = warp::test::request()
|
||||
.remote_addr((remote, 80).into())
|
||||
.header("x-forwarded-for", "10.10.10.10, 11.11.11.11")
|
||||
.reply(&serve(vec![remote, [10, 10, 10, 10].into()]))
|
||||
.await;
|
||||
assert_eq!(res.body(), "11.11.11.11");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue