update ws dependencies as well as http rustls dependency

This commit is contained in:
Joakim Frostegård 2024-01-07 10:40:50 +01:00
parent 071f088d8b
commit 3042539101
16 changed files with 499 additions and 295 deletions

View file

@ -37,5 +37,5 @@ toml = "0.5"
# Optional
glommio = { version = "0.8", optional = true }
hwloc = { version = "0.5", optional = true }
rustls = { version = "0.21", optional = true }
rustls-pemfile = { version = "1", optional = true }
rustls = { version = "0.22", optional = true }
rustls-pemfile = { version = "2", optional = true }

View file

@ -17,10 +17,20 @@ pub fn create_rustls_config(
})?;
let mut f = BufReader::new(f);
rustls_pemfile::certs(&mut f)?
.into_iter()
.map(|bytes| rustls::Certificate(bytes))
.collect()
let mut certs = Vec::new();
for cert in rustls_pemfile::certs(&mut f) {
match cert {
Ok(cert) => {
certs.push(cert);
}
Err(err) => {
::log::error!("error parsing certificate: {:#?}", err)
}
}
}
certs
};
let private_key = {
@ -32,16 +42,16 @@ pub fn create_rustls_config(
})?;
let mut f = BufReader::new(f);
rustls_pemfile::pkcs8_private_keys(&mut f)?
.first()
.map(|bytes| rustls::PrivateKey(bytes.clone()))
.ok_or(anyhow::anyhow!("No private keys in file"))?
let key = rustls_pemfile::pkcs8_private_keys(&mut f)
.next()
.ok_or(anyhow::anyhow!("No private keys in file"))??;
key
};
let tls_config = rustls::ServerConfig::builder()
.with_safe_defaults()
.with_no_client_auth()
.with_single_cert(certs, private_key)
.with_single_cert(certs, rustls::pki_types::PrivateKeyDer::Pkcs8(private_key))
.with_context(|| "create rustls config")?;
Ok(tls_config)

View file

@ -33,7 +33,7 @@ cfg-if = "1"
either = "1"
futures = "0.3"
futures-lite = "1"
futures-rustls = "0.24"
futures-rustls = "0.25"
glommio = "0.8"
httparse = "1"
itoa = "1"
@ -46,7 +46,7 @@ memchr = "2"
privdrop = "0.5"
once_cell = "1"
rand = { version = "0.8", features = ["small_rng"] }
rustls-pemfile = "1"
rustls-pemfile = "2"
serde = { version = "1", features = ["derive"] }
signal-hook = { version = "0.3" }
slotmap = "1"

View file

@ -21,14 +21,14 @@ aquatic_toml_config.workspace = true
anyhow = "1"
futures = "0.3"
futures-lite = "1"
futures-rustls = "0.24"
futures-rustls = "0.25"
hashbrown = "0.14"
glommio = "0.8"
log = "0.4"
mimalloc = { version = "0.1", default-features = false }
rand = { version = "0.8", features = ["small_rng"] }
rand_distr = "0.4"
rustls = { version = "0.21", default-features = false, features = ["logging", "dangerous_configuration"] } # TLS 1.2 disabled
rustls = { version = "0.22", default-features = false, features = ["logging"] } # TLS 1.2 disabled
serde = { version = "1", features = ["derive"] }
[dev-dependencies]

View file

@ -4,7 +4,6 @@ use rand_distr::Gamma;
pub use aquatic_http_protocol::common::*;
pub use aquatic_http_protocol::request::*;
pub use aquatic_http_protocol::response::*;
#[derive(PartialEq, Eq, Clone)]
pub struct TorrentPeer {

View file

@ -180,25 +180,53 @@ fn monitor_statistics(state: LoadTestState, config: &Config) {
}
}
#[derive(Debug)]
struct FakeCertificateVerifier;
impl rustls::client::ServerCertVerifier for FakeCertificateVerifier {
impl rustls::client::danger::ServerCertVerifier for FakeCertificateVerifier {
fn verify_server_cert(
&self,
_end_entity: &rustls::Certificate,
_intermediates: &[rustls::Certificate],
_server_name: &rustls::ServerName,
_scts: &mut dyn Iterator<Item = &[u8]>,
_end_entity: &rustls::pki_types::CertificateDer<'_>,
_intermediates: &[rustls::pki_types::CertificateDer<'_>],
_server_name: &rustls::pki_types::ServerName<'_>,
_ocsp_response: &[u8],
_now: std::time::SystemTime,
) -> Result<rustls::client::ServerCertVerified, rustls::Error> {
Ok(rustls::client::ServerCertVerified::assertion())
_now: rustls::pki_types::UnixTime,
) -> Result<rustls::client::danger::ServerCertVerified, rustls::Error> {
Ok(rustls::client::danger::ServerCertVerified::assertion())
}
fn verify_tls12_signature(
&self,
_message: &[u8],
_cert: &rustls::pki_types::CertificateDer<'_>,
_dss: &rustls::DigitallySignedStruct,
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
Ok(rustls::client::danger::HandshakeSignatureValid::assertion())
}
fn verify_tls13_signature(
&self,
_message: &[u8],
_cert: &rustls::pki_types::CertificateDer<'_>,
_dss: &rustls::DigitallySignedStruct,
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
Ok(rustls::client::danger::HandshakeSignatureValid::assertion())
}
fn supported_verify_schemes(&self) -> Vec<rustls::SignatureScheme> {
vec![
rustls::SignatureScheme::ECDSA_NISTP384_SHA384,
rustls::SignatureScheme::ECDSA_NISTP256_SHA256,
rustls::SignatureScheme::RSA_PSS_SHA512,
rustls::SignatureScheme::RSA_PSS_SHA384,
rustls::SignatureScheme::RSA_PSS_SHA256,
rustls::SignatureScheme::ED25519,
]
}
}
fn create_tls_config() -> anyhow::Result<Arc<rustls::ClientConfig>> {
let mut config = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(rustls::RootCertStore::empty())
.with_no_client_auth();

View file

@ -29,31 +29,31 @@ aquatic_toml_config.workspace = true
aquatic_ws_protocol.workspace = true
anyhow = "1"
async-tungstenite = "0.23"
async-tungstenite = "0.24"
arc-swap = "1"
cfg-if = "1"
futures = "0.3"
futures-lite = "1"
futures-rustls = "0.24"
futures-rustls = "0.25"
glommio = "0.8"
hashbrown = { version = "0.14", features = ["serde"] }
httparse = "1"
indexmap = "2"
log = "0.4"
metrics = { version = "0.21", optional = true }
metrics-util = { version = "0.15", optional = true }
metrics-exporter-prometheus = { version = "0.12", optional = true, default-features = false, features = ["http-listener"] }
metrics = { version = "0.22", optional = true }
metrics-util = { version = "0.16", optional = true }
metrics-exporter-prometheus = { version = "0.13", optional = true, default-features = false, features = ["http-listener"] }
mimalloc = { version = "0.1", default-features = false }
privdrop = "0.5"
rand = { version = "0.8", features = ["small_rng"] }
rustls = "0.21"
rustls-pemfile = "1"
rustls = "0.22"
rustls-pemfile = "2"
serde = { version = "1", features = ["derive"] }
signal-hook = { version = "0.3" }
slab = "0.4"
slotmap = "1"
socket2 = { version = "0.5", features = ["all"] }
tungstenite = "0.20"
tungstenite = "0.21"
[dev-dependencies]
quickcheck = "1"

View file

@ -1,8 +1,8 @@
use aquatic_common::cli::run_app_with_cli_and_config;
use aquatic_ws::config::Config;
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
// #[global_allocator]
// static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn main() {
run_app_with_cli_and_config::<Config>(

View file

@ -9,7 +9,6 @@ use anyhow::Context;
use aquatic_common::access_list::{create_access_list_cache, AccessListArcSwap, AccessListCache};
use aquatic_common::rustls_config::RustlsConfig;
use aquatic_common::ServerStartInstant;
use aquatic_peer_id::PeerClient;
use aquatic_ws_protocol::*;
use arc_swap::ArcSwap;
use async_tungstenite::WebSocketStream;
@ -26,6 +25,9 @@ use hashbrown::hash_map::Entry;
use hashbrown::HashMap;
use slab::Slab;
#[cfg(feature = "metrics")]
use metrics::{Counter, Gauge};
use crate::common::*;
use crate::config::Config;
use crate::workers::socket::calculate_in_message_consumer_index;
@ -60,6 +62,12 @@ impl ConnectionRunner {
announced_info_hashes: Default::default(),
ip_version: self.ip_version,
opt_peer_client: Default::default(),
#[cfg(feature = "metrics")]
active_connections_gauge: ::metrics::gauge!(
"aquatic_active_connections",
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.get().to_string(),
),
};
clean_up_data.before_open();
@ -74,7 +82,7 @@ impl ConnectionRunner {
clean_up_data
) async move {
if let Err(err) = self.run_inner(clean_up_data, stream).await {
::log::debug!("connection {:?} error: {:#}", connection_id, err);
::log::debug!("connection {:?} closed: {:#}", connection_id, err);
}
}),
tq_regular,
@ -101,7 +109,8 @@ impl ConnectionRunner {
mut stream: TcpStream,
) -> anyhow::Result<()> {
if let Some(tls_config) = self.opt_tls_config.as_ref() {
let tls_acceptor: TlsAcceptor = tls_config.load_full().into();
let tls_config = tls_config.load_full();
let tls_acceptor = TlsAcceptor::from(tls_config);
let stream = tls_acceptor.accept(stream).await?;
@ -177,6 +186,20 @@ impl ConnectionRunner {
ip_version: self.ip_version,
connection_id: self.connection_id,
clean_up_data: clean_up_data.clone(),
#[cfg(feature = "metrics")]
total_announce_requests_counter: ::metrics::counter!(
"aquatic_requests_total",
"type" => "announce",
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
),
#[cfg(feature = "metrics")]
total_scrape_requests_counter: ::metrics::counter!(
"aquatic_requests_total",
"type" => "scrape",
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
)
};
reader.run_in_message_loop().await
@ -219,6 +242,10 @@ struct ConnectionReader<S> {
ip_version: IpVersion,
connection_id: ConnectionId,
clean_up_data: ConnectionCleanupData,
#[cfg(feature = "metrics")]
total_announce_requests_counter: Counter,
#[cfg(feature = "metrics")]
total_scrape_requests_counter: Counter,
}
impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionReader<S> {
@ -270,12 +297,7 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionReader<S> {
async fn handle_announce_request(&mut self, request: AnnounceRequest) -> anyhow::Result<()> {
#[cfg(feature = "metrics")]
::metrics::increment_counter!(
"aquatic_requests_total",
"type" => "announce",
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
self.total_announce_requests_counter.increment(1);
let info_hash = request.info_hash;
@ -315,24 +337,28 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionReader<S> {
&& self.clean_up_data.opt_peer_client.borrow().is_none()
{
let peer_id = aquatic_peer_id::PeerId(request.peer_id.0);
let client = peer_id.client();
let prefix = peer_id.first_8_bytes_hex().to_string();
::metrics::increment_gauge!(
let peer_client_gauge = ::metrics::gauge!(
"aquatic_peer_clients",
1.0,
"client" => client.to_string(),
"client" => peer_id.client().to_string(),
);
if self.config.metrics.peer_id_prefixes {
::metrics::increment_gauge!(
"aquatic_peer_id_prefixes",
1.0,
"prefix_hex" => prefix.to_string(),
);
}
peer_client_gauge.increment(1.0);
*self.clean_up_data.opt_peer_client.borrow_mut() = Some((client, prefix));
let opt_peer_id_prefix_gauge =
self.config.metrics.peer_id_prefixes.then(|| {
let g = ::metrics::gauge!(
"aquatic_peer_id_prefixes",
"prefix_hex" => peer_id.first_8_bytes_hex().to_string(),
);
g.increment(1.0);
g
});
*self.clean_up_data.opt_peer_client.borrow_mut() =
Some((peer_client_gauge, opt_peer_id_prefix_gauge));
};
}
}
@ -370,12 +396,7 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionReader<S> {
async fn handle_scrape_request(&mut self, request: ScrapeRequest) -> anyhow::Result<()> {
#[cfg(feature = "metrics")]
::metrics::increment_counter!(
"aquatic_requests_total",
"type" => "scrape",
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
self.total_scrape_requests_counter.increment(1);
let info_hashes = if let Some(info_hashes) = request.info_hashes {
info_hashes
@ -548,32 +569,24 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionWriter<S> {
OutMessage::ErrorResponse(_) => "error",
};
::metrics::increment_counter!(
::metrics::counter!(
"aquatic_responses_total",
"type" => out_message_type,
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
)
.increment(1);
if let Some((peer_client, prefix)) =
// As long as connection is still alive, increment peer client
// gauges by zero to prevent them from being removed due to
// idleness
if let Some((peer_client_gauge, opt_peer_id_prefix_gauge)) =
self.clean_up_data.opt_peer_client.borrow().as_ref()
{
// As long as connection is still alive, increment peer client
// gauges by zero to prevent them from being removed due to
// idleness
peer_client_gauge.increment(0.0);
::metrics::increment_gauge!(
"aquatic_peer_clients",
0.0,
"client" => peer_client.to_string(),
);
if self.config.metrics.peer_id_prefixes {
::metrics::increment_gauge!(
"aquatic_peer_id_prefixes",
0.0,
"prefix_hex" => prefix.to_string(),
);
if let Some(g) = opt_peer_id_prefix_gauge {
g.increment(0.0);
}
}
}
@ -587,18 +600,15 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionWriter<S> {
struct ConnectionCleanupData {
announced_info_hashes: Rc<RefCell<HashMap<InfoHash, PeerId>>>,
ip_version: IpVersion,
opt_peer_client: Rc<RefCell<Option<(PeerClient, String)>>>,
opt_peer_client: Rc<RefCell<Option<(Gauge, Option<Gauge>)>>>,
#[cfg(feature = "metrics")]
active_connections_gauge: Gauge,
}
impl ConnectionCleanupData {
fn before_open(&self) {
#[cfg(feature = "metrics")]
::metrics::increment_gauge!(
"aquatic_active_connections",
1.0,
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.get().to_string(),
);
self.active_connections_gauge.increment(1.0);
}
async fn after_close(
&self,
@ -625,28 +635,14 @@ impl ConnectionCleanupData {
}
#[cfg(feature = "metrics")]
{
::metrics::decrement_gauge!(
"aquatic_active_connections",
1.0,
"ip_version" => ip_version_to_metrics_str(self.ip_version),
"worker_index" => WORKER_INDEX.get().to_string(),
);
self.active_connections_gauge.decrement(1.0);
if let Some((peer_client, prefix)) = self.opt_peer_client.borrow().as_ref() {
::metrics::decrement_gauge!(
"aquatic_peer_clients",
1.0,
"client" => peer_client.to_string(),
);
#[cfg(feature = "metrics")]
if let Some((peer_client_gauge, opt_peer_id_prefix_gauge)) = self.opt_peer_client.take() {
peer_client_gauge.decrement(1.0);
if config.metrics.peer_id_prefixes {
::metrics::decrement_gauge!(
"aquatic_peer_id_prefixes",
1.0,
"prefix_hex" => prefix.to_string(),
);
}
if let Some(g) = opt_peer_id_prefix_gauge {
g.decrement(1.0);
}
}
}

View file

@ -253,20 +253,20 @@ async fn clean_connections(
let worker_index = WORKER_INDEX.with(|index| index.get()).to_string();
if config.network.address.is_ipv4() || !config.network.only_ipv6 {
::metrics::increment_gauge!(
::metrics::gauge!(
"aquatic_active_connections",
0.0,
"ip_version" => "4",
"worker_index" => worker_index.clone(),
);
)
.increment(0.0);
}
if config.network.address.is_ipv6() {
::metrics::increment_gauge!(
::metrics::gauge!(
"aquatic_active_connections",
0.0,
"ip_version" => "6",
"worker_index" => worker_index,
);
)
.increment(0.0);
}
}

View file

@ -2,6 +2,7 @@ use std::sync::Arc;
use aquatic_common::access_list::{create_access_list_cache, AccessListArcSwap, AccessListCache};
use hashbrown::HashMap;
use metrics::Gauge;
use rand::rngs::SmallRng;
use aquatic_common::{
@ -16,10 +17,42 @@ use crate::workers::swarm::WORKER_INDEX;
type TorrentMap = IndexMap<InfoHash, TorrentData>;
type PeerMap = IndexMap<PeerId, Peer>;
#[derive(Default)]
pub struct TorrentMaps {
ipv4: TorrentMap,
ipv6: TorrentMap,
peers_gauge_ipv4: Gauge,
peers_gauge_ipv6: Gauge,
torrents_gauge_ipv4: Gauge,
torrents_gauge_ipv6: Gauge,
}
impl Default for TorrentMaps {
fn default() -> Self {
Self {
ipv4: Default::default(),
ipv6: Default::default(),
peers_gauge_ipv4: ::metrics::gauge!(
"aquatic_peers",
"ip_version" => "4",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
),
peers_gauge_ipv6: ::metrics::gauge!(
"aquatic_peers",
"ip_version" => "6",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
),
torrents_gauge_ipv4: ::metrics::gauge!(
"aquatic_torrents",
"ip_version" => "4",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
),
torrents_gauge_ipv6: ::metrics::gauge!(
"aquatic_torrents",
"ip_version" => "6",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
),
}
}
}
impl TorrentMaps {
@ -33,12 +66,11 @@ impl TorrentMaps {
request_sender_meta: InMessageMeta,
request: AnnounceRequest,
) {
let (torrent_data, ip_version): (&mut TorrentData, &'static str) =
if let IpVersion::V4 = request_sender_meta.ip_version {
(self.ipv4.entry(request.info_hash).or_default(), "4")
} else {
(self.ipv6.entry(request.info_hash).or_default(), "6")
};
let torrent_data = if let IpVersion::V4 = request_sender_meta.ip_version {
self.ipv4.entry(request.info_hash).or_default()
} else {
self.ipv6.entry(request.info_hash).or_default()
};
// If there is already a peer with this peer_id, check that connection id
// is same as that of request sender. Otherwise, ignore request. Since
@ -89,12 +121,10 @@ impl TorrentMaps {
}
#[cfg(feature = "metrics")]
::metrics::decrement_gauge!(
"aquatic_peers",
1.0,
"ip_version" => ip_version,
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
match request_sender_meta.ip_version {
IpVersion::V4 => self.peers_gauge_ipv4.decrement(1.0),
IpVersion::V6 => self.peers_gauge_ipv6.decrement(1.0),
}
return;
}
@ -112,12 +142,10 @@ impl TorrentMaps {
entry.insert(peer);
#[cfg(feature = "metrics")]
::metrics::increment_gauge!(
"aquatic_peers",
1.0,
"ip_version" => ip_version,
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
match request_sender_meta.ip_version {
IpVersion::V4 => self.peers_gauge_ipv4.increment(1.0),
IpVersion::V6 => self.peers_gauge_ipv6.increment(1.0),
}
}
PeerStatus::Seeding => {
torrent_data.num_seeders += 1;
@ -133,12 +161,10 @@ impl TorrentMaps {
entry.insert(peer);
#[cfg(feature = "metrics")]
::metrics::increment_gauge!(
"aquatic_peers",
1.0,
"ip_version" => ip_version,
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
match request_sender_meta.ip_version {
IpVersion::V4 => self.peers_gauge_ipv4.increment(1.0),
IpVersion::V6 => self.peers_gauge_ipv6.increment(1.0),
}
}
PeerStatus::Stopped => return,
},
@ -311,8 +337,20 @@ impl TorrentMaps {
let mut access_list_cache = create_access_list_cache(access_list);
let now = server_start_instant.seconds_elapsed();
Self::clean_torrent_map(config, &mut access_list_cache, &mut self.ipv4, now, "4");
Self::clean_torrent_map(config, &mut access_list_cache, &mut self.ipv6, now, "6");
Self::clean_torrent_map(
config,
&mut access_list_cache,
&mut self.ipv4,
now,
&self.peers_gauge_ipv4,
);
Self::clean_torrent_map(
config,
&mut access_list_cache,
&mut self.ipv6,
now,
&self.peers_gauge_ipv6,
);
}
fn clean_torrent_map(
@ -320,7 +358,7 @@ impl TorrentMaps {
access_list_cache: &mut AccessListCache,
torrent_map: &mut TorrentMap,
now: SecondsSinceServerStart,
ip_version: &'static str,
peers_gauge: &Gauge,
) {
let mut total_num_peers = 0u64;
@ -357,31 +395,14 @@ impl TorrentMaps {
torrent_map.shrink_to_fit();
let total_num_peers = total_num_peers as f64;
#[cfg(feature = "metrics")]
::metrics::gauge!(
"aquatic_peers",
total_num_peers,
"ip_version" => ip_version,
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
peers_gauge.set(total_num_peers as f64)
}
#[cfg(feature = "metrics")]
pub fn update_torrent_count_metrics(&self) {
::metrics::gauge!(
"aquatic_torrents",
self.ipv4.len() as f64,
"ip_version" => "4",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
::metrics::gauge!(
"aquatic_torrents",
self.ipv6.len() as f64,
"ip_version" => "6",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
self.torrents_gauge_ipv4.set(self.ipv4.len() as f64);
self.torrents_gauge_ipv6.set(self.ipv6.len() as f64);
}
pub fn handle_connection_closed(
@ -397,24 +418,14 @@ impl TorrentMaps {
torrent_data.remove_peer(peer_id);
#[cfg(feature = "metrics")]
::metrics::decrement_gauge!(
"aquatic_peers",
1.0,
"ip_version" => "4",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
self.peers_gauge_ipv4.decrement(1.0);
}
} else {
if let Some(torrent_data) = self.ipv6.get_mut(&info_hash) {
torrent_data.remove_peer(peer_id);
#[cfg(feature = "metrics")]
::metrics::decrement_gauge!(
"aquatic_peers",
1.0,
"ip_version" => "6",
"worker_index" => WORKER_INDEX.with(|index| index.get()).to_string(),
);
self.peers_gauge_ipv6.decrement(1.0);
}
}
}

View file

@ -19,18 +19,18 @@ aquatic_toml_config.workspace = true
aquatic_ws_protocol.workspace = true
anyhow = "1"
async-tungstenite = "0.23"
async-tungstenite = "0.24"
futures = "0.3"
futures-rustls = "0.24"
futures-rustls = "0.25"
glommio = "0.8"
log = "0.4"
mimalloc = { version = "0.1", default-features = false }
rand = { version = "0.8", features = ["small_rng"] }
rand_distr = "0.4"
rustls = { version = "0.21", default-features = false, features = ["dangerous_configuration"] }
rustls = { version = "0.22" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tungstenite = "0.20"
tungstenite = "0.21"
[dev-dependencies]
quickcheck = "1"

View file

@ -87,25 +87,53 @@ fn run(config: Config) -> ::anyhow::Result<()> {
Ok(())
}
#[derive(Debug)]
struct FakeCertificateVerifier;
impl rustls::client::ServerCertVerifier for FakeCertificateVerifier {
impl rustls::client::danger::ServerCertVerifier for FakeCertificateVerifier {
fn verify_server_cert(
&self,
_end_entity: &rustls::Certificate,
_intermediates: &[rustls::Certificate],
_server_name: &rustls::ServerName,
_scts: &mut dyn Iterator<Item = &[u8]>,
_end_entity: &rustls::pki_types::CertificateDer<'_>,
_intermediates: &[rustls::pki_types::CertificateDer<'_>],
_server_name: &rustls::pki_types::ServerName<'_>,
_ocsp_response: &[u8],
_now: std::time::SystemTime,
) -> Result<rustls::client::ServerCertVerified, rustls::Error> {
Ok(rustls::client::ServerCertVerified::assertion())
_now: rustls::pki_types::UnixTime,
) -> Result<rustls::client::danger::ServerCertVerified, rustls::Error> {
Ok(rustls::client::danger::ServerCertVerified::assertion())
}
fn verify_tls12_signature(
&self,
_message: &[u8],
_cert: &rustls::pki_types::CertificateDer<'_>,
_dss: &rustls::DigitallySignedStruct,
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
Ok(rustls::client::danger::HandshakeSignatureValid::assertion())
}
fn verify_tls13_signature(
&self,
_message: &[u8],
_cert: &rustls::pki_types::CertificateDer<'_>,
_dss: &rustls::DigitallySignedStruct,
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
Ok(rustls::client::danger::HandshakeSignatureValid::assertion())
}
fn supported_verify_schemes(&self) -> Vec<rustls::SignatureScheme> {
vec![
rustls::SignatureScheme::ECDSA_NISTP384_SHA384,
rustls::SignatureScheme::ECDSA_NISTP256_SHA256,
rustls::SignatureScheme::RSA_PSS_SHA512,
rustls::SignatureScheme::RSA_PSS_SHA384,
rustls::SignatureScheme::RSA_PSS_SHA256,
rustls::SignatureScheme::ED25519,
]
}
}
fn create_tls_config() -> anyhow::Result<Arc<rustls::ClientConfig>> {
let mut config = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(rustls::RootCertStore::empty())
.with_no_client_auth();

View file

@ -24,8 +24,8 @@ anyhow = "1"
hashbrown = { version = "0.14", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
simd-json = "0.12"
tungstenite = "0.20"
simd-json = "0.13"
tungstenite = "0.21"
[dev-dependencies]
criterion = "0.5"