Add IPC support (#6348)

This is useful for both security and performance reasons. IPC is faster
than TCP, and it is subject to OS access controls.
This commit is contained in:
Demi Obenour
2020-06-16 10:14:12 +00:00
committed by GitHub
parent e99ff8ee96
commit e2f5e4bd74
10 changed files with 136 additions and 1 deletions
+6
View File
@@ -285,6 +285,12 @@ macro_rules! substrate_cli_subcommands {
}
}
fn rpc_ipc(&self) -> $crate::Result<::std::option::Option<::std::string::String>> {
match self {
$($enum::$variant(cmd) => cmd.rpc_ipc()),*
}
}
fn rpc_http(&self) -> $crate::Result<::std::option::Option<::std::net::SocketAddr>> {
match self {
$($enum::$variant(cmd) => cmd.rpc_http()),*
@@ -122,6 +122,10 @@ pub struct RunCmd {
#[structopt(long = "prometheus-external")]
pub prometheus_external: bool,
/// Specify IPC RPC server path
#[structopt(long = "ipc-path", value_name = "PATH")]
pub ipc_path: Option<String>,
/// Specify HTTP RPC server TCP port.
#[structopt(long = "rpc-port", value_name = "PORT")]
pub rpc_port: Option<u16>,
@@ -434,6 +438,10 @@ impl CliConfiguration for RunCmd {
Ok(Some(SocketAddr::new(interface, self.rpc_port.unwrap_or(9933))))
}
fn rpc_ipc(&self) -> Result<Option<String>> {
Ok(self.ipc_path.clone())
}
fn rpc_ws(&self) -> Result<Option<SocketAddr>> {
let interface = rpc_interface(
self.ws_external,