-
Notifications
You must be signed in to change notification settings - Fork 36
Nicolas/introduced new parameters #4039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 3 commits
f223b58
10610b3
07c35bf
bc171eb
0f3ebfb
827f21d
95abdbf
3105fc0
b5643dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,7 +124,7 @@ impl Default for TunnelConstants { | |
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||
| #[derive(Debug, Clone, PartialEq)] | ||
|
||
| pub struct TunnelSettings { | ||
| /// Whether to enable support for IPv6. | ||
| pub enable_ipv6: bool, | ||
|
|
@@ -737,7 +737,6 @@ impl TunnelStateMachine { | |
| &mut self.shared_state, | ||
| ) | ||
| .await; | ||
|
|
||
| match next_state { | ||
| NextTunnelState::NewState((new_state_handler, new_state)) => { | ||
| self.current_state_handler = new_state_handler; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ use anyhow::Result; | |
| use nym_vpn_proto::rpc_client::RpcClient; | ||
|
|
||
| use crate::{boolean_option::BooleanOption, display_helpers::display_on_off}; | ||
| use clap::builder::ValueParser; | ||
|
|
||
| #[derive(Debug, Clone, clap::Subcommand)] | ||
| pub enum Command { | ||
|
|
@@ -35,6 +36,56 @@ pub struct SetParams { | |
| /// Enable Circumvention Transport (CT) wrapping for the connection to the entry gateway in two hop wireguard mode. | ||
| #[arg(long, alias = "ct", value_parser = clap::value_parser!(BooleanOption))] | ||
| circumvention_transports: Option<BooleanOption>, | ||
| /// Set the average delay for a loop cover packet (milliseconds) | ||
| #[arg( | ||
| long, | ||
| value_name = "MILLISECONDS", | ||
| value_parser = ValueParser::from(|s: &str| -> Result<u32, String> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pronebird @trojanfoe How do feel about the parameters validation on that layer?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type should be |
||
| let val: u32 = s.parse().map_err(|_| format!("Invalid integer: {}", s))?; | ||
| if !(0..=200).contains(&val) { | ||
| return Err(format!("Value must be between 0 and 200 (got {val})")); | ||
| } | ||
| Ok(val) | ||
| }) | ||
| )] | ||
| pub loop_cover_stream_average_delay: Option<u32>, | ||
nick1231321 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// Set average packet delay at each mixnode (milliseconds) | ||
| #[arg( | ||
| long, | ||
| value_name = "MILLISECONDS", | ||
| value_parser = ValueParser::from(|s: &str| -> Result<u32, String> { | ||
| let val: u32 = s.parse().map_err(|_| format!("Invalid integer: {}", s))?; | ||
| if !(0..=200).contains(&val) { | ||
| return Err(format!("Packet delay must be between 0 and 200 (got {val})")); | ||
| } | ||
| Ok(val) | ||
| }) | ||
| )] | ||
| pub average_packet_delay: Option<u32>, | ||
|
|
||
| /// Set average real message sending delay (milliseconds) | ||
| #[arg( | ||
| long, | ||
| value_name = "MILLISECONDS", | ||
| value_parser = ValueParser::from(|s: &str| -> Result<u32, String> { | ||
| let val: u32 = s.parse().map_err(|_| format!("Invalid integer: {}", s))?; | ||
| if !(5..=50).contains(&val) { | ||
| return Err(format!( | ||
| "Message sending delay must be between 5 and 50 (got {val})" | ||
| )); | ||
| } | ||
| Ok(val) | ||
| }) | ||
| )] | ||
| pub message_sending_delay: Option<u32>, | ||
|
|
||
| #[arg( | ||
| long, | ||
| help = "Disable Poisson process rate limiting for real traffic", | ||
| value_parser = BooleanOption::custom_parser("on","off") | ||
nick1231321 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| )] | ||
| pub disable_real_traffic_poisson_rate: Option<BooleanOption>, | ||
| } | ||
|
|
||
| impl Command { | ||
|
|
@@ -57,6 +108,10 @@ impl Command { | |
| netstack, | ||
| ipv6, | ||
| circumvention_transports, | ||
| loop_cover_stream_average_delay, | ||
| average_packet_delay, | ||
| message_sending_delay, | ||
| disable_real_traffic_poisson_rate, | ||
| }) => { | ||
| if let Some(two_hop) = two_hop { | ||
| rpc_client.set_enable_two_hop(*two_hop).await?; | ||
|
|
@@ -73,7 +128,21 @@ impl Command { | |
| if let Some(enable_ct) = circumvention_transports { | ||
| rpc_client.set_enable_bridges(*enable_ct).await?; | ||
| } | ||
| if let Some(poisson) = loop_cover_stream_average_delay { | ||
| rpc_client.set_poisson_parameter(poisson).await?; | ||
| } | ||
| if let Some(delay_ms) = average_packet_delay { | ||
| rpc_client.set_average_packet_delay(delay_ms).await?; | ||
| } | ||
|
|
||
| if let Some(delay_ms) = message_sending_delay { | ||
| rpc_client | ||
| .set_message_sending_average_delay(delay_ms) | ||
| .await?; | ||
| } | ||
| if let Some(disable) = disable_real_traffic_poisson_rate { | ||
| rpc_client.set_disable_poisson_rate(*disable).await?; | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,6 @@ async fn run_vpn_service(args: CliArgs) -> anyhow::Result<()> { | |
|
|
||
| #[cfg(not(windows))] | ||
| run_standalone(run_parameters, remove_log_file_signal, shutdown_token).await?; | ||
|
|
||
| let _worker_guard = if let Some(setup) = logging_setup { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary changes here, you can revert the whole file |
||
| if setup.log_file_remover_join_handle.await.is_err() { | ||
| tracing::error!("Failed to join on file logging handle"); | ||
|
|
@@ -204,7 +203,6 @@ impl VpnServiceHandle { | |
| if let Err(e) = self.vpn_service_handle.await { | ||
| tracing::error!("Failed to join on vpn service: {}", e); | ||
| } | ||
|
|
||
| self.command_shutdown_token.cancel(); | ||
|
|
||
| if let Err(e) = self.command_handle.await { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it, we need another name for that option, looking at it, I have zero clue of what it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently have a
disable_poisson_ratefield in theVpnServiceConfigbut it doesn't appear to be used for anything useful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it, this and
disable_poisson_rateare redundant!We could "merge" them and
disable_poisson_ratewould have the same effect as settingpoisson_parameterto 0, i.e. disable the real traffic poisson