mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 15:21:39 +02:00
Optional Tor Send/Listen Functionality (#226)
* udpate for beta release * initial tor explorations * rustfmt * basic tor tx send working * rustfmt * add tor proxy info to config file * rustfmt * add utilities to output tor hidden service configuration files * output tor config as part of listener startup * rustfmt * fully automate config and startup of tor process * rustfmt * remove unnecessary process kill commands from listener * rustfmt * assume defaults for tor sending config if section doesn't exist in grin-wallet.toml * rustfmt * ignore tor dev test * update default paths output by config, compilation + confirmed working on windows * rustfmt * fix on osx/unix * add timeout to tor connector, remove unwrap in client * allow specifiying tor address without 'http://[].onion' on the command line * fix api test * rustfmt * update address derivation path as per spec * rustfmt * move tor init to separate function * rustfmt * re-ignore tor dev test * listen on tor by default if tor available * rustfmt * test fix * remove explicit send via tor flag, and assume tor if address fits * rustfmt
This commit is contained in:
@@ -190,6 +190,48 @@ fn comments() -> HashMap<String, String> {
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
retval.insert(
|
||||
"[tor]".to_string(),
|
||||
"
|
||||
#########################################
|
||||
### TOR CONFIGURATION (Experimental) ###
|
||||
#########################################
|
||||
"
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
retval.insert(
|
||||
"use_tor_listener".to_string(),
|
||||
"
|
||||
#Whether to start tor listener on listener startup (default true)
|
||||
"
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
retval.insert(
|
||||
"socks_proxy_addr".to_string(),
|
||||
"
|
||||
#Address of the running TOR (SOCKS) server
|
||||
"
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
retval.insert(
|
||||
"socks_proxy_addr".to_string(),
|
||||
"
|
||||
# TOR (SOCKS) proxy server address
|
||||
"
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
retval.insert(
|
||||
"send_config_dir".to_string(),
|
||||
"
|
||||
#Directory to output TOR configuration to when sending
|
||||
"
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
retval
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -27,8 +27,8 @@ use toml;
|
||||
|
||||
use crate::comments::insert_comments;
|
||||
use crate::core::global;
|
||||
use crate::types::WalletConfig;
|
||||
use crate::types::{ConfigError, GlobalWalletConfig, GlobalWalletConfigMembers};
|
||||
use crate::types::{TorConfig, WalletConfig};
|
||||
use crate::util::LoggingConfig;
|
||||
|
||||
/// Wallet configuration file name
|
||||
@@ -153,6 +153,7 @@ impl Default for GlobalWalletConfigMembers {
|
||||
fn default() -> GlobalWalletConfigMembers {
|
||||
GlobalWalletConfigMembers {
|
||||
logging: Some(LoggingConfig::default()),
|
||||
tor: Some(TorConfig::default()),
|
||||
wallet: WalletConfig::default(),
|
||||
}
|
||||
}
|
||||
@@ -257,6 +258,14 @@ impl GlobalWalletConfig {
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.log_file_path = log_path.to_str().unwrap().to_owned();
|
||||
let tor_path = wallet_home.clone();
|
||||
self.members
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.tor
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.send_config_dir = tor_path.to_str().unwrap().to_owned();
|
||||
}
|
||||
|
||||
/// Serialize config
|
||||
|
||||
+3
-1
@@ -31,4 +31,6 @@ pub mod config;
|
||||
pub mod types;
|
||||
|
||||
pub use crate::config::{initial_setup_wallet, GRIN_WALLET_DIR, WALLET_CONFIG_FILE_NAME};
|
||||
pub use crate::types::{ConfigError, GlobalWalletConfig, GlobalWalletConfigMembers, WalletConfig};
|
||||
pub use crate::types::{
|
||||
ConfigError, GlobalWalletConfig, GlobalWalletConfigMembers, TorConfig, WalletConfig,
|
||||
};
|
||||
|
||||
@@ -138,6 +138,26 @@ impl fmt::Display for ConfigError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Tor configuration
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct TorConfig {
|
||||
/// Whether to start tor listener on listener startup (default true)
|
||||
pub use_tor_listener: bool,
|
||||
/// Just the address of the socks proxy for now
|
||||
pub socks_proxy_addr: String,
|
||||
/// Send configuration directory
|
||||
pub send_config_dir: String,
|
||||
}
|
||||
|
||||
impl Default for TorConfig {
|
||||
fn default() -> TorConfig {
|
||||
TorConfig {
|
||||
use_tor_listener: true,
|
||||
socks_proxy_addr: "127.0.0.1:59050".to_owned(),
|
||||
send_config_dir: ".".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<io::Error> for ConfigError {
|
||||
fn from(error: io::Error) -> ConfigError {
|
||||
ConfigError::FileIOError(
|
||||
@@ -162,6 +182,8 @@ pub struct GlobalWalletConfigMembers {
|
||||
/// Wallet configuration
|
||||
#[serde(default)]
|
||||
pub wallet: WalletConfig,
|
||||
/// Tor config
|
||||
pub tor: Option<TorConfig>,
|
||||
/// Logging config
|
||||
pub logging: Option<LoggingConfig>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user