From 338613362d5b73f2cfb0cfccd2c1dbcc3ac88d0f Mon Sep 17 00:00:00 2001 From: Simon Wicky Date: Wed, 22 Nov 2023 10:13:45 +0100 Subject: [PATCH] offline/online toggle for gateway --- gateway/src/commands/helpers.rs | 5 +++++ gateway/src/commands/init.rs | 6 ++++++ gateway/src/commands/run.rs | 5 +++++ gateway/src/config/mod.rs | 13 +++++++++++++ gateway/src/config/old_config_v1_1_29.rs | 3 +++ gateway/src/config/template.rs | 3 +++ 6 files changed, 35 insertions(+) diff --git a/gateway/src/commands/helpers.rs b/gateway/src/commands/helpers.rs index 3b97212ae6..1085bce787 100644 --- a/gateway/src/commands/helpers.rs +++ b/gateway/src/commands/helpers.rs @@ -40,6 +40,7 @@ pub(crate) struct OverrideConfig { pub(crate) mnemonic: Option, pub(crate) nyxd_urls: Option>, pub(crate) only_coconut_credentials: Option, + pub(crate) offline_credential_verification: Option, pub(crate) with_network_requester: Option, pub(crate) with_ip_packet_router: Option, } @@ -76,6 +77,10 @@ impl OverrideConfig { Config::with_only_coconut_credentials, self.only_coconut_credentials, ) + .with_optional( + Config::with_offline_credential_verification, + self.offline_credential_verification, + ) .with_optional( Config::with_enabled_network_requester, self.with_network_requester, diff --git a/gateway/src/commands/init.rs b/gateway/src/commands/init.rs index bfa12bd66d..5ff42f4256 100644 --- a/gateway/src/commands/init.rs +++ b/gateway/src/commands/init.rs @@ -73,6 +73,10 @@ pub struct Init { #[clap(long, hide = true)] only_coconut_credentials: Option, + /// Set this gateway to use offline credentials verification + #[clap(long, hide = true)] + offline_credential_verification: Option, + /// Enable/disable gateway anonymized statistics that get sent to a statistics aggregator server #[clap(long)] enabled_statistics: Option, @@ -160,6 +164,7 @@ impl From for OverrideConfig { nyxd_urls: init_config.nyxd_urls, only_coconut_credentials: init_config.only_coconut_credentials, + offline_credential_verification: init_config.offline_credential_verification, with_network_requester: Some(init_config.with_network_requester), with_ip_packet_router: Some(init_config.with_ip_packet_router), } @@ -292,6 +297,7 @@ mod tests { enabled_statistics: None, nyxd_urls: None, only_coconut_credentials: None, + offline_credential_verification: None, output: Default::default(), with_network_requester: false, with_ip_packet_router: false, diff --git a/gateway/src/commands/run.rs b/gateway/src/commands/run.rs index 76f7629de5..6ff9ef2282 100644 --- a/gateway/src/commands/run.rs +++ b/gateway/src/commands/run.rs @@ -78,6 +78,10 @@ pub struct Run { #[arg(long, hide = true)] only_coconut_credentials: Option, + /// Set this gateway to use offline credentials verification + #[clap(long, hide = true)] + offline_credential_verification: Option, + /// Enable/disable gateway anonymized statistics that get sent to a statistics aggregator server #[arg(long)] enabled_statistics: Option, @@ -162,6 +166,7 @@ impl From for OverrideConfig { statistics_service_url: run_config.statistics_service_url, nyxd_urls: run_config.nyxd_urls, only_coconut_credentials: run_config.only_coconut_credentials, + offline_credential_verification: run_config.offline_credential_verification, with_network_requester: run_config.with_network_requester, with_ip_packet_router: run_config.with_ip_packet_router, } diff --git a/gateway/src/config/mod.rs b/gateway/src/config/mod.rs index b872a1dffd..4696beb2f5 100644 --- a/gateway/src/config/mod.rs +++ b/gateway/src/config/mod.rs @@ -217,6 +217,14 @@ impl Config { self } + pub fn with_offline_credential_verification( + mut self, + offline_credential_verification: bool, + ) -> Self { + self.gateway.offline_credential_verification = offline_credential_verification; + self + } + pub fn with_enabled_statistics(mut self, enabled_statistics: bool) -> Self { self.gateway.enabled_statistics = enabled_statistics; self @@ -299,6 +307,10 @@ pub struct Gateway { #[serde(default)] pub only_coconut_credentials: bool, + /// Indicates whether this gateway is using offline mode for credential verification + #[serde(default)] + pub offline_credential_verification: bool, + /// Address to which this mixnode will bind to and will be listening for packets. #[zeroize(skip)] pub listening_address: IpAddr, @@ -347,6 +359,7 @@ impl Gateway { version: env!("CARGO_PKG_VERSION").to_string(), id: id.into(), only_coconut_credentials: false, + offline_credential_verification: false, listening_address: inaddr_any(), mix_port: DEFAULT_MIX_LISTENING_PORT, clients_port: DEFAULT_CLIENT_LISTENING_PORT, diff --git a/gateway/src/config/old_config_v1_1_29.rs b/gateway/src/config/old_config_v1_1_29.rs index 48ca3d14fb..8d5d78e222 100644 --- a/gateway/src/config/old_config_v1_1_29.rs +++ b/gateway/src/config/old_config_v1_1_29.rs @@ -127,6 +127,9 @@ impl From for ConfigV1_1_31 { version: value.gateway.version, id: value.gateway.id, only_coconut_credentials: value.gateway.only_coconut_credentials, + // \/ ADDED + offline_credential_verification: false, + // /\ ADDED listening_address: value.gateway.listening_address, mix_port: value.gateway.mix_port, clients_port: value.gateway.clients_port, diff --git a/gateway/src/config/template.rs b/gateway/src/config/template.rs index 1b6ac71262..d396986fd5 100644 --- a/gateway/src/config/template.rs +++ b/gateway/src/config/template.rs @@ -33,6 +33,9 @@ id = '{{ gateway.id }}' # the mixnet, or if it also accepts non-paying clients only_coconut_credentials = {{ gateway.only_coconut_credentials }} +# Indicates whether this gateway is using offline mode for credential verification +offline_credential_verification = {{ gateway.offline_credential_verification }} + # Socket address to which this gateway will bind to and will be listening for packets. listening_address = '{{ gateway.listening_address }}'