diff --git a/parity/configuration.rs b/parity/configuration.rs index 4560324d3..4d201ffa8 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -438,6 +438,22 @@ impl Configuration { Some(self.args.flag_signer_port) } } + + pub fn rpc_interface(&self) -> String { + match self.network_settings().rpc_interface.as_str() { + "all" => "0.0.0.0", + "local" => "127.0.0.1", + x => x, + }.into() + } + + pub fn dapps_interface(&self) -> String { + match self.args.flag_dapps_interface.as_str() { + "all" => "0.0.0.0", + "local" => "127.0.0.1", + x => x, + }.into() + } } #[cfg(test)] diff --git a/parity/dapps.rs b/parity/dapps.rs index 59a9ee552..917c59fc6 100644 --- a/parity/dapps.rs +++ b/parity/dapps.rs @@ -45,12 +45,7 @@ pub fn new(configuration: Configuration, deps: Dependencies) -> Option "0.0.0.0", - "local" => "127.0.0.1", - x => x, - }; - let url = format!("{}:{}", interface, configuration.port); + let url = format!("{}:{}", configuration.interface, configuration.port); let addr = SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid Webapps listen host/port given.", url)); let auth = configuration.user.as_ref().map(|username| { diff --git a/parity/main.rs b/parity/main.rs index 8beba61b5..de1d81b0b 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -252,7 +252,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig) // Setup http rpc let rpc_server = rpc::new_http(rpc::HttpConfiguration { enabled: network_settings.rpc_enabled, - interface: network_settings.rpc_interface.clone(), + interface: conf.rpc_interface(), port: network_settings.rpc_port, apis: conf.rpc_apis(), cors: conf.rpc_cors(), @@ -265,7 +265,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig) if conf.args.flag_webapp { println!("WARNING: Flag -w/--webapp is deprecated. Dapps server is now on by default. Ignoring."); } let dapps_server = dapps::new(dapps::Configuration { enabled: !conf.args.flag_dapps_off && !conf.args.flag_no_dapps, - interface: conf.args.flag_dapps_interface.clone(), + interface: conf.dapps_interface(), port: conf.args.flag_dapps_port, user: conf.args.flag_dapps_user.clone(), pass: conf.args.flag_dapps_pass.clone(), @@ -296,7 +296,10 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig) service.register_io_handler(io_handler).expect("Error registering IO handler"); if conf.args.cmd_ui { - url::open("http://localhost:8080/") + if conf.args.flag_dapps_off { + die_with_message("Cannot use UI command with Dapps turned off."); + } + url::open(&format!("http://{}:{}/", conf.dapps_interface(), conf.args.flag_dapps_port)); } // Handle exit diff --git a/parity/rpc.rs b/parity/rpc.rs index c10635889..df1e14524 100644 --- a/parity/rpc.rs +++ b/parity/rpc.rs @@ -66,13 +66,8 @@ pub fn new_http(conf: HttpConfiguration, deps: &Dependencies) -> Option "0.0.0.0", - "local" => "127.0.0.1", - x => x, - }; let apis = conf.apis.split(',').collect(); - let url = format!("{}:{}", interface, conf.port); + let url = format!("{}:{}", conf.interface, conf.port); let addr = SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid JSONRPC listen host/port given.", url)); Some(setup_http_rpc_server(deps, &addr, conf.cors, apis))