mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
udp: use prettier formatting for html peer client count output
This commit is contained in:
parent
47b45f28d5
commit
467f75e1fb
3 changed files with 14 additions and 9 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -220,7 +220,6 @@ dependencies = [
|
||||||
"aquatic_udp_protocol",
|
"aquatic_udp_protocol",
|
||||||
"blake3",
|
"blake3",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"compact_str",
|
|
||||||
"constant_time_eq",
|
"constant_time_eq",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ aquatic_udp_protocol.workspace = true
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
blake3 = "1"
|
blake3 = "1"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
compact_str = { version = "0.7", features = ["serde"] }
|
|
||||||
constant_time_eq = "0.2"
|
constant_time_eq = "0.2"
|
||||||
crossbeam-channel = "0.5"
|
crossbeam-channel = "0.5"
|
||||||
getrandom = "0.2"
|
getrandom = "0.2"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ use std::time::{Duration, Instant};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use aquatic_common::{IndexMap, PanicSentinel};
|
use aquatic_common::{IndexMap, PanicSentinel};
|
||||||
use aquatic_udp_protocol::PeerClient;
|
use aquatic_udp_protocol::PeerClient;
|
||||||
use compact_str::{CompactString, ToCompactString};
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
|
use num_format::{Locale, ToFormattedString};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use time::format_description::well_known::Rfc2822;
|
use time::format_description::well_known::Rfc2822;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
|
@ -37,7 +37,7 @@ struct TemplateData {
|
||||||
ipv6: CollectedStatistics,
|
ipv6: CollectedStatistics,
|
||||||
last_updated: String,
|
last_updated: String,
|
||||||
peer_update_interval: String,
|
peer_update_interval: String,
|
||||||
peer_clients: Vec<(CompactString, usize)>,
|
peer_clients: Vec<(String, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_statistics_worker(
|
pub fn run_statistics_worker(
|
||||||
|
|
@ -155,15 +155,22 @@ pub fn run_statistics_worker(
|
||||||
|
|
||||||
if let Some(tt) = opt_tt.as_ref() {
|
if let Some(tt) = opt_tt.as_ref() {
|
||||||
let mut peer_clients = if config.statistics.extended {
|
let mut peer_clients = if config.statistics.extended {
|
||||||
peer_clients
|
peer_clients.iter().collect()
|
||||||
.iter()
|
|
||||||
.map(|(peer_client, count)| (peer_client.to_compact_string(), *count))
|
|
||||||
.collect()
|
|
||||||
} else {
|
} else {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
peer_clients.sort_unstable_by(|a, b| b.1.cmp(&a.1));
|
peer_clients.sort_unstable_by(|a, b| b.1.cmp(a.1));
|
||||||
|
|
||||||
|
let peer_clients = peer_clients
|
||||||
|
.into_iter()
|
||||||
|
.map(|(peer_client, count)| {
|
||||||
|
(
|
||||||
|
peer_client.to_string(),
|
||||||
|
count.to_formatted_string(&Locale::en),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let template_data = TemplateData {
|
let template_data = TemplateData {
|
||||||
stylesheet: STYLESHEET_CONTENTS.to_string(),
|
stylesheet: STYLESHEET_CONTENTS.to_string(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue