mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 07:27:55 +00:00
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:
@@ -62,6 +62,8 @@ pub fn rpc_handler<M: PubSubMetadata>(
|
||||
mod inner {
|
||||
use super::*;
|
||||
|
||||
/// Type alias for ipc server
|
||||
pub type IpcServer = ipc::Server;
|
||||
/// Type alias for http server
|
||||
pub type HttpServer = http::Server;
|
||||
/// Type alias for ws server
|
||||
@@ -89,6 +91,23 @@ mod inner {
|
||||
.start_http(addr)
|
||||
}
|
||||
|
||||
/// Start IPC server listening on given path.
|
||||
///
|
||||
/// **Note**: Only available if `not(target_os = "unknown")`.
|
||||
pub fn start_ipc<M: pubsub::PubSubMetadata + Default>(
|
||||
addr: &str,
|
||||
io: RpcHandler<M>,
|
||||
) -> io::Result<ipc::Server> {
|
||||
let builder = ipc::ServerBuilder::new(io);
|
||||
#[cfg(target_os = "unix")]
|
||||
builder.set_security_attributes({
|
||||
let security_attributes = ipc::SecurityAttributes::empty();
|
||||
security_attributes.set_mode(0o600)?;
|
||||
security_attributes
|
||||
});
|
||||
builder.start(addr)
|
||||
}
|
||||
|
||||
/// Start WS server listening on given address.
|
||||
///
|
||||
/// **Note**: Only available if `not(target_os = "unknown")`.
|
||||
|
||||
Reference in New Issue
Block a user