Merge pull request #1414 from ethcore/uifix
Fixing interface and port for parity ui
This commit is contained in:
commit
b9649c0e78
@ -447,6 +447,26 @@ 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()
|
||||
}
|
||||
|
||||
pub fn dapps_enabled(&self) -> bool {
|
||||
!self.args.flag_dapps_off && !self.args.flag_no_dapps
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -45,12 +45,7 @@ pub fn new(configuration: Configuration, deps: Dependencies) -> Option<WebappSer
|
||||
return None;
|
||||
}
|
||||
|
||||
let interface = match configuration.interface.as_str() {
|
||||
"all" => "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| {
|
||||
|
@ -253,7 +253,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,8 +265,8 @@ 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(),
|
||||
enabled: conf.dapps_enabled(),
|
||||
interface: conf.dapps_interface(),
|
||||
port: conf.args.flag_dapps_port,
|
||||
user: conf.args.flag_dapps_user.clone(),
|
||||
pass: conf.args.flag_dapps_pass.clone(),
|
||||
@ -297,7 +297,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.dapps_enabled() {
|
||||
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
|
||||
|
@ -66,13 +66,8 @@ pub fn new_http(conf: HttpConfiguration, deps: &Dependencies) -> Option<RpcServe
|
||||
return None;
|
||||
}
|
||||
|
||||
let interface = match conf.interface.as_str() {
|
||||
"all" => "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))
|
||||
|
@ -49,11 +49,11 @@ pub fn open(url: &str) {
|
||||
#[cfg(target_os="macos")]
|
||||
pub fn open(url: &str) {
|
||||
use std;
|
||||
let _ = std::process::Command::new("open").arg(url).output();
|
||||
let _ = std::process::Command::new("open").arg(url).spawn();
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
pub fn open(url: &str) {
|
||||
use std;
|
||||
let _ = std::process::Command::new("xdg-open").arg(url).output();
|
||||
let _ = std::process::Command::new("xdg-open").arg(url).spawn();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user