diff --git a/common/src/cert.rs b/common/src/cert.rs index a85b46f..c8cc4a1 100644 --- a/common/src/cert.rs +++ b/common/src/cert.rs @@ -1,8 +1,3 @@ -//! Self-signed certificate generation for local testing. -//! -//! Generates a CA certificate and server certificate for TLS benchmarking. -//! These certificates are NOT suitable for production use. - use rcgen::{BasicConstraints, CertificateParams, DnType, IsCa, Issuer, KeyPair, SanType}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; diff --git a/common/src/lib.rs b/common/src/lib.rs index 7329701..133dbfa 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -2,6 +2,7 @@ pub mod cert; pub mod error; +pub mod prelude; pub mod protocol; pub use error::Error; diff --git a/common/src/prelude.rs b/common/src/prelude.rs new file mode 100644 index 0000000..2abb89a --- /dev/null +++ b/common/src/prelude.rs @@ -0,0 +1,4 @@ +pub use crate::{ + BenchRecord, KeyExchangeMode, + protocol::{read_payload, read_request, write_payload, write_request}, +}; diff --git a/common/src/protocol.rs b/common/src/protocol.rs index 2ea16cd..75e2122 100644 --- a/common/src/protocol.rs +++ b/common/src/protocol.rs @@ -1,11 +1,3 @@ -//! Benchmark protocol implementation. -//! -//! Protocol specification: -//! 1. Client sends 8-byte little-endian u64: requested payload size N -//! 2. Server responds with exactly N bytes (deterministic pattern) -//! -//! The deterministic pattern is a repeating sequence of bytes 0x00..0xFF. - // Casts are intentional: MAX_PAYLOAD_SIZE (16 MiB) fits in usize on 64-bit, // and byte patterns are explicitly masked to 0xFF before casting. #![allow(clippy::cast_possible_truncation)] diff --git a/runner/src/bench.rs b/runner/src/bench.rs index 45132da..2b42f6c 100644 --- a/runner/src/bench.rs +++ b/runner/src/bench.rs @@ -1,7 +1,4 @@ -use common::{ - BenchRecord, KeyExchangeMode, - protocol::{read_payload, write_request}, -}; +use common::prelude::*; use futures::{StreamExt, stream::FuturesUnordered}; use miette::{Context, IntoDiagnostic}; use rustls::pki_types::ServerName; diff --git a/runner/src/config/mod.rs b/runner/src/config/mod.rs index 84ae57a..81f36c4 100644 --- a/runner/src/config/mod.rs +++ b/runner/src/config/mod.rs @@ -5,7 +5,7 @@ use crate::{ config::utils::validate_config, error::{self, ConfigError}, }; -use common::{self, KeyExchangeMode}; +use common::prelude::*; use miette::{NamedSource, SourceSpan}; use serde::Deserialize; use std::{fs::read_to_string, net::SocketAddr, path::Path}; diff --git a/runner/src/main.rs b/runner/src/main.rs index e02aee4..c206963 100644 --- a/runner/src/main.rs +++ b/runner/src/main.rs @@ -12,6 +12,12 @@ mod config; mod error; mod tls; +use crate::{ + args::Args, + bench::run_benchmark, + config::{load_from_cli, load_from_file}, + tls::build_tls_config, +}; use clap::Parser; use miette::{Context, IntoDiagnostic}; use rustls::pki_types::ServerName; @@ -21,13 +27,6 @@ use tracing::info; use tracing_subscriber::EnvFilter; use uuid::Uuid; -use crate::{ - args::Args, - bench::run_benchmark, - config::{load_from_cli, load_from_file}, - tls::build_tls_config, -}; - #[tokio::main] async fn main() -> miette::Result<()> { let run_id = Uuid::new_v4(); diff --git a/runner/src/tls.rs b/runner/src/tls.rs index b9a47db..4d3e4cc 100644 --- a/runner/src/tls.rs +++ b/runner/src/tls.rs @@ -1,4 +1,4 @@ -use common::KeyExchangeMode; +use common::prelude::*; use miette::{Context, IntoDiagnostic}; use rustls::{ ClientConfig, DigitallySignedStruct, SignatureScheme, diff --git a/server/src/main.rs b/server/src/main.rs index 806cf13..dfe324a 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -11,7 +11,7 @@ mod tls; use crate::{server::run_server, tls::build_tls_config}; use base64::prelude::*; use clap::Parser; -use common::{KeyExchangeMode, cert::CaCertificate}; +use common::{cert::CaCertificate, prelude::*}; use std::{env, net::SocketAddr}; use tracing::{error, info}; use tracing_subscriber::EnvFilter; @@ -72,7 +72,6 @@ async fn main() -> miette::Result<()> { mod tests { use super::*; use claims::assert_ok; - use common::cert::CaCertificate; use std::sync::Arc; #[test] diff --git a/server/src/server.rs b/server/src/server.rs index 8d3631b..eff9885 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -1,5 +1,5 @@ use crate::{Args, error}; -use common::protocol::{read_request, write_payload}; +use common::prelude::*; use rustls::{ServerConfig, server::Acceptor}; use std::{io::ErrorKind, net::SocketAddr, sync::Arc}; use tokio::{ diff --git a/server/src/tls.rs b/server/src/tls.rs index 5f552aa..f76815c 100644 --- a/server/src/tls.rs +++ b/server/src/tls.rs @@ -1,5 +1,5 @@ use crate::error; -use common::{KeyExchangeMode, cert::ServerCertificate}; +use common::{cert::ServerCertificate, prelude::*}; use rustls::{ ServerConfig, crypto::aws_lc_rs::{