summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2020-06-20 11:01:55 -0700
committerStuart Stock <stuart@int08h.com>2020-06-20 11:01:55 -0700
commitcb8c8fefd914b2c8a466f240db7f48e8951ab0bb (patch)
treee19aa4aa0e1f10f11dd7e47c523113330482da57
parent76c4af584837416411b1941e78e95538f2549697 (diff)
downloadroughenough-cb8c8fefd914b2c8a466f240db7f48e8951ab0bb.zip
stats: display clients sorted by number of valid requests
-rw-r--r--src/server.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server.rs b/src/server.rs
index ad08ff0..6e549b0 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -18,7 +18,7 @@
use hex;
use std::io::ErrorKind;
-use std::net::SocketAddr;
+use std::net::{SocketAddr, IpAddr};
use std::process;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
@@ -40,7 +40,7 @@ use crate::grease::Grease;
use crate::key::{LongTermKey, OnlineKey};
use crate::kms;
use crate::merkle::MerkleTree;
-use crate::stats::{AggregatedStats, PerClientStats, ServerStats};
+use crate::stats::{AggregatedStats, PerClientStats, ServerStats, ClientStatEntry};
macro_rules! check_ctrlc {
($keep_running:expr) => {
@@ -273,7 +273,10 @@ impl Server {
}
STATUS => {
- for (addr, counts) in self.stats.iter() {
+ let mut vec: Vec<(&IpAddr, &ClientStatEntry)> = self.stats.iter().collect();
+ vec.sort_by(|lhs, rhs| lhs.1.valid_requests.cmp(&rhs.1.valid_requests));
+
+ for (addr, counts) in vec {
info!(
"{:16}: {} valid, {} invalid requests; {} responses ({} sent)",
format!("{}", addr), counts.valid_requests, counts.invalid_requests,