diff --git a/Cargo.lock b/Cargo.lock index 7c1bdbfaf..509e60aa4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -538,7 +538,7 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" version = "5.0.1" -source = "git+https://github.com/debris/jsonrpc-http-server.git#239066b94660a1af24c8b2efc16e800f9c7cce18" +source = "git+https://github.com/debris/jsonrpc-http-server.git#e728f2e080799b7a62b0b5cf5fa9d4ad65cd8c96" dependencies = [ "hyper 0.9.0-mio (git+https://github.com/hyperium/hyper?branch=mio)", "jsonrpc-core 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/parity/main.rs b/parity/main.rs index bbf7e27a9..94466e0e2 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -133,8 +133,7 @@ API and Console Options: --jsonrpc-interface IP Specify the hostname portion of the JSONRPC API server, IP should be an interface's IP address, or all (all interfaces) or local [default: local]. - --jsonrpc-cors URL Specify CORS header for JSON-RPC API responses - [default: null]. + --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. @@ -242,7 +241,7 @@ struct Args { flag_jsonrpc: bool, flag_jsonrpc_interface: String, flag_jsonrpc_port: u16, - flag_jsonrpc_cors: String, + flag_jsonrpc_cors: Option, flag_jsonrpc_apis: String, flag_webapp: bool, flag_webapp_port: u16, @@ -307,7 +306,7 @@ fn setup_rpc_server( secret_store: Arc, miner: Arc, url: &SocketAddr, - cors_domain: &str, + cors_domain: Option, apis: Vec<&str>, ) -> RpcServer { use rpc::v1::*; @@ -380,7 +379,7 @@ fn setup_rpc_server( _secret_store: Arc, _miner: Arc, _url: &str, - _cors_domain: &str, + _cors_domain: Option, _apis: Vec<&str>, ) -> ! { die!("Your Parity version has been compiled without JSON-RPC support.") @@ -713,7 +712,7 @@ impl Configuration { self.args.flag_rpcport.unwrap_or(self.args.flag_jsonrpc_port) ); let addr = SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid JSONRPC listen host/port given.", url)); - let cors_domain = self.args.flag_rpccorsdomain.as_ref().unwrap_or(&self.args.flag_jsonrpc_cors); + let cors_domain = self.args.flag_jsonrpc_cors.clone().or(self.args.flag_rpccorsdomain.clone()); Some(setup_rpc_server( service.client(), @@ -721,7 +720,7 @@ impl Configuration { account_service.clone(), miner.clone(), &addr, - &cors_domain, + cors_domain, apis.split(',').collect() )) } else { diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index f059750d2..f79cbe828 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -58,8 +58,8 @@ impl RpcServer { } /// Start server asynchronously and returns result with `Server` handle on success or an error. - pub fn start_http(&self, addr: &SocketAddr, cors_domain: &str) -> Result { + pub fn start_http(&self, addr: &SocketAddr, cors_domain: Option) -> Result { let cors_domain = cors_domain.to_owned(); - Server::start(addr, self.handler.clone(), jsonrpc_http_server::AccessControlAllowOrigin::Value(cors_domain)) + Server::start(addr, self.handler.clone(), cors_domain.map(jsonrpc_http_server::AccessControlAllowOrigin::Value)) } }