1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 13:29:21 +00:00

Start to extract remote IP address

This commit is contained in:
Pierre HUBERT 2021-01-23 08:19:10 +01:00
parent ebc5ebea2a
commit 82fcd95fd3
2 changed files with 13 additions and 3 deletions

View File

@ -254,7 +254,8 @@ async fn process_request(custom_req: CustomRequest) -> HttpResponse {
request.internal_error(e).unwrap_err();
}
println!("{} - {} - {}",
println!("{} - {} - {} - {}",
request.remote_ip(),
request.response_status_code(),
request.request_path(),
err_msg
@ -267,7 +268,11 @@ async fn process_request(custom_req: CustomRequest) -> HttpResponse {
request.success("Success").unwrap()
}
println!("{} - {}", request.response_status_code(), request.request_path());
println!("{} - {} - {}",
request.remote_ip(),
request.response_status_code(),
request.request_path()
);
}
}

View File

@ -192,6 +192,11 @@ impl HttpRequestHandler {
self.client.as_ref().unwrap()
}
/// Get the remote IP address
pub fn remote_ip(&self) -> String {
self.request.peer_addr().unwrap().ip().to_string()
}
/// Check if a POST parameter was present in the request or not
pub fn has_post_parameter(&self, name: &str) -> bool {
self.body.contains_key(name)
@ -690,7 +695,7 @@ impl HttpRequestHandler {
let info = self.ok_or_not_found(
custom_emojies_helper::get_single(emoji_id),
"Requested emoji not found!"
"Requested emoji not found!",
)?;
if &info.user_id != self.user_id_ref()? {