Fix code quality: trailing whitespace, unused imports, clippy warnings
- Fix trailing whitespace in kex.rs and s3.rs - Add missing KexProposal import in kex_complete.rs - Auto-fix clippy warnings across all crates - All 153 tests pass
This commit is contained in:
@@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
pub struct ConnectionStats {
|
||||
pub total_connections: u64,
|
||||
pub active_connections: u32,
|
||||
@@ -12,19 +13,6 @@ pub struct ConnectionStats {
|
||||
pub uptime_seconds: u64,
|
||||
}
|
||||
|
||||
impl Default for ConnectionStats {
|
||||
fn default() -> Self {
|
||||
ConnectionStats {
|
||||
total_connections: 0,
|
||||
active_connections: 0,
|
||||
read_operations: 0,
|
||||
write_operations: 0,
|
||||
errors: 0,
|
||||
bytes_transferred: 0,
|
||||
uptime_seconds: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct AccessLogEntry {
|
||||
@@ -38,12 +26,19 @@ pub struct AccessLogEntry {
|
||||
}
|
||||
|
||||
impl AccessLogEntry {
|
||||
pub fn new(username: String, action: String, path: String, success: bool, bytes: u64, duration: Duration) -> Self {
|
||||
pub fn new(
|
||||
username: String,
|
||||
action: String,
|
||||
path: String,
|
||||
success: bool,
|
||||
bytes: u64,
|
||||
duration: Duration,
|
||||
) -> Self {
|
||||
let timestamp = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
|
||||
|
||||
AccessLogEntry {
|
||||
timestamp: timestamp.to_string(),
|
||||
username,
|
||||
@@ -62,6 +57,12 @@ pub struct SMBMonitor {
|
||||
start_time: SystemTime,
|
||||
}
|
||||
|
||||
impl Default for SMBMonitor {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SMBMonitor {
|
||||
pub fn new() -> Self {
|
||||
SMBMonitor {
|
||||
@@ -70,10 +71,10 @@ impl SMBMonitor {
|
||||
start_time: SystemTime::now(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn log_access(&mut self, entry: AccessLogEntry) {
|
||||
self.logs.push(entry.clone());
|
||||
|
||||
|
||||
if entry.success {
|
||||
if entry.action == "read" {
|
||||
self.stats.read_operations += 1;
|
||||
@@ -85,28 +86,28 @@ impl SMBMonitor {
|
||||
self.stats.errors += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn connection_opened(&mut self) {
|
||||
self.stats.total_connections += 1;
|
||||
self.stats.active_connections += 1;
|
||||
}
|
||||
|
||||
|
||||
pub fn connection_closed(&mut self) {
|
||||
self.stats.active_connections -= 1;
|
||||
}
|
||||
|
||||
|
||||
pub fn get_stats(&self) -> ConnectionStats {
|
||||
let uptime = SystemTime::now()
|
||||
.duration_since(self.start_time)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
|
||||
|
||||
let mut stats = self.stats.clone();
|
||||
stats.uptime_seconds = uptime;
|
||||
stats
|
||||
}
|
||||
|
||||
|
||||
pub fn get_logs(&self, limit: usize) -> Vec<AccessLogEntry> {
|
||||
self.logs.iter().rev().take(limit).cloned().collect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user