Skip to content

Commit

Permalink
Make BloomTokenLog the default TokenLog
Browse files Browse the repository at this point in the history
Unless the fastbloom feature is disabled, in which case it still falls
back to NoneTokenLog.
  • Loading branch information
gretchenfrage committed Jan 26, 2025
1 parent fb6cd92 commit f96e7c5
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions quinn-proto/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ use thiserror::Error;

#[cfg(any(feature = "rustls-aws-lc-rs", feature = "rustls-ring"))]
use crate::crypto::rustls::{configured_provider, QuicServerConfig};
#[cfg(feature = "fastbloom")]
use crate::BloomTokenLog;
#[cfg(not(feature = "fastbloom"))]
use crate::NoneTokenLog;
use crate::{
cid_generator::{ConnectionIdGenerator, HashedConnectionIdGenerator},
crypto::{self, HandshakeTokenKey, HmacKey},
shared::ConnectionId,
Duration, NoneTokenLog, NoneTokenStore, RandomConnectionIdGenerator, SystemTime, TokenLog,
TokenStore, VarInt, VarIntBoundsExceeded, DEFAULT_SUPPORTED_VERSIONS, MAX_CID_SIZE,
Duration, NoneTokenStore, RandomConnectionIdGenerator, SystemTime, TokenLog, TokenStore,
VarInt, VarIntBoundsExceeded, DEFAULT_SUPPORTED_VERSIONS, MAX_CID_SIZE,
};

mod transport;
Expand Down Expand Up @@ -487,8 +491,12 @@ impl ValidationTokenConfig {

/// Set a custom [`TokenLog`]
///
/// Defaults to [`NoneTokenLog`], which makes the server ignore all address validation tokens
/// (that is, tokens originating from NEW_TOKEN frames--retry tokens are not affected).
/// If the `fastbloom` feature is enabled (which it is by default), defaults to a default
/// [`BloomTokenLog`], which is suitable for most internet applications.
///
/// If the `fastbloom` feature is disabled, defaults to [`NoneTokenLog`], which makes the
/// server ignore all address validation tokens (that is, tokens originating from NEW_TOKEN
/// frames--retry tokens are not affected).
pub fn log(&mut self, log: Arc<dyn TokenLog>) -> &mut Self {
self.log = log;
self
Expand All @@ -507,9 +515,13 @@ impl ValidationTokenConfig {

impl Default for ValidationTokenConfig {
fn default() -> Self {
#[cfg(feature = "fastbloom")]
let log = Arc::new(BloomTokenLog::default());
#[cfg(not(feature = "fastbloom"))]
let log = Arc::new(NoneTokenLog);
Self {
lifetime: Duration::from_secs(2 * 7 * 24 * 60 * 60),
log: Arc::new(NoneTokenLog),
log,
sent: 0,
}
}
Expand Down

0 comments on commit f96e7c5

Please sign in to comment.