Rename cli and config options signer->ui (#3232)

* rename options signer->ui

* rename config signer->ui
This commit is contained in:
keorn 2016-11-07 16:40:53 +00:00 committed by Gav Wood
parent 01602ec0b5
commit 52ea597d6f
7 changed files with 69 additions and 68 deletions

View File

@ -12,7 +12,7 @@ unlock = ["0xdeadbeefcafe0000000000000000000000000000"]
password = ["~/.safe/password.file"]
keys_iterations = 10240
[signer]
[ui]
force = false
disable = false
port = 8180

View File

@ -8,7 +8,7 @@ chain = "./chain.json"
unlock = ["0x1", "0x2", "0x3"]
password = ["passwdfile path"]
[signer]
[ui]
disable = true
[network]

View File

@ -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,
@ -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>,
@ -302,7 +302,7 @@ struct Account {
}
#[derive(Default, Debug, PartialEq, RustcDecodable)]
struct Signer {
struct Ui {
force: Option<bool>,
disable: Option<bool>,
port: Option<u16>,
@ -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;
@ -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,
@ -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,

View File

@ -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})

View File

@ -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());
@ -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,
@ -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,
}
}
@ -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() };
@ -616,7 +616,7 @@ impl Configuration {
keys: keys_path,
db: db_path,
dapps: dapps_path,
signer: signer_path,
signer: ui_path,
}
}
@ -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()
@ -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
}
}
@ -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(),
@ -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]
@ -991,7 +991,7 @@ mod tests {
let conf0 = parse(&["parity", "--unlock", "0x0"]);
// then
assert_eq!(conf0.signer_enabled(), false);
assert_eq!(conf0.ui_enabled(), false);
}
#[test]
@ -999,10 +999,10 @@ mod tests {
// 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 {

View File

@ -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,
@ -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(),

View File

@ -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)),