Merge pull request #956 from ethcore/cors-option

Changing cors header to be optional
This commit is contained in:
Arkadiy Paronyan
2016-04-14 21:16:57 +02:00
3 changed files with 9 additions and 10 deletions

View File

@@ -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<String>,
flag_jsonrpc_apis: String,
flag_webapp: bool,
flag_webapp_port: u16,
@@ -307,7 +306,7 @@ fn setup_rpc_server(
secret_store: Arc<AccountService>,
miner: Arc<Miner>,
url: &SocketAddr,
cors_domain: &str,
cors_domain: Option<String>,
apis: Vec<&str>,
) -> RpcServer {
use rpc::v1::*;
@@ -380,7 +379,7 @@ fn setup_rpc_server(
_secret_store: Arc<AccountService>,
_miner: Arc<Miner>,
_url: &str,
_cors_domain: &str,
_cors_domain: Option<String>,
_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 {