Open TxMat opened 8 months ago
The IP is certainly parsed from headers, so your approach is correct. But the provided example is too complex, as usual try to maximally simplify it to locate the bug.
i'll write a fully working example at work Monday but just using this you should be able to reproduce
async fn set_ready(secure_client_ip: SecureClientIp, state: State<AppState>) -> (StatusCode, String) {
println!("client ip: {}", secure_client_ip.0); // does not output 12.12.12.12
}
// ... bind the route, create the test server using axum-test, add connexioninfo ext //
#[tokio::test]
async fn test() {
let server = setup_test_server();
server.post("/ready")
.add_header("X-Real-Ip".parse().unwrap(), "12.12.12.12".parse().unwrap())
.await;
}
Hi,
I am currently writing a program with your library but while writing test i found that it seems to be no method for forcing a wrong ip to check the behaviour of the program. is there something that i missed ? what are the solutions ?
it seems that the ip source is set to
ConnectInfo
even if a header is set(this method works for insecure client tho)