Skip to content

Commit f96e7c5

Browse files
committed
Make BloomTokenLog the default TokenLog
Unless the fastbloom feature is disabled, in which case it still falls back to NoneTokenLog.
1 parent fb6cd92 commit f96e7c5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

quinn-proto/src/config/mod.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ use thiserror::Error;
1313

1414
#[cfg(any(feature = "rustls-aws-lc-rs", feature = "rustls-ring"))]
1515
use crate::crypto::rustls::{configured_provider, QuicServerConfig};
16+
#[cfg(feature = "fastbloom")]
17+
use crate::BloomTokenLog;
18+
#[cfg(not(feature = "fastbloom"))]
19+
use crate::NoneTokenLog;
1620
use crate::{
1721
cid_generator::{ConnectionIdGenerator, HashedConnectionIdGenerator},
1822
crypto::{self, HandshakeTokenKey, HmacKey},
1923
shared::ConnectionId,
20-
Duration, NoneTokenLog, NoneTokenStore, RandomConnectionIdGenerator, SystemTime, TokenLog,
21-
TokenStore, VarInt, VarIntBoundsExceeded, DEFAULT_SUPPORTED_VERSIONS, MAX_CID_SIZE,
24+
Duration, NoneTokenStore, RandomConnectionIdGenerator, SystemTime, TokenLog, TokenStore,
25+
VarInt, VarIntBoundsExceeded, DEFAULT_SUPPORTED_VERSIONS, MAX_CID_SIZE,
2226
};
2327

2428
mod transport;
@@ -487,8 +491,12 @@ impl ValidationTokenConfig {
487491

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

508516
impl Default for ValidationTokenConfig {
509517
fn default() -> Self {
518+
#[cfg(feature = "fastbloom")]
519+
let log = Arc::new(BloomTokenLog::default());
520+
#[cfg(not(feature = "fastbloom"))]
521+
let log = Arc::new(NoneTokenLog);
510522
Self {
511523
lifetime: Duration::from_secs(2 * 7 * 24 * 60 * 60),
512-
log: Arc::new(NoneTokenLog),
524+
log,
513525
sent: 0,
514526
}
515527
}

0 commit comments

Comments
 (0)