diff --git a/config/src/comments.rs b/config/src/comments.rs index 64b4be7bd..326272b6a 100644 --- a/config/src/comments.rs +++ b/config/src/comments.rs @@ -136,7 +136,7 @@ fn comments() -> HashMap { #transport = \"https\" #Proxy address, eg IP:PORT or Hostname -#server = \"IP:PORT\" +#server = \"\" #Username for the proxy server authentification #user = \"\" @@ -261,6 +261,7 @@ fn comments() -> HashMap { " #Tor bridge relay: allow to send and receive via TOR in a country where it is censored. #Enable it by entering a single bridge line. To disable it, you must comment it. +#Support of the transport: obfs4, meek and snowflake. #obfs4proxy or snowflake client binary must be installed and on your path. #For example, the bridge line must be in the following format for obfs4 transport: \"obfs4 [IP:PORT] [FINGERPRINT] cert=[CERT] iat-mode=[IAT-MODE]\" #bridge_line = \"\" @@ -314,7 +315,7 @@ pub fn migrate_comments( old_version: Option, ) -> String { let comments = comments(); - // Prohibe the old key we are basing on to introduce new comments + // Prohibe the key we are basing on to introduce new comments for [tor.proxy] let prohibited_key = match old_version { None => vec!["[logging]"], Some(_) => vec![], @@ -377,18 +378,18 @@ pub fn migrate_comments( let key_fmt = format!("{}\n", key_line); if old_key_exist { if prohibited_key.contains(&key.as_str()) { - // push new config comment + // push new config key/comments let value = comments.get(&key).unwrap(); new_config_str.push_str(value); new_config_str.push_str(&key_fmt); } else { - // push old config comment + // push old config key/comment let value = hm_key_cmt_old.get(&key).unwrap(); new_config_str.push_str(value); new_config_str.push_str(&key_fmt); } } else { - // old key does not exist, we push new comments + // old key does not exist, we push new key/comments let value = comments.get(&key).unwrap(); new_config_str.push_str(value); new_config_str.push_str(&key_fmt); diff --git a/config/src/config.rs b/config/src/config.rs index 6d464d65b..97b5fe058 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -331,7 +331,7 @@ impl GlobalWalletConfig { } /// This migration does the following: /// - Adds "config_file_version = 2" - /// - Introduce new commented key [tor.bridge] and [tor.proxy] + /// - Introduce new key config_file_version, [tor.bridge] and [tor.proxy] /// - Migrate old config key/value and comments while it does not conflict with newly indroduced key and comments fn migrate_config_file_version_none_to_2( config_str: String, diff --git a/controller/src/command.rs b/controller/src/command.rs index 074edb685..a736cdb92 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -338,7 +338,9 @@ where let tor_config = match tor_config { Some(mut c) => { - c.bridge.bridge_line = args.bridge.clone(); + if let Some(b) = args.bridge.clone() { + c.bridge.bridge_line = Some(b); + } c.skip_send_attempt = Some(args.skip_tor); Some(c) } @@ -532,6 +534,7 @@ pub struct ReceiveArgs { pub input_slatepack_message: Option, pub skip_tor: bool, pub outfile: Option, + pub bridge: Option, } pub fn receive( @@ -561,6 +564,9 @@ where let tor_config = match tor_config { Some(mut c) => { + if let Some(b) = args.bridge { + c.bridge.bridge_line = Some(b); + } c.skip_send_attempt = Some(args.skip_tor); Some(c) } @@ -816,6 +822,7 @@ pub struct ProcessInvoiceArgs { pub ttl_blocks: Option, pub skip_tor: bool, pub outfile: Option, + pub bridge: Option, } /// Process invoice @@ -892,6 +899,9 @@ where let tor_config = match tor_config { Some(mut c) => { + if let Some(b) = args.bridge { + c.bridge.bridge_line = Some(b); + } c.skip_send_attempt = Some(args.skip_tor); Some(c) } diff --git a/impls/src/tor/bridge.rs b/impls/src/tor/bridge.rs index e2d3a7fec..a924092b5 100644 --- a/impls/src/tor/bridge.rs +++ b/impls/src/tor/bridge.rs @@ -274,7 +274,7 @@ impl PluginClient { FlagParser::new(s, flags, bool_flags, true).collect() } - /// Try to find the plugin client path in the env var + /// Try to find the plugin client path pub fn get_client_path(plugin: &str) -> Result { let plugin_path = env::var_os("PATH").and_then(|path| { env::split_paths(&path) @@ -291,7 +291,7 @@ impl PluginClient { match plugin_path { Some(path) => Ok(path.into_os_string().into_string().unwrap()), None => { - let msg = format!("Transport plugin client \"{}\" is missing, make sure it's installed and in your path.", plugin); + let msg = format!("Transport client \"{}\" is missing, make sure it's installed and on your path.", plugin); return Err(ErrorKind::TorBridge(msg).into()); } } @@ -327,7 +327,7 @@ impl PluginClient { let ice_addr = arg.trim(); let vec_ice_addr = ice_addr.split(","); for addr in vec_ice_addr { - addr.to_lowercase(); + let addr = addr.to_lowercase(); if addr.starts_with("stun:") || addr.starts_with("turn:") { let address = addr.replace("stun:", "").replace("turn:", ""); let _p_address = TorProxy::parse_address(&address) diff --git a/src/bin/grin-wallet.yml b/src/bin/grin-wallet.yml index 798253d90..1dd754b2d 100644 --- a/src/bin/grin-wallet.yml +++ b/src/bin/grin-wallet.yml @@ -155,7 +155,7 @@ subcommands: long: outfile takes_value: true - bridge: - help: Enable bridge relay when sending via Slatepack workflow + help: Enable tor bridge relay when sending via Slatepack workflow short: g long: bridge takes_value: true @@ -184,6 +184,11 @@ subcommands: short: u long: outfile takes_value: true + - bridge: + help: Enable tor bridge relay when receiving via Slatepack workflow + short: g + long: bridge + takes_value: true - finalize: about: Processes a Slatepack Message to finalize a transfer. args: @@ -267,6 +272,11 @@ subcommands: short: u long: outfile takes_value: true + - bridge: + help: Enable tor bridge relay when paying invoice. + short: g + long: bridge + takes_value: true - outputs: about: Raw wallet output info (list of outputs) - txs: diff --git a/src/cmd/wallet_args.rs b/src/cmd/wallet_args.rs index 911b18d73..bbf28ed6e 100644 --- a/src/cmd/wallet_args.rs +++ b/src/cmd/wallet_args.rs @@ -544,11 +544,14 @@ pub fn parse_receive_args(args: &ArgMatches) -> Result Result