Skip to content

Commit

Permalink
fix(server): change remote-ip in log
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxiaohei committed Apr 30, 2024
1 parent 4816735 commit 74c06ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion land-server/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ async fn log_middleware(request: Request, next: Next) -> Result<Response, Status
return Ok(next.run(request).await);
}
let mut remote = "0.0.0.0".to_string();
if let Some(connect_info) = request.extensions().get::<ConnectInfo<SocketAddr>>() {
// if x-real-ip exists, use it
if let Some(real_ip) = request.headers().get("x-real-ip") {
remote = real_ip.to_str().unwrap().to_string();
} else if let Some(connect_info) = request.extensions().get::<ConnectInfo<SocketAddr>>() {
remote = connect_info.to_string();
}

Expand Down

0 comments on commit 74c06ed

Please sign in to comment.