@ -49,6 +49,7 @@ use blacklist::*;
use byteorder ::{ BigEndian , ByteOrder } ;
use cache ::* ;
use clap ::Arg ;
use clockpro_cache ::ClockProCache ;
use config ::* ;
use crypto ::* ;
use dns ::* ;
@ -65,7 +66,6 @@ use parking_lot::RwLock;
#[ cfg(target_family = " unix " ) ]
use privdrop ::PrivDrop ;
use rand ::prelude ::* ;
use sieve_cache ::SieveCache ;
use siphasher ::sip128 ::SipHasher13 ;
use slabigator ::Slab ;
use tokio ::io ::{ AsyncReadExt , AsyncWriteExt } ;
@ -214,12 +214,7 @@ async fn handle_client_query(
. await
}
Ok ( None ) = > return Ok ( ( ) ) ,
Err ( _ ) = > {
if may_be_quic ( & packet ) {
bail ! ( "Likely a QUIC packet" ) // RFC 9443
}
bail ! ( "Unencrypted query or different protocol" )
}
Err ( _ ) = > bail ! ( "Unencrypted query or QUIC protocol" ) ,
} ;
}
} ;
@ -353,16 +348,12 @@ async fn tcp_acceptor(globals: Arc<Globals>, tcp_listener: TcpListener) -> Resul
#[ cfg(feature = " metrics " ) ]
varz . inflight_tcp_queries . set ( _count . saturating_sub ( 1 ) as _ ) ;
if let Ok ( Either ::Right ( e ) ) = either {
if let Ok ( Either ::Right ( _ ) ) = either {
// Removing the active connection was already done during
// cancellation.
debug ! ( "TCP query canceled: {:?}" , e . 0 )
} else {
let mut active_connections = active_connections . lock ( ) ;
_ = active_connections . remove ( tx_channel_index ) ;
if let Ok ( Either ::Left ( e ) ) = either {
debug ! ( "TCP query error: {:?}" , e . 0 )
}
}
} ) ) ;
}
@ -418,16 +409,12 @@ async fn udp_acceptor(
#[ cfg(feature = " metrics " ) ]
varz . inflight_udp_queries . set ( _count . saturating_sub ( 1 ) as _ ) ;
if let Ok ( Either ::Right ( e ) ) = either {
if let Ok ( Either ::Right ( _ ) ) = either {
// Removing the active connection was already done during
// cancellation.
debug ! ( "UDP query canceled: {:?}" , e . 0 )
} else {
let mut active_connections = active_connections . lock ( ) ;
_ = active_connections . remove ( tx_channel_index ) ;
if let Ok ( Either ::Left ( e ) ) = either {
debug ! ( "UDP query error: {:?}" , e . 0 )
}
}
} ) ) ;
}
@ -573,6 +560,16 @@ fn set_limits(config: &Config) -> Result<(), Error> {
}
fn main ( ) -> Result < ( ) , Error > {
env_logger ::Builder ::from_default_env ( )
. write_style ( env_logger ::WriteStyle ::Never )
. format_module_path ( false )
. format_timestamp ( None )
. filter_level ( log ::LevelFilter ::Info )
. target ( env_logger ::Target ::Stdout )
. init ( ) ;
crypto ::init ( ) ? ;
let time_updater = coarsetime ::Updater ::new ( 1000 ) . start ( ) ? ;
let matches = clap ::command ! ( )
. arg (
Arg ::new ( "config" )
@ -596,31 +593,8 @@ fn main() -> Result<(), Error> {
. takes_value ( false )
. help ( "Only print the connection information and quit" ) ,
)
. arg (
Arg ::new ( "debug" )
. long ( "debug" )
. takes_value ( false )
. help ( "Enable debug logs" ) ,
)
. get_matches ( ) ;
let log_level = if matches . is_present ( "debug" ) {
log ::LevelFilter ::Debug
} else {
log ::LevelFilter ::Info
} ;
env_logger ::Builder ::from_default_env ( )
. write_style ( env_logger ::WriteStyle ::Never )
. format_module_path ( false )
. format_timestamp ( None )
. filter_level ( log_level )
. target ( env_logger ::Target ::Stdout )
. init ( ) ;
crypto ::init ( ) ? ;
let time_updater = coarsetime ::Updater ::new ( 1000 ) . start ( ) ? ;
let config_path = matches . value_of ( "config" ) . unwrap ( ) ;
let config = Config ::from_path ( config_path ) ? ;
if let Err ( e ) = set_limits ( & config ) {
@ -735,14 +709,14 @@ fn main() -> Result<(), Error> {
let hasher = SipHasher13 ::new_with_keys ( sh_k0 , sh_k1 ) ;
let cache = Cache ::new (
Sieve Cache::new ( cache_capacity )
ClockPro Cache::new ( cache_capacity )
. map_err ( | e | anyhow ! ( "Unable to create the DNS cache: [{}]" , e ) ) ? ,
config . cache_ttl_min ,
config . cache_ttl_max ,
config . cache_ttl_error ,
) ;
let cert_cache = Cache ::new (
Sieve Cache::new ( RELAYED_CERT_CACHE_SIZE )
ClockPro Cache::new ( RELAYED_CERT_CACHE_SIZE )
. map_err ( | e | anyhow ! ( "Unable to create the relay cert cache: [{}]" , e ) ) ? ,
RELAYED_CERT_CACHE_TTL ,
RELAYED_CERT_CACHE_TTL ,