Skip to content

Commit

Permalink
agg-speed: add debug build warning
Browse files Browse the repository at this point in the history
Since speed is very slow in non-release builds.
  • Loading branch information
surban committed Mar 26, 2024
1 parent 1aab9f2 commit 02f5051
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions aggligator-util/src/bin/agg-speed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ fn tls_server_config() -> ServerConfig {
ServerConfig::builder().with_no_client_auth().with_single_cert(vec![tls_cert()], tls_key()).unwrap()
}

fn debug_warning() -> String {
match cfg!(debug_assertions) {
true => "⚠ debug build: speeds will be slow ⚠\n".red().to_string(),
false => String::new(),
}
}

/// Run speed test using a connection consisting of aggregated TCP links.
///
/// This uses Aggligator to combine multiple TCP links into one connection,
Expand Down Expand Up @@ -182,6 +189,10 @@ async fn main() -> Result<()> {
let cfg = load_cfg(&cli.cfg)?;
let dump = cli.dump.clone();

if cfg!(debug_assertions) {
eprintln!("{}", debug_warning());
}

match cli.command {
Commands::Client(client) => client.run(cfg, dump).await?,
Commands::Server(server) => server.run(cfg, dump).await?,
Expand Down Expand Up @@ -402,7 +413,7 @@ impl ClientCli {
"Downstream: ".grey(),
format_speed(recv)
);
let header = format!("{}\r\n\r\n{}", title.clone().white().bold(), speed);
let header = format!("{}\r\n\r\n{}{}", title.clone().white().bold(), speed, debug_warning());

if header_tx.send(header).is_err() {
break;
Expand Down Expand Up @@ -669,7 +680,7 @@ impl ServerCli {
} else {
let task = tokio::spawn(task);

let header_rx = watch::channel(format!("{title}\r\n").white().bold().to_string()).1;
let header_rx = watch::channel(format!("{}\r\n{}", title.white().bold(), debug_warning())).1;
block_in_place(|| interactive_monitor(header_rx, control_rx, 1, None, Some(tag_error_rx), None))?;

task.abort();
Expand Down

0 comments on commit 02f5051

Please sign in to comment.