Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Rename cli and config options signer->ui #3232

Merged
merged 2 commits into from
Nov 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion parity/cli/config.full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unlock = ["0xdeadbeefcafe0000000000000000000000000000"]
password = ["~/.safe/password.file"]
keys_iterations = 10240

[signer]
[ui]
force = false
disable = false
port = 8180
Expand Down
2 changes: 1 addition & 1 deletion parity/cli/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ chain = "./chain.json"
unlock = ["0x1", "0x2", "0x3"]
password = ["passwdfile path"]

[signer]
[ui]
disable = true

[network]
Expand Down
42 changes: 21 additions & 21 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ usage! {
flag_keys_iterations: u32 = 10240u32,
or |c: &Config| otry!(c.account).keys_iterations.clone(),

flag_force_signer: bool = false,
or |c: &Config| otry!(c.signer).force.clone(),
flag_no_signer: bool = false,
or |c: &Config| otry!(c.signer).disable.clone(),
flag_signer_port: u16 = 8180u16,
or |c: &Config| otry!(c.signer).port.clone(),
flag_signer_interface: String = "local",
or |c: &Config| otry!(c.signer).interface.clone(),
flag_signer_path: String = "$HOME/.parity/signer",
or |c: &Config| otry!(c.signer).path.clone(),
flag_force_ui: bool = false,
or |c: &Config| otry!(c.ui).force.clone(),
flag_no_ui: bool = false,
or |c: &Config| otry!(c.ui).disable.clone(),
flag_ui_port: u16 = 8180u16,
or |c: &Config| otry!(c.ui).port.clone(),
flag_ui_interface: String = "local",
or |c: &Config| otry!(c.ui).interface.clone(),
flag_ui_path: String = "$HOME/.parity/signer",
or |c: &Config| otry!(c.ui).path.clone(),
// NOTE [todr] For security reasons don't put this to config files
flag_signer_no_validation: bool = false, or |_| None,
flag_ui_no_validation: bool = false, or |_| None,

// -- Networking Options
flag_warp: bool = false,
Expand Down Expand Up @@ -271,7 +271,7 @@ usage! {
struct Config {
parity: Option<Operating>,
account: Option<Account>,
signer: Option<Signer>,
ui: Option<Ui>,
network: Option<Network>,
rpc: Option<Rpc>,
ipc: Option<Ipc>,
Expand Down Expand Up @@ -302,7 +302,7 @@ struct Account {
}

#[derive(Default, Debug, PartialEq, RustcDecodable)]
struct Signer {
struct Ui {
force: Option<bool>,
disable: Option<bool>,
port: Option<u16>,
Expand Down Expand Up @@ -418,7 +418,7 @@ struct Misc {
mod tests {
use super::{
Args, ArgsError,
Config, Operating, Account, Signer, Network, Rpc, Ipc, Dapps, Mining, Footprint, Snapshots, VM, Misc
Config, Operating, Account, Ui, Network, Rpc, Ipc, Dapps, Mining, Footprint, Snapshots, VM, Misc
};
use toml;

Expand Down Expand Up @@ -511,12 +511,12 @@ mod tests {
flag_password: vec!["~/.safe/password.file".into()],
flag_keys_iterations: 10240u32,

flag_force_signer: false,
flag_no_signer: false,
flag_signer_port: 8180u16,
flag_signer_interface: "127.0.0.1".into(),
flag_signer_path: "$HOME/.parity/signer".into(),
flag_signer_no_validation: false,
flag_force_ui: false,
flag_no_ui: false,
flag_ui_port: 8180u16,
flag_ui_interface: "127.0.0.1".into(),
flag_ui_path: "$HOME/.parity/signer".into(),
flag_ui_no_validation: false,

// -- Networking Options
flag_warp: true,
Expand Down Expand Up @@ -675,7 +675,7 @@ mod tests {
password: Some(vec!["passwdfile path".into()]),
keys_iterations: None,
}),
signer: Some(Signer {
ui: Some(Ui {
force: None,
disable: Some(true),
port: None,
Expand Down
31 changes: 16 additions & 15 deletions parity/cli/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,29 @@ Operating Options:
Account Options:
--unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution.
ACCOUNTS is a comma-delimited list of addresses.
Implies --no-signer. (default: {flag_unlock:?})
Implies --no-ui. (default: {flag_unlock:?})
--password FILE Provide a file containing a password for unlocking
an account. Leading and trailing whitespace is trimmed.
(default: {flag_password:?})
--keys-iterations NUM Specify the number of iterations to use when
deriving key from the password (bigger is more
secure) (default: {flag_keys_iterations}).
--force-signer Enable Trusted Signer WebSocket endpoint used by
Signer UIs, even when --unlock is in use.
(default: ${flag_force_signer})
--no-signer Disable Trusted Signer WebSocket endpoint used by
Signer UIs. (default: ${flag_no_signer})
--signer-port PORT Specify the port of Trusted Signer server
(default: {flag_signer_port}).
--signer-interface IP Specify the hostname portion of the Trusted Signer

UI Options:
--force-ui Enable Trusted UI WebSocket endpoint,
even when --unlock is in use. (default: ${flag_force_ui})
--no-ui Disable Trusted UI WebSocket endpoint.
(default: ${flag_no_ui})
--ui-port PORT Specify the port of Trusted UI server
(default: {flag_ui_port}).
--ui-interface IP Specify the hostname portion of the Trusted UI
server, IP should be an interface's IP address,
or local (default: {flag_signer_interface}).
--signer-path PATH Specify directory where Signer UIs tokens should
be stored. (default: {flag_signer_path})
--signer-no-validation Disable Origin and Host headers validation for
Trusted Signer. WARNING: INSECURE. Used only for
development. (default: {flag_signer_no_validation})
or local (default: {flag_ui_interface}).
--ui-path PATH Specify directory where Trusted UIs tokens should
be stored. (default: {flag_ui_path})
--ui-no-validation Disable Origin and Host headers validation for
Trusted UI. WARNING: INSECURE. Used only for
development. (default: {flag_ui_no_validation})

Networking Options:
--warp Enable syncing from the snapshot over the network. (default: {flag_warp})
Expand Down
54 changes: 27 additions & 27 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Configuration {
let wal = !self.args.flag_fast_and_loose;
let warp_sync = self.args.flag_warp;
let geth_compatibility = self.args.flag_geth;
let signer_port = self.signer_port();
let ui_port = self.ui_port();
let dapps_conf = self.dapps_config();
let signer_conf = self.signer_config();
let format = try!(self.format());
Expand Down Expand Up @@ -243,7 +243,7 @@ impl Configuration {
vm_type: vm_type,
warp_sync: warp_sync,
geth_compatibility: geth_compatibility,
signer_port: signer_port,
ui_port: ui_port,
net_settings: self.network_settings(),
dapps_conf: dapps_conf,
signer_conf: signer_conf,
Expand Down Expand Up @@ -396,11 +396,11 @@ impl Configuration {

fn signer_config(&self) -> SignerConfiguration {
SignerConfiguration {
enabled: self.signer_enabled(),
port: self.args.flag_signer_port,
interface: self.signer_interface(),
enabled: self.ui_enabled(),
port: self.args.flag_ui_port,
interface: self.ui_interface(),
signer_path: self.directories().signer,
skip_origin_validation: self.args.flag_signer_no_validation,
skip_origin_validation: self.args.flag_ui_no_validation,
}
}

Expand Down Expand Up @@ -595,7 +595,7 @@ impl Configuration {
);

let dapps_path = replace_home(&self.args.flag_dapps_path);
let signer_path = replace_home(&self.args.flag_signer_path);
let ui_path = replace_home(&self.args.flag_ui_path);

if self.args.flag_geth && !cfg!(windows) {
let geth_root = if self.args.flag_testnet { path::ethereum::test() } else { path::ethereum::default() };
Expand All @@ -616,7 +616,7 @@ impl Configuration {
keys: keys_path,
db: db_path,
dapps: dapps_path,
signer: signer_path,
signer: ui_path,
}
}

Expand All @@ -628,16 +628,16 @@ impl Configuration {
}
}

fn signer_port(&self) -> Option<u16> {
if !self.signer_enabled() {
fn ui_port(&self) -> Option<u16> {
if !self.ui_enabled() {
None
} else {
Some(self.args.flag_signer_port)
Some(self.args.flag_ui_port)
}
}

fn signer_interface(&self) -> String {
match self.args.flag_signer_interface.as_str() {
fn ui_interface(&self) -> String {
match self.args.flag_ui_interface.as_str() {
"local" => "127.0.0.1",
x => x,
}.into()
Expand All @@ -662,16 +662,16 @@ impl Configuration {
!self.args.flag_dapps_off && !self.args.flag_no_dapps && cfg!(feature = "dapps")
}

fn signer_enabled(&self) -> bool {
if self.args.flag_force_signer {
fn ui_enabled(&self) -> bool {
if self.args.flag_force_ui {
return true;
}

let signer_disabled = self.args.flag_unlock.is_some() ||
let ui_disabled = self.args.flag_unlock.is_some() ||
self.args.flag_geth ||
self.args.flag_no_signer;
self.args.flag_no_ui;

!signer_disabled
!ui_disabled
}
}

Expand Down Expand Up @@ -853,7 +853,7 @@ mod tests {
wal: true,
vm_type: Default::default(),
geth_compatibility: false,
signer_port: Some(8180),
ui_port: Some(8180),
net_settings: Default::default(),
dapps_conf: Default::default(),
signer_conf: Default::default(),
Expand Down Expand Up @@ -976,11 +976,11 @@ mod tests {

// when
let conf0 = parse(&["parity", "--geth"]);
let conf1 = parse(&["parity", "--geth", "--force-signer"]);
let conf1 = parse(&["parity", "--geth", "--force-ui"]);

// then
assert_eq!(conf0.signer_enabled(), false);
assert_eq!(conf1.signer_enabled(), true);
assert_eq!(conf0.ui_enabled(), false);
assert_eq!(conf1.ui_enabled(), true);
}

#[test]
Expand All @@ -991,18 +991,18 @@ mod tests {
let conf0 = parse(&["parity", "--unlock", "0x0"]);

// then
assert_eq!(conf0.signer_enabled(), false);
assert_eq!(conf0.ui_enabled(), false);
}

#[test]
fn should_parse_signer_configration() {
// given

// when
let conf0 = parse(&["parity", "--signer-path", "signer"]);
let conf1 = parse(&["parity", "--signer-path", "signer", "--signer-no-validation"]);
let conf2 = parse(&["parity", "--signer-path", "signer", "--signer-port", "3123"]);
let conf3 = parse(&["parity", "--signer-path", "signer", "--signer-interface", "test"]);
let conf0 = parse(&["parity", "--ui-path", "signer"]);
let conf1 = parse(&["parity", "--ui-path", "signer", "--ui-no-validation"]);
let conf2 = parse(&["parity", "--ui-path", "signer", "--ui-port", "3123"]);
let conf3 = parse(&["parity", "--ui-path", "signer", "--ui-interface", "test"]);

// then
assert_eq!(conf0.signer_config(), SignerConfiguration {
Expand Down
4 changes: 2 additions & 2 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct RunCmd {
pub wal: bool,
pub vm_type: VMType,
pub geth_compatibility: bool,
pub signer_port: Option<u16>,
pub ui_port: Option<u16>,
pub net_settings: NetworkSettings,
pub dapps_conf: dapps::Configuration,
pub signer_conf: signer::Configuration,
Expand Down Expand Up @@ -262,7 +262,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<(), String> {
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
signer_service: Arc::new(rpc_apis::SignerService::new(move || {
signer::generate_new_token(signer_path.clone()).map_err(|e| format!("{:?}", e))
}, cmd.signer_port)),
}, cmd.ui_port)),
snapshot: snapshot_service.clone(),
client: client.clone(),
sync: sync_provider.clone(),
Expand Down
2 changes: 1 addition & 1 deletion parity/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn do_start(conf: Configuration, deps: Dependencies) -> Result<SignerServer, Str

match start_result {
Err(signer::ServerError::IoError(err)) => match err.kind() {
io::ErrorKind::AddrInUse => Err(format!("Trusted Signer address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --signer-port and --signer-interface options.", addr)),
io::ErrorKind::AddrInUse => Err(format!("Trusted UI address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --ui-port and --ui-interface options.", addr)),
_ => Err(format!("Trusted Signer io error: {}", err)),
},
Err(e) => Err(format!("Trusted Signer Error: {:?}", e)),
Expand Down