This commit is contained in:
Alexey
2026-09-25 19:46:31 +03:00
parent 2d63fcf376
commit 326c0ecdb9
128 changed files with 914 additions and 1248 deletions
+3 -6
View File
@@ -22,13 +22,13 @@ use std::sync::atomic::{AtomicBool, AtomicU8, AtomicU64, AtomicUsize, Ordering};
use std::time::Instant;
pub(crate) use self::quota_store::{QuotaReservation, QuotaStore, UserQuotaHandle};
pub(crate) use self::users::UserConnectionObservation;
#[allow(unused_imports)]
pub use self::replay::{ReplayChecker, ReplayStats};
use self::telemetry::TelemetryPolicy;
use crate::proxy::user_connection_authority::UserConnectionAuthority;
pub use self::tls_fingerprints::TlsFingerprintSnapshotRow;
pub(crate) use self::users::UserConnectionObservation;
use crate::config::MeWriterPickMode;
use crate::proxy::user_connection_authority::UserConnectionAuthority;
const ME_HANDSHAKE_ERROR_CODE_MAX: usize = 64;
@@ -432,10 +432,7 @@ impl Stats {
#[cfg(test)]
pub(crate) fn with_quota_store(quota_store: Arc<QuotaStore>) -> Self {
Self::with_process_authorities(
quota_store,
Arc::new(UserConnectionAuthority::default()),
)
Self::with_process_authorities(quota_store, Arc::new(UserConnectionAuthority::default()))
}
/// Creates generation telemetry around process-owned enforcement authorities.
+1 -5
View File
@@ -146,11 +146,7 @@ impl QuotaStore {
}
/// Advances a credential incarnation while preserving usage captured at the transition.
pub(crate) fn advance_preserving_usage(
&self,
user: &str,
incarnation: UserIncarnation,
) {
pub(crate) fn advance_preserving_usage(&self, user: &str, incarnation: UserIncarnation) {
let slot = self.slot(user);
let mut state = slot.state.lock();
if incarnation <= state.high_water {
+1 -1
View File
@@ -1,6 +1,6 @@
use std::borrow::Borrow;
use std::collections::{HashMap, VecDeque};
use std::collections::hash_map::DefaultHasher;
use std::collections::{HashMap, VecDeque};
use std::hash::{Hash, Hasher};
use std::num::NonZeroUsize;
use std::sync::Arc;
+13 -12
View File
@@ -17,26 +17,27 @@ fn test_stats_shared_counters() {
fn runtime_stats_share_process_connection_admission_authority() {
let quota_store = Arc::new(QuotaStore::default());
let authority = Arc::new(UserConnectionAuthority::default());
let first = Stats::with_process_authorities(
Arc::clone(&quota_store),
Arc::clone(&authority),
);
let first = Stats::with_process_authorities(Arc::clone(&quota_store), Arc::clone(&authority));
let second = Stats::with_process_authorities(quota_store, authority);
let permit = first
.connection_authority()
.try_acquire("alice", Some(1))
.unwrap();
assert!(second
.connection_authority()
.try_acquire("alice", Some(1))
.is_none());
assert!(
second
.connection_authority()
.try_acquire("alice", Some(1))
.is_none()
);
drop(permit);
assert!(second
.connection_authority()
.try_acquire("alice", Some(1))
.is_some());
assert!(
second
.connection_authority()
.try_acquire("alice", Some(1))
.is_some()
);
}
#[test]
+1 -2
View File
@@ -350,8 +350,7 @@ impl TlsFingerprintCollector {
let mut removed = 0usize;
self.entries.retain(|_, entry| {
let last_seen = entry.last_seen_epoch_secs.load(Ordering::Relaxed);
let retained =
ttl_secs != 0 && now_epoch_secs.saturating_sub(last_seen) <= ttl_secs;
let retained = ttl_secs != 0 && now_epoch_secs.saturating_sub(last_seen) <= ttl_secs;
if !retained {
removed += 1;
}