Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5016a9f
udpate for beta release
Sep 24, 2019
5d4775f
initial tor explorations
Sep 26, 2019
99677cc
rustfmt
Sep 26, 2019
555c353
Merge branch 'master' into tor_test
Sep 26, 2019
a420915
basic tor tx send working
Sep 27, 2019
f28a414
rustfmt
Sep 27, 2019
67f5b14
add tor proxy info to config file
Sep 27, 2019
3344327
rustfmt
Sep 27, 2019
0edf1eb
add utilities to output tor hidden service configuration files
Oct 1, 2019
55b65bd
output tor config as part of listener startup
Oct 2, 2019
742a70a
rustfmt
Oct 2, 2019
1f53ad0
fully automate config and startup of tor process
Oct 2, 2019
43695c1
rustfmt
Oct 2, 2019
1ad3648
remove unnecessary process kill commands from listener
Oct 2, 2019
a8ff3e1
rustfmt
Oct 2, 2019
1cf25c9
assume defaults for tor sending config if section doesn't exist in gr…
Oct 4, 2019
39b5789
rustfmt
Oct 4, 2019
ebba417
ignore tor dev test
Oct 4, 2019
0a6a475
merge from master
Oct 4, 2019
84dd957
update default paths output by config, compilation + confirmed workin…
Oct 7, 2019
2f4b202
rustfmt
Oct 7, 2019
897a435
fix on osx/unix
Oct 7, 2019
9a8c54e
add timeout to tor connector, remove unwrap in client
Oct 7, 2019
67761a6
allow specifiying tor address without 'http://[].onion' on the comman…
Oct 7, 2019
c5f38ab
fix api test
Oct 7, 2019
fad3bb0
update from master
Oct 10, 2019
1e9f509
rustfmt
Oct 10, 2019
804b3db
update address derivation path as per spec
Oct 10, 2019
19acf41
rustfmt
Oct 10, 2019
ffc868c
move tor init to separate function
Oct 10, 2019
5ae7034
rustfmt
Oct 10, 2019
2d73a8a
re-ignore tor dev test
Oct 10, 2019
ad1be6d
Cargo.lock
Oct 11, 2019
da13ce7
listen on tor by default if tor available
Oct 14, 2019
cfba422
rustfmt
Oct 14, 2019
6afbe7e
test fix
Oct 14, 2019
d11f2a3
remove explicit send via tor flag, and assume tor if address fits
Oct 14, 2019
b55f361
rustfmt
Oct 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 245 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions api/src/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use chrono::prelude::*;
use uuid::Uuid;

use crate::config::WalletConfig;
use crate::config::{TorConfig, WalletConfig};
use crate::core::core::Transaction;
use crate::core::global;
use crate::impls::create_sender;
Expand Down Expand Up @@ -579,7 +579,8 @@ where
.into());
}
};
let comm_adapter = create_sender(&sa.method, &sa.dest)
//TODO: no TOR just now via this method, to keep compatibility for now
let comm_adapter = create_sender(&sa.method, &sa.dest, None)
.map_err(|e| ErrorKind::GenericError(format!("{}", e)))?;
slate = comm_adapter.send_tx(&slate)?;
self.tx_lock_outputs(keychain_mask, &slate, 0)?;
Expand Down Expand Up @@ -1361,7 +1362,7 @@ where
/// let api_owner = Owner::new(wallet.clone());
/// let _ = api_owner.set_top_level_directory(dir);
///
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None);
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None, None);
///
/// if let Ok(_) = result {
/// //...
Expand All @@ -1373,6 +1374,7 @@ where
chain_type: &global::ChainTypes,
wallet_config: Option<WalletConfig>,
logging_config: Option<LoggingConfig>,
tor_config: Option<TorConfig>,
) -> Result<(), Error> {
let mut w_lock = self.wallet_inst.lock();
let lc = w_lock.lc_provider()?;
Expand All @@ -1381,6 +1383,7 @@ where
"grin-wallet.toml",
wallet_config,
logging_config,
tor_config,
)
}

Expand Down Expand Up @@ -1429,7 +1432,7 @@ where
/// let _ = api_owner.set_top_level_directory(dir);
///
/// // Create configuration
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None);
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None, None);
///
/// // create new wallet wirh random seed
/// let pw = ZeroingString::from("my_password");
Expand Down Expand Up @@ -1496,7 +1499,7 @@ where
/// let _ = api_owner.set_top_level_directory(dir);
///
/// // Create configuration
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None);
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None, None);
///
/// // create new wallet wirh random seed
/// let pw = ZeroingString::from("my_password");
Expand Down
12 changes: 10 additions & 2 deletions api/src/owner_rpc_s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! JSON-RPC Stub generation for the Owner API
use uuid::Uuid;

use crate::config::WalletConfig;
use crate::config::{TorConfig, WalletConfig};
use crate::core::core::Transaction;
use crate::core::global;
use crate::keychain::{Identifier, Keychain};
Expand Down Expand Up @@ -1469,6 +1469,11 @@ pub trait OwnerRpcS {
"log_max_size": null,
"log_max_files": null,
"tui_running": null
},
"tor_config" : {
"default_send_via_tor": false,
"socks_proxy_addr": "127.0.0.1:9050",
"send_config_dir": "."
}
},
"id": 1
Expand All @@ -1492,6 +1497,7 @@ pub trait OwnerRpcS {
chain_type: global::ChainTypes,
wallet_config: Option<WalletConfig>,
logging_config: Option<LoggingConfig>,
tor_config: Option<TorConfig>,
) -> Result<(), ErrorKind>;

/**
Expand Down Expand Up @@ -1912,8 +1918,10 @@ where
chain_type: global::ChainTypes,
wallet_config: Option<WalletConfig>,
logging_config: Option<LoggingConfig>,
tor_config: Option<TorConfig>,
) -> Result<(), ErrorKind> {
Owner::create_config(self, &chain_type, wallet_config, logging_config).map_err(|e| e.kind())
Owner::create_config(self, &chain_type, wallet_config, logging_config, tor_config)
.map_err(|e| e.kind())
}

fn create_wallet(
Expand Down
43 changes: 43 additions & 0 deletions config/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,49 @@ fn comments() -> HashMap<String, String> {
.to_string(),
);

retval.insert(
"[tor]".to_string(),
"
#########################################
### TOR CONFIGURATION (Experimental) ###
#########################################
"
.to_string(),
);

retval.insert(
"default_send_via_tor".to_string(),
"
#Whether to default all http sends via the configured TOR proxy
#(Not currently used, reserved for future use)
"
.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
}

Expand Down
11 changes: 10 additions & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -153,6 +153,7 @@ impl Default for GlobalWalletConfigMembers {
fn default() -> GlobalWalletConfigMembers {
GlobalWalletConfigMembers {
logging: Some(LoggingConfig::default()),
tor: Some(TorConfig::default()),
wallet: WalletConfig::default(),
}
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
23 changes: 23 additions & 0 deletions config/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ impl fmt::Display for ConfigError {
}
}

/// Tor configuration
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct TorConfig {
/// Whether to use tor for all communication with other wallets
/// by default (not used at present, reserved for future use)
pub default_send_via_tor: 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 {
default_send_via_tor: false,
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(
Expand All @@ -162,6 +183,8 @@ pub struct GlobalWalletConfigMembers {
/// Wallet configuration
#[serde(default)]
pub wallet: WalletConfig,
/// Tor config
pub tor: Option<TorConfig>,
/// Logging config
pub logging: Option<LoggingConfig>,
}
24 changes: 20 additions & 4 deletions controller/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! Grin wallet command-line function implementations

use crate::api::TLSConfig;
use crate::config::{WalletConfig, WALLET_CONFIG_FILE_NAME};
use crate::config::{TorConfig, WalletConfig, WALLET_CONFIG_FILE_NAME};
use crate::core::{core, global};
use crate::error::{Error, ErrorKind};
use crate::impls::{create_sender, KeybaseAllChannels, SlateGetter as _, SlateReceiver as _};
Expand Down Expand Up @@ -75,7 +75,13 @@ where
{
let mut w_lock = wallet.lock();
let p = w_lock.lc_provider()?;
p.create_config(&g_args.chain_type, WALLET_CONFIG_FILE_NAME, None, None)?;
p.create_config(
&g_args.chain_type,
WALLET_CONFIG_FILE_NAME,
None,
None,
None,
)?;
p.create_wallet(
None,
args.recovery_phrase,
Expand Down Expand Up @@ -139,6 +145,14 @@ where
keychain_mask,
&config.api_listen_addr(),
g_args.tls_conf.clone(),
false,
),
"tor" => controller::foreign_listener(
wallet.clone(),
keychain_mask,
&config.api_listen_addr(),
g_args.tls_conf.clone(),
true,
),
"keybase" => KeybaseAllChannels::new()?.listen(
config.clone(),
Expand Down Expand Up @@ -251,6 +265,7 @@ pub struct SendArgs {
pub fn send<'a, L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
keychain_mask: Option<&SecretKey>,
tor_config: Option<TorConfig>,
args: SendArgs,
dark_scheme: bool,
) -> Result<(), Error>
Expand Down Expand Up @@ -327,7 +342,7 @@ where
})?;
}
method => {
let sender = create_sender(method, &args.dest)?;
let sender = create_sender(method, &args.dest, tor_config)?;
slate = sender.send_tx(&slate)?;
api.tx_lock_outputs(m, &slate, 0)?;
}
Expand Down Expand Up @@ -514,6 +529,7 @@ pub struct ProcessInvoiceArgs {
pub fn process_invoice<'a, L, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
keychain_mask: Option<&SecretKey>,
tor_config: Option<TorConfig>,
args: ProcessInvoiceArgs,
dark_scheme: bool,
) -> Result<(), Error>
Expand Down Expand Up @@ -594,7 +610,7 @@ where
})?;
}
method => {
let sender = create_sender(method, &args.dest)?;
let sender = create_sender(method, &args.dest, tor_config)?;
slate = sender.send_tx(&slate)?;
api.tx_lock_outputs(m, &slate, 0)?;
}
Expand Down
Loading