server: misc changes for traces
This commit is contained in:
@@ -4,6 +4,7 @@ use nix::unistd::{Group as LibcGroup, User as LibcUser};
|
|||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
pub const DEFAULT_CONFIG_PATH: &str = "/etc/muscl/config.toml";
|
pub const DEFAULT_CONFIG_PATH: &str = "/etc/muscl/config.toml";
|
||||||
pub const DEFAULT_SOCKET_PATH: &str = "/run/muscl/muscl.sock";
|
pub const DEFAULT_SOCKET_PATH: &str = "/run/muscl/muscl.sock";
|
||||||
@@ -24,6 +25,12 @@ pub struct UnixUser {
|
|||||||
pub groups: Vec<String>,
|
pub groups: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for UnixUser {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(&self.username)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: these functions are somewhat critical, and should have integration tests
|
// TODO: these functions are somewhat critical, and should have integration tests
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ pub async fn handle_command(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if auto_detected_systemd_mode {
|
if auto_detected_systemd_mode {
|
||||||
tracing::info!("Running in systemd mode, auto-detected");
|
tracing::debug!("Running in systemd mode, auto-detected");
|
||||||
} else {
|
} else {
|
||||||
tracing::info!("Running in systemd mode");
|
tracing::debug!("Running in systemd mode");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let subscriber = tracing_subscriber::Registry::default()
|
let subscriber = tracing_subscriber::Registry::default()
|
||||||
@@ -111,7 +111,7 @@ pub async fn handle_command(
|
|||||||
|
|
||||||
trace_server_prelude();
|
trace_server_prelude();
|
||||||
|
|
||||||
tracing::info!("Running in standalone mode");
|
tracing::debug!("Running in standalone mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
let config_path = config_path.unwrap_or_else(|| PathBuf::from(DEFAULT_CONFIG_PATH));
|
let config_path = config_path.unwrap_or_else(|| PathBuf::from(DEFAULT_CONFIG_PATH));
|
||||||
|
|||||||
@@ -77,7 +77,13 @@ pub async fn session_handler(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
session_handler_with_unix_user(socket, &unix_user, db_pool).await
|
tracing::info!("Accepted connection from user: {}", unix_user);
|
||||||
|
|
||||||
|
let result = session_handler_with_unix_user(socket, &unix_user, db_pool).await;
|
||||||
|
|
||||||
|
tracing::info!("Finished handling requests for connection from user: {}", unix_user);
|
||||||
|
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn session_handler_with_unix_user(
|
pub async fn session_handler_with_unix_user(
|
||||||
@@ -143,7 +149,12 @@ async fn session_handler_with_db_connection(
|
|||||||
}
|
}
|
||||||
request => request.to_owned(),
|
request => request.to_owned(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if request_to_display != Request::Exit {
|
||||||
tracing::info!("Received request: {:#?}", request_to_display);
|
tracing::info!("Received request: {:#?}", request_to_display);
|
||||||
|
} else {
|
||||||
|
tracing::debug!("Received request: {:#?}", request_to_display);
|
||||||
|
}
|
||||||
|
|
||||||
let response = match request {
|
let response = match request {
|
||||||
Request::CheckAuthorization(dbs_or_users) => {
|
Request::CheckAuthorization(dbs_or_users) => {
|
||||||
@@ -237,7 +248,7 @@ async fn session_handler_with_db_connection(
|
|||||||
}
|
}
|
||||||
response => response.to_owned(),
|
response => response.to_owned(),
|
||||||
};
|
};
|
||||||
tracing::info!("Response: {:#?}", response_to_display);
|
tracing::debug!("Response: {:#?}", response_to_display);
|
||||||
|
|
||||||
stream.send(response).await?;
|
stream.send(response).await?;
|
||||||
stream.flush().await?;
|
stream.flush().await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user