From 2953837f25f779d31d2cfb2c477dce92fb6809c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Wed, 28 Jun 2023 23:47:00 +0200 Subject: [PATCH] Add medium toggle to socks5 client (#3615) * Add medium toggle to socks5 client * rustfmt --- clients/socks5/src/commands/init.rs | 1 + clients/socks5/src/commands/mod.rs | 18 +++++++++++++++++- clients/socks5/src/commands/run.rs | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index 7c8fa68719..76337b84ac 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -94,6 +94,7 @@ impl From for OverrideConfig { use_anonymous_replies: init_config.use_reply_surbs, fastmode: init_config.fastmode, no_cover: init_config.no_cover, + medium_toggle: false, nyxd_urls: init_config.nyxd_urls, enabled_credentials_mode: init_config.enabled_credentials_mode, outfox: false, diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 60d6b6e0b7..61e992d4d0 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -19,7 +19,7 @@ use nym_client_core::client::key_manager::persistence::OnDiskKeys; use nym_client_core::config::GatewayEndpointConfig; use nym_client_core::error::ClientCoreError; use nym_config::OptionalSet; -use nym_sphinx::params::PacketType; +use nym_sphinx::params::{PacketSize, PacketType}; use std::error::Error; pub mod init; @@ -72,6 +72,7 @@ pub(crate) struct OverrideConfig { use_anonymous_replies: Option, fastmode: bool, no_cover: bool, + medium_toggle: bool, nyxd_urls: Option>, enabled_credentials_mode: Option, outfox: bool, @@ -91,6 +92,10 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box Config { + let disable_cover_traffic_with_keepalive = args.medium_toggle; + let secondary_packet_size = args.medium_toggle.then_some(PacketSize::ExtendedPacket16); + let no_per_hop_delays = args.medium_toggle; + let packet_type = if args.outfox { PacketType::Outfox } else { @@ -101,6 +106,17 @@ pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config { BaseClientConfig::with_high_default_traffic_volume, args.fastmode, ) + .with_base( + // NOTE: This interacts with disabling cover traffic fully, so we want to this to be set before + BaseClientConfig::with_disabled_cover_traffic_with_keepalive, + disable_cover_traffic_with_keepalive, + ) + .with_base( + BaseClientConfig::with_secondary_packet_size, + secondary_packet_size, + ) + .with_base(BaseClientConfig::with_no_per_hop_delays, no_per_hop_delays) + // NOTE: see comment above about the order of the other disble cover traffic config .with_base(BaseClientConfig::with_disabled_cover_traffic, args.no_cover) .with_base(BaseClientConfig::with_packet_type, packet_type) .with_optional(Config::with_anonymous_replies, args.use_anonymous_replies) diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index a6bc88344b..5d54038c06 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -60,6 +60,11 @@ pub(crate) struct Run { #[clap(long, hide = true)] no_cover: bool, + /// Enable medium mixnet traffic, for experiments only. + /// This includes things like disabling cover traffic, no per hop delays, etc. + #[clap(long, hide = true)] + medium_toggle: bool, + /// Set this client to work in a enabled credentials mode that would attempt to use gateway /// with bandwidth credential requirement. #[clap(long, hide = true)] @@ -77,6 +82,7 @@ impl From for OverrideConfig { use_anonymous_replies: run_config.use_anonymous_replies, fastmode: run_config.fastmode, no_cover: run_config.no_cover, + medium_toggle: run_config.medium_toggle, nyxd_urls: run_config.nyxd_urls, enabled_credentials_mode: run_config.enabled_credentials_mode, outfox: run_config.outfox,