Remove UI related settings from CLI (#8783)

* Remove all ui reference in dapps interface

* Pass primary cli build

* Add back parity wallet dapp as builtin

* Clean up ui settings

* Fix all tests in cli

* Missed ui files to commit

* Add parity-utils endpoint back

* Fix non-dapp feature compiling

* Inline styles

* Remove parity-utils endpoint

* Remove ui precompiled crate

* Remove parity-ui alltogether

* Remove ui feature flags

* Move errors to static methods

* Fix tests

* Remove all reference to utils endpoint and remove server side injection

According to https://github.com/paritytech/parity/pull/8539, inject.js is already handled by Parity UI.
This commit is contained in:
Wei Tang
2018-06-06 16:05:52 +08:00
committed by Marek Kotewicz
parent 114d4433a9
commit a5190449da
42 changed files with 306 additions and 1639 deletions

View File

@@ -26,10 +26,6 @@ usage! {
// Arguments must start with arg_
// Flags must start with flag_
CMD cmd_ui {
"Manage ui",
}
CMD cmd_dapp
{
"Manage dapps",
@@ -376,35 +372,10 @@ usage! {
"Provide a file containing passwords for unlocking accounts (signer, private account, validators).",
["UI options"]
FLAG flag_force_ui: (bool) = false, or |c: &Config| c.ui.as_ref()?.force.clone(),
"--force-ui",
"Enable Trusted UI WebSocket endpoint, even when --unlock is in use.",
FLAG flag_no_ui: (bool) = false, or |c: &Config| c.ui.as_ref()?.disable.clone(),
"--no-ui",
"Disable Trusted UI WebSocket endpoint.",
// NOTE [todr] For security reasons don't put this to config files
FLAG flag_ui_no_validation: (bool) = false, or |_| None,
"--ui-no-validation",
"Disable Origin and Host headers validation for Trusted UI. WARNING: INSECURE. Used only for development.",
ARG arg_ui_interface: (String) = "local", or |c: &Config| c.ui.as_ref()?.interface.clone(),
"--ui-interface=[IP]",
"Specify the hostname portion of the Trusted UI server, IP should be an interface's IP address, or local.",
ARG arg_ui_hosts: (String) = "none", or |c: &Config| c.ui.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")),
"--ui-hosts=[HOSTS]",
"List of allowed Host header values. This option will validate the Host header sent by the browser, it is additional security against some attack vectors. Special options: \"all\", \"none\",.",
ARG arg_ui_path: (String) = "$BASE/signer", or |c: &Config| c.ui.as_ref()?.path.clone(),
"--ui-path=[PATH]",
"Specify directory where Trusted UIs tokens should be stored.",
ARG arg_ui_port: (u16) = 8180u16, or |c: &Config| c.ui.as_ref()?.port.clone(),
"--ui-port=[PORT]",
"Specify the port of Trusted UI server.",
["Networking options"]
FLAG flag_no_warp: (bool) = false, or |c: &Config| c.network.as_ref()?.warp.clone().map(|w| !w),
"--no-warp",
@@ -948,6 +919,30 @@ usage! {
"--public-node",
"Does nothing; Public node is removed from Parity.",
FLAG flag_force_ui: (bool) = false, or |_| None,
"--force-ui",
"Does nothing; UI is now a separate project.",
FLAG flag_no_ui: (bool) = false, or |_| None,
"--no-ui",
"Does nothing; UI is now a separate project.",
FLAG flag_ui_no_validation: (bool) = false, or |_| None,
"--ui-no-validation",
"Does nothing; UI is now a separate project.",
ARG arg_ui_interface: (String) = "local", or |_| None,
"--ui-interface=[IP]",
"Does nothing; UI is now a separate project.",
ARG arg_ui_hosts: (String) = "none", or |_| None,
"--ui-hosts=[HOSTS]",
"Does nothing; UI is now a separate project.",
ARG arg_ui_port: (u16) = 8180u16, or |_| None,
"--ui-port=[PORT]",
"Does nothing; UI is now a separate project.",
ARG arg_dapps_port: (Option<u16>) = None, or |c: &Config| c.dapps.as_ref()?.port.clone(),
"--dapps-port=[PORT]",
"Dapps server is merged with RPC server. Use --jsonrpc-port.",
@@ -1111,12 +1106,18 @@ struct PrivateTransactions {
#[derive(Default, Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
struct Ui {
force: Option<bool>,
disable: Option<bool>,
port: Option<u16>,
interface: Option<String>,
hosts: Option<Vec<String>>,
path: Option<String>,
#[serde(rename="force")]
_legacy_force: Option<bool>,
#[serde(rename="disable")]
_legacy_disable: Option<bool>,
#[serde(rename="port")]
_legacy_port: Option<u16>,
#[serde(rename="interface")]
_legacy_interface: Option<String>,
#[serde(rename="hosts")]
_legacy_hosts: Option<Vec<String>>,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
@@ -1404,15 +1405,13 @@ mod tests {
let args = Args::parse(&["parity", "--secretstore-nodes", "abc@127.0.0.1:3333,cde@10.10.10.10:4444"]).unwrap();
assert_eq!(args.arg_secretstore_nodes, "abc@127.0.0.1:3333,cde@10.10.10.10:4444");
let args = Args::parse(&["parity", "--password", "~/.safe/1", "--password", "~/.safe/2", "--ui-port", "8123", "ui"]).unwrap();
let args = Args::parse(&["parity", "--password", "~/.safe/1", "--password", "~/.safe/2", "--ui-port", "8123"]).unwrap();
assert_eq!(args.arg_password, vec!["~/.safe/1".to_owned(), "~/.safe/2".to_owned()]);
assert_eq!(args.arg_ui_port, 8123);
assert_eq!(args.cmd_ui, true);
let args = Args::parse(&["parity", "--password", "~/.safe/1,~/.safe/2", "--ui-port", "8123", "ui"]).unwrap();
let args = Args::parse(&["parity", "--password", "~/.safe/1,~/.safe/2", "--ui-port", "8123"]).unwrap();
assert_eq!(args.arg_password, vec!["~/.safe/1".to_owned(), "~/.safe/2".to_owned()]);
assert_eq!(args.arg_ui_port, 8123);
assert_eq!(args.cmd_ui, true);
}
#[test]
@@ -1476,7 +1475,6 @@ mod tests {
// then
assert_eq!(args, Args {
// Commands
cmd_ui: false,
cmd_dapp: false,
cmd_daemon: false,
cmd_account: false,
@@ -1566,7 +1564,7 @@ mod tests {
flag_force_ui: false,
flag_no_ui: false,
arg_ui_port: 8180u16,
arg_ui_interface: "127.0.0.1".into(),
arg_ui_interface: "local".into(),
arg_ui_hosts: "none".into(),
arg_ui_path: "$HOME/.parity/signer".into(),
flag_ui_no_validation: false,
@@ -1820,12 +1818,12 @@ mod tests {
fast_unlock: None,
}),
ui: Some(Ui {
force: None,
disable: Some(true),
port: None,
interface: None,
hosts: None,
path: None,
_legacy_force: None,
_legacy_disable: Some(true),
_legacy_port: None,
_legacy_interface: None,
_legacy_hosts: None,
}),
network: Some(Network {
warp: Some(false),