Fix record feature optional

This commit is contained in:
Pascal Engélibert 2026-08-24 12:29:03 +02:00
commit e44cbc1e26

View file

@ -1,7 +1,9 @@
use crate::util::SigAlg; use crate::util::SigAlg;
#[cfg(feature = "record")]
use dashmap::DashMap; use dashmap::DashMap;
use log::error; use log::error;
#[cfg(feature = "record")]
use openssl::{pkey::PKey, x509::X509}; use openssl::{pkey::PKey, x509::X509};
use std::{ use std::{
collections::{BTreeMap, HashMap, btree_map}, collections::{BTreeMap, HashMap, btree_map},
@ -37,6 +39,7 @@ static TEST_RECORD: &[(u64, &str, Direction, &[u8])] =
//(1, "upload.wikimedia.org", Direction::ServerToClient, b"0\r\n\r\n"), //(1, "upload.wikimedia.org", Direction::ServerToClient, b"0\r\n\r\n"),
]; ];
#[cfg(feature = "record")]
#[derive(Debug)] #[derive(Debug)]
pub struct LyingCertificateRegistry { pub struct LyingCertificateRegistry {
by_name: DashMap<String, &'static openssl::ssl::SslContext>, by_name: DashMap<String, &'static openssl::ssl::SslContext>,
@ -44,6 +47,7 @@ pub struct LyingCertificateRegistry {
certs_dir: PathBuf, certs_dir: PathBuf,
} }
#[cfg(feature = "record")]
impl LyingCertificateRegistry { impl LyingCertificateRegistry {
pub fn new(ca_dir: &str, certs_dir: &str) -> Self { pub fn new(ca_dir: &str, certs_dir: &str) -> Self {
Self { Self {
@ -366,6 +370,7 @@ impl LyingCertificateRegistry {
} }
} }
#[cfg(feature = "record")]
pub static CERTIFICATES: OnceLock<LyingCertificateRegistry> = OnceLock::new(); pub static CERTIFICATES: OnceLock<LyingCertificateRegistry> = OnceLock::new();
fn write_record( fn write_record(
@ -475,6 +480,7 @@ impl sslrelay::HandlerCallbacks for Handler {
} }
} }
#[cfg(feature = "record")]
fn servername_callback( fn servername_callback(
ssl: &mut openssl::ssl::SslRef, ssl: &mut openssl::ssl::SslRef,
_alert: &mut openssl::ssl::SslAlert, _alert: &mut openssl::ssl::SslAlert,