From 4dd63c81a63ae8a6bea5183404ecdf224ed5db2a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 May 2016 19:26:47 +0200 Subject: [PATCH] Tidy up CLI options and make JSONRPC & webapps on by default. --- parity/cli.rs | 48 +++++++++++++++++++++++++---------------- parity/configuration.rs | 9 ++++---- parity/main.rs | 5 +++-- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/parity/cli.rs b/parity/cli.rs index 106d65aa3..e5a5a0983 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -59,7 +59,7 @@ Networking Options: string or input to SHA3 operation. API and Console Options: - -j --jsonrpc Enable the JSON-RPC API server. + --jsonrpc-off Disable the JSON-RPC API server. --jsonrpc-port PORT Specify the port portion of the JSONRPC API server [default: 8545]. --jsonrpc-interface IP Specify the hostname portion of the JSONRPC API @@ -68,10 +68,18 @@ API and Console Options: --jsonrpc-cors URL Specify CORS header for JSON-RPC API responses. --jsonrpc-apis APIS Specify the APIs available through the JSONRPC interface. APIS is a comma-delimited list of API - name. Possible name are web3, eth and net. + name. Possible name are web3, eth, net, personal, + ethcore, traces. [default: web3,eth,net,personal,ethcore,traces]. - -w --webapp Enable the web applications server (e.g. - status page). + + --ipc-off Disable JSON-RPC over IPC service. + --ipc-path PATH Specify custom path for JSON-RPC over IPC service + [default: $HOME/.parity/jsonrpc.ipc]. + --ipc-apis APIS Specify custom API set available via JSON-RPC over + IPC [default: web3,eth,net,personal,ethcore]. + + --webapp-off Disable the web applications server (e.g. status + page). --webapp-port PORT Specify the port portion of the WebApps server [default: 8080]. --webapp-interface IP Specify the hostname portion of the WebApps @@ -84,12 +92,6 @@ API and Console Options: --webapp-pass PASSWORD Specify password for WebApps server. Use only in conjunction with --webapp-user. - --ipc-disable Disable JSON-RPC over IPC service - --ipc-path PATH Specify custom path for IPC service - [default: $HOME/.parity/jsonrpc.ipc] - --ipc-api APIS Specify custom API set available via IPC service - [default: web3,eth,net,personal,ethcore] - Sealing/Mining Options: --force-sealing Force the node to author new blocks as if it were always sealing/mining. @@ -133,18 +135,23 @@ Footprint Options: the entire system, overrides other cache and queue options. -Geth-compatibility Options: +Legacy Options: --datadir PATH Equivalent to --db-path PATH. --testnet Equivalent to --chain testnet. --networkid INDEX Equivalent to --network-id INDEX. --maxpeers COUNT Equivalent to --peers COUNT. --nodekey KEY Equivalent to --node-key KEY. --nodiscover Equivalent to --no-discovery. - --rpc Equivalent to --jsonrpc. + -j --jsonrpc Does nothing; JSON-RPC is on by default now. + -w --webapp Does nothing; web app server is on by default now. + --rpc Does nothing; JSON-RPC is on by default now. --rpcaddr IP Equivalent to --jsonrpc-interface IP. --rpcport PORT Equivalent to --jsonrpc-port PORT. --rpcapi APIS Equivalent to --jsonrpc-apis APIS. --rpccorsdomain URL Equivalent to --jsonrpc-cors URL. + --ipcdisable Equivalent to --ipc-off. + --ipcapi APIS Equivalent to --ipc-apis APIS. + --ipcpath PATH Equivalent to --ipc-path PATH. --gasprice WEI Minimum amount of Wei per GAS to be paid for a transaction to be accepted for mining. Overrides --basic-tx-usd. @@ -184,12 +191,15 @@ pub struct Args { pub flag_cache_pref_size: usize, pub flag_cache_max_size: usize, pub flag_queue_max_size: usize, - pub flag_jsonrpc: bool, + pub flag_jsonrpc_off: bool, pub flag_jsonrpc_interface: String, pub flag_jsonrpc_port: u16, pub flag_jsonrpc_cors: Option, pub flag_jsonrpc_apis: String, - pub flag_webapp: bool, + pub flag_ipc_off: bool, + pub flag_ipc_path: String, + pub flag_ipc_apis: String, + pub flag_webapp_off: bool, pub flag_webapp_port: u16, pub flag_webapp_interface: String, pub flag_webapp_user: Option, @@ -203,10 +213,7 @@ pub struct Args { pub flag_tx_limit: usize, pub flag_logging: Option, pub flag_version: bool, - pub flag_ipc_disable: bool, - pub flag_ipc_path: String, - pub flag_ipc_api: String, - // geth-compatibility... + // legacy... pub flag_nodekey: Option, pub flag_nodiscover: bool, pub flag_maxpeers: Option, @@ -214,6 +221,8 @@ pub struct Args { pub flag_extradata: Option, pub flag_etherbase: Option, pub flag_gasprice: Option, + pub flag_jsonrpc: bool, + pub flag_webapp: bool, pub flag_rpc: bool, pub flag_rpcaddr: Option, pub flag_rpcport: Option, @@ -221,6 +230,9 @@ pub struct Args { pub flag_rpcapi: Option, pub flag_testnet: bool, pub flag_networkid: Option, + pub flag_ipcdisable: bool, + pub flag_ipcpath: Option, + pub flag_ipcapi: Option, } pub fn print_version() { diff --git a/parity/configuration.rs b/parity/configuration.rs index 0b32d5232..2327417c8 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -269,20 +269,21 @@ impl Configuration { pub fn ipc_settings(&self) -> IpcConfiguration { IpcConfiguration { - enabled: !self.args.flag_ipc_disable, - socket_addr: self.args.flag_ipc_path.clone() + enabled: !(self.args.flag_ipcdisable || self.args.flag_ipc_off), + socket_addr: self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone()) .replace("$HOME", env::home_dir().unwrap().to_str().unwrap()), - apis: self.args.flag_ipc_api.clone(), + apis: self.args.flag_ipcapi.clone().unwrap_or(self.args.flag_ipc_apis.clone()), } } pub fn network_settings(&self) -> NetworkSettings { + if self.args.flag_jsonrpc { println!("WARNING: Flag -j/--json-rpc is deprecated. JSON-RPC is now on by default. Ignoring."); } NetworkSettings { name: self.args.flag_identity.clone(), chain: self.chain(), max_peers: self.max_peers(), network_port: self.net_port(), - rpc_enabled: self.args.flag_rpc || self.args.flag_jsonrpc, + rpc_enabled: !self.args.flag_jsonrpc_off, rpc_interface: self.args.flag_rpcaddr.clone().unwrap_or(self.args.flag_jsonrpc_interface.clone()), rpc_port: self.args.flag_rpcport.unwrap_or(self.args.flag_jsonrpc_port), } diff --git a/parity/main.rs b/parity/main.rs index 23f299406..bdde750ca 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -181,10 +181,11 @@ fn execute_client(conf: Configuration) { }, &dependencies); // setup ipc rpc - let ipc_server = rpc::new_ipc(conf.ipc_settings(), &dependencies); + let _ipc_server = rpc::new_ipc(conf.ipc_settings(), &dependencies); + if conf.args.flag_webapp { println!("WARNING: Flag -w/--webapp is deprecated. Web app server is now on by default. Ignoring."); } let webapp_server = webapp::new(webapp::Configuration { - enabled: conf.args.flag_webapp, + enabled: !conf.args.flag_webapp_off, interface: conf.args.flag_webapp_interface.clone(), port: conf.args.flag_webapp_port, user: conf.args.flag_webapp_user.clone(),