fix: disable logging of ip
This commit is contained in:
parent
6f61bda344
commit
8afedcb885
61
src/main.rs
61
src/main.rs
@ -34,38 +34,39 @@ async fn word() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn log_ip(req: Request<Body>, next: Next) -> Response {
|
async fn log_ip(req: Request<Body>, next: Next) -> Response {
|
||||||
let mut head = "REMOTE_ADDR";
|
// let mut head = "REMOTE_ADDR";
|
||||||
let ip = req
|
// let ip = req
|
||||||
.headers()
|
// .headers()
|
||||||
.get(head)
|
// .get(head)
|
||||||
.and_then(|hv| hv.to_str().ok())
|
// .and_then(|hv| hv.to_str().ok())
|
||||||
.or_else(|| {
|
// .or_else(|| {
|
||||||
head = "HTTP_CLIENT_IP";
|
// head = "HTTP_CLIENT_IP";
|
||||||
req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
// req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
||||||
})
|
// })
|
||||||
.or_else(|| {
|
// .or_else(|| {
|
||||||
head = "x-real-ip";
|
// head = "x-real-ip";
|
||||||
req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
// req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
||||||
})
|
// })
|
||||||
.or_else(|| {
|
// .or_else(|| {
|
||||||
head = "cf-connection-ip";
|
// head = "cf-connection-ip";
|
||||||
req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
// req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
||||||
})
|
// })
|
||||||
.or_else(|| {
|
// .or_else(|| {
|
||||||
head = "HTTP_X_FORWARDED_FOR";
|
// head = "HTTP_X_FORWARDED_FOR";
|
||||||
req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
// req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
||||||
})
|
// })
|
||||||
.or_else(|| {
|
// .or_else(|| {
|
||||||
head = "HTTP_FORWARDED_FOR";
|
// head = "HTTP_FORWARDED_FOR";
|
||||||
req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
// req.headers().get(head).and_then(|hv| hv.to_str().ok())
|
||||||
})
|
// })
|
||||||
.unwrap_or("Unknown");
|
// .unwrap_or("Unknown");
|
||||||
|
|
||||||
if format!("{ip}") == "Unknown" {
|
// if format!("{ip}") == "Unknown" {
|
||||||
head = "none"
|
// 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
|
next.run(req).await
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user