From 8afedcb8857262b136e30fb211737ffd10ea5706 Mon Sep 17 00:00:00 2001 From: itsscb Date: Sun, 25 Aug 2024 21:19:30 +0200 Subject: [PATCH] fix: disable logging of ip --- src/main.rs | 61 +++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8da0dc2..15dd2ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,38 +34,39 @@ async fn word() -> String { } async fn log_ip(req: Request, next: Next) -> Response { - let mut head = "REMOTE_ADDR"; - let ip = req - .headers() - .get(head) - .and_then(|hv| hv.to_str().ok()) - .or_else(|| { - head = "HTTP_CLIENT_IP"; - req.headers().get(head).and_then(|hv| hv.to_str().ok()) - }) - .or_else(|| { - head = "x-real-ip"; - req.headers().get(head).and_then(|hv| hv.to_str().ok()) - }) - .or_else(|| { - head = "cf-connection-ip"; - req.headers().get(head).and_then(|hv| hv.to_str().ok()) - }) - .or_else(|| { - head = "HTTP_X_FORWARDED_FOR"; - req.headers().get(head).and_then(|hv| hv.to_str().ok()) - }) - .or_else(|| { - head = "HTTP_FORWARDED_FOR"; - req.headers().get(head).and_then(|hv| hv.to_str().ok()) - }) - .unwrap_or("Unknown"); + // let mut head = "REMOTE_ADDR"; + // let ip = req + // .headers() + // .get(head) + // .and_then(|hv| hv.to_str().ok()) + // .or_else(|| { + // head = "HTTP_CLIENT_IP"; + // req.headers().get(head).and_then(|hv| hv.to_str().ok()) + // }) + // .or_else(|| { + // head = "x-real-ip"; + // req.headers().get(head).and_then(|hv| hv.to_str().ok()) + // }) + // .or_else(|| { + // head = "cf-connection-ip"; + // req.headers().get(head).and_then(|hv| hv.to_str().ok()) + // }) + // .or_else(|| { + // head = "HTTP_X_FORWARDED_FOR"; + // req.headers().get(head).and_then(|hv| hv.to_str().ok()) + // }) + // .or_else(|| { + // head = "HTTP_FORWARDED_FOR"; + // req.headers().get(head).and_then(|hv| hv.to_str().ok()) + // }) + // .unwrap_or("Unknown"); - if format!("{ip}") == "Unknown" { - head = "none" - } + // if format!("{ip}") == "Unknown" { + // head = "none" + // } - info!(PATH = req.uri().path().to_string(), IP = ip, HEADER = head); + // info!(PATH = req.uri().path().to_string(), IP = ip); + info!(PATH = req.uri().path().to_string()); next.run(req).await }