diff --git a/src/main.rs b/src/main.rs index 06e3741..f6a1edb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,9 +84,9 @@ fn get_remote_ip(req: &HttpRequest, args: &Args) -> String { let mut ip = req.peer_addr().unwrap().ip().to_string(); // We check if the request comes from a trusted reverse proxy - if let Some(proxy) = args.proxy_ip.as_ref() { - if match_ip(proxy, &ip) { - if let Some(header) = req.headers().get("X-Forwarded-For") { + if let Some(proxy) = args.proxy_ip.as_ref() + && match_ip(proxy, &ip) + && let Some(header) = req.headers().get("X-Forwarded-For") { let header: Vec = header .to_str() .unwrap() @@ -98,8 +98,6 @@ fn get_remote_ip(req: &HttpRequest, args: &Args) -> String { ip = header[0].to_string(); } } - } - } ip }