diff --git a/src/metrics.rs b/src/metrics.rs index 4f4c317..4c03dc2 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -449,6 +449,21 @@ async fn render_metrics(stats: &Stats, config: &ProxyConfig, ip_tracker: &UserIp } ); + let _ = writeln!( + out, + "# HELP telemt_me_kdf_port_only_drift_total ME KDF client-port changes with stable non-port material" + ); + let _ = writeln!(out, "# TYPE telemt_me_kdf_port_only_drift_total counter"); + let _ = writeln!( + out, + "telemt_me_kdf_port_only_drift_total {}", + if me_allows_debug { + stats.get_me_kdf_port_only_drift_total() + } else { + 0 + } + ); + let _ = writeln!( out, "# HELP telemt_me_hardswap_pending_reuse_total Hardswap cycles that reused an existing pending generation" @@ -587,6 +602,24 @@ async fn render_metrics(stats: &Stats, config: &ProxyConfig, ip_tracker: &UserIp } ); + let _ = writeln!( + out, + "# HELP telemt_me_single_endpoint_shadow_rotate_skipped_quarantine_total Shadow rotations skipped because endpoint is quarantined" + ); + let _ = writeln!( + out, + "# TYPE telemt_me_single_endpoint_shadow_rotate_skipped_quarantine_total counter" + ); + let _ = writeln!( + out, + "telemt_me_single_endpoint_shadow_rotate_skipped_quarantine_total {}", + if me_allows_normal { + stats.get_me_single_endpoint_shadow_rotate_skipped_quarantine_total() + } else { + 0 + } + ); + let _ = writeln!(out, "# HELP telemt_secure_padding_invalid_total Invalid secure frame lengths"); let _ = writeln!(out, "# TYPE telemt_secure_padding_invalid_total counter"); let _ = writeln!( @@ -679,7 +712,7 @@ async fn render_metrics(stats: &Stats, config: &ProxyConfig, ip_tracker: &UserIp let _ = writeln!( out, "telemt_pool_swap_total {}", - if me_allows_debug { + if me_allows_normal { stats.get_pool_swap_total() } else { 0 diff --git a/src/stats/mod.rs b/src/stats/mod.rs index 5b2bb94..57b732d 100644 --- a/src/stats/mod.rs +++ b/src/stats/mod.rs @@ -38,6 +38,7 @@ pub struct Stats { me_seq_mismatch: AtomicU64, me_endpoint_quarantine_total: AtomicU64, me_kdf_drift_total: AtomicU64, + me_kdf_port_only_drift_total: AtomicU64, me_hardswap_pending_reuse_total: AtomicU64, me_hardswap_pending_ttl_expired_total: AtomicU64, me_single_endpoint_outage_enter_total: AtomicU64, @@ -46,6 +47,7 @@ pub struct Stats { me_single_endpoint_outage_reconnect_success_total: AtomicU64, me_single_endpoint_quarantine_bypass_total: AtomicU64, me_single_endpoint_shadow_rotate_total: AtomicU64, + me_single_endpoint_shadow_rotate_skipped_quarantine_total: AtomicU64, me_handshake_error_codes: DashMap, me_route_drop_no_conn: AtomicU64, me_route_drop_channel_closed: AtomicU64, @@ -290,7 +292,7 @@ impl Stats { } } pub fn increment_pool_swap_total(&self) { - if self.telemetry_me_allows_debug() { + if self.telemetry_me_allows_normal() { self.pool_swap_total.fetch_add(1, Ordering::Relaxed); } } @@ -377,6 +379,12 @@ impl Stats { self.me_kdf_drift_total.fetch_add(1, Ordering::Relaxed); } } + pub fn increment_me_kdf_port_only_drift_total(&self) { + if self.telemetry_me_allows_debug() { + self.me_kdf_port_only_drift_total + .fetch_add(1, Ordering::Relaxed); + } + } pub fn increment_me_hardswap_pending_reuse_total(&self) { if self.telemetry_me_allows_debug() { self.me_hardswap_pending_reuse_total @@ -425,6 +433,12 @@ impl Stats { .fetch_add(1, Ordering::Relaxed); } } + pub fn increment_me_single_endpoint_shadow_rotate_skipped_quarantine_total(&self) { + if self.telemetry_me_allows_normal() { + self.me_single_endpoint_shadow_rotate_skipped_quarantine_total + .fetch_add(1, Ordering::Relaxed); + } + } pub fn get_connects_all(&self) -> u64 { self.connects_all.load(Ordering::Relaxed) } pub fn get_connects_bad(&self) -> u64 { self.connects_bad.load(Ordering::Relaxed) } pub fn get_me_keepalive_sent(&self) -> u64 { self.me_keepalive_sent.load(Ordering::Relaxed) } @@ -447,6 +461,9 @@ impl Stats { pub fn get_me_kdf_drift_total(&self) -> u64 { self.me_kdf_drift_total.load(Ordering::Relaxed) } + pub fn get_me_kdf_port_only_drift_total(&self) -> u64 { + self.me_kdf_port_only_drift_total.load(Ordering::Relaxed) + } pub fn get_me_hardswap_pending_reuse_total(&self) -> u64 { self.me_hardswap_pending_reuse_total .load(Ordering::Relaxed) @@ -479,6 +496,10 @@ impl Stats { self.me_single_endpoint_shadow_rotate_total .load(Ordering::Relaxed) } + pub fn get_me_single_endpoint_shadow_rotate_skipped_quarantine_total(&self) -> u64 { + self.me_single_endpoint_shadow_rotate_skipped_quarantine_total + .load(Ordering::Relaxed) + } pub fn get_me_handshake_error_code_counts(&self) -> Vec<(i32, u64)> { let mut out: Vec<(i32, u64)> = self .me_handshake_error_codes