Merge pull request #1 from Moepchi/fix/pr-4-review-bugs

Fix 8 correctness bugs found in review of TeaSpeak/GTS + multi-join PR
This commit is contained in:
Nico B. authored and GitHub committed 2026-09-06 01:20:59 +02:00
commit a118c0f58e
4 files changed
+93 -20

No files matched your search

+14 -9
View File
@@ -574,9 +574,8 @@ fn snapshot(con: &data::Connection) -> Event {
})
.collect::<Vec<_>>();
// Bookkeeping includes ServerQuery clients (`ClientType::Query`); hide them
// from the channel tree / client lists. Online counters still use the
// server-reported total (often includes Query) via `client_count` below.
let all_clients_count = con.clients.len() as u16;
// from the channel tree / client lists, and from the online-count fallback
// below too, so the number shown never counts a client the list doesn't.
let clients = con
.clients
.values()
@@ -611,12 +610,13 @@ fn snapshot(con: &data::Connection) -> Event {
.collect::<Vec<_>>();
// Prefer server-reported counters (GTS/TS `virtualserver_*` via notifyserverupdated)
// but never under-report vs. the full bookkeeping client set including Query
// (stale optional_data after joins would otherwise freeze the InfoPanel left number).
// but never under-report vs. the visible (non-Query) client set (stale
// optional_data after joins would otherwise freeze the InfoPanel left number).
let opt = con.server.optional_data.as_ref();
let visible_channels = channels.len() as u64;
let visible_clients_count = clients.len() as u16;
let server_clients_online =
opt.map(|d| d.client_count.max(all_clients_count)).unwrap_or(all_clients_count);
opt.map(|d| d.client_count.max(visible_clients_count)).unwrap_or(visible_clients_count);
let server_channels_online =
opt.map(|d| d.channel_count.max(visible_channels)).unwrap_or(visible_channels);
@@ -2150,10 +2150,15 @@ async fn run(args: Args) -> Result<()> {
}
}
if pending_server_conninfo {
if let Some(data) = &con.get_state()?.server.connection_data {
// TeaSpeak/TS may report packet loss as a fraction (0–1) or percent.
let state = con.get_state()?;
// GreenTeaSpeak reports packet loss already as a percent; classic
// TeamSpeak3/TeaSpeak report it as a fraction (0-1). A value's magnitude
// alone can't disambiguate a healthy GTS server (e.g. 0.5%) from a bad
// TS3 one (e.g. 0.5 = 50%), so branch on the actual server type instead.
let is_gts = is_greenteaspeak_server_version(&state.server.version);
if let Some(data) = &state.server.connection_data {
let loss = data.packetloss_total;
let packet_loss_percent = if loss <= 1.0 { loss * 100.0 } else { loss };
let packet_loss_percent = if is_gts { loss } else { loss * 100.0 };
emit(&Event::ServerConnectionInfo {
ping_ms: data.ping.as_seconds_f64() * 1000.0,
connected_secs: data.connected_time_total.whole_seconds(),