Skip to content

Commit

Permalink
Refactor low level clients
Browse files Browse the repository at this point in the history
This commit includes a few changes:
* remove explicit wire protocol version handling, following a similar
change in the interface
* add a provider ID field to the list_opcodes operation, with the
request being serviced by the core provider
* include an implicit provider ID within the basic client to allow it to
maintain a consistent operation while allowing it to expose an interface
that essentially covers the wire protocol contracts
* add checks that core operations are only performed on the core client
and cryptographic operations cannot be performed on the core client

Co-authored-by: Ionut Mihalcea <[email protected]>
Co-authored-by: Hugues de Valon <[email protected]>

Signed-off-by: Ionut Mihalcea <[email protected]>
  • Loading branch information
ionut-arm committed Apr 15, 2020
1 parent 8786219 commit bf556fe
Show file tree
Hide file tree
Showing 11 changed files with 633 additions and 604 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ categories = ["development-tools"]
edition = "2018"

[dependencies]
parsec-interface = "0.11.0"
parsec-interface = "0.13.0"
num = "0.2.1"
rand = "0.7.3"
log = "0.4.8"
Expand Down
495 changes: 495 additions & 0 deletions src/core/basic_client.rs

Large diffs are not rendered by default.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ use std::time::Duration;
const DEFAULT_SOCKET_PATH: &str = "/tmp/security-daemon-socket";
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(1);

/// IPC client for Unix domain sockets
/// IPC handler for Unix domain sockets
#[derive(Debug, Clone)]
pub struct Client {
pub struct Handler {
/// Path at which the socket can be found
path: PathBuf,
/// Timeout for reads and writes on the streams
timeout: Option<Duration>,
}

impl Connect for Client {
impl Connect for Handler {
fn connect(&self) -> Result<Box<dyn ReadWrite>> {
let stream = UnixStream::connect(self.path.clone()).map_err(ClientErrorKind::Ipc)?;

Expand All @@ -34,16 +34,16 @@ impl Connect for Client {
}
}

impl Client {
impl Handler {
/// Create new client using given socket path and timeout duration
pub fn new(path: PathBuf, timeout: Option<Duration>) -> Self {
Client { path, timeout }
Handler { path, timeout }
}
}

impl Default for Client {
impl Default for Handler {
fn default() -> Self {
Client {
Handler {
path: DEFAULT_SOCKET_PATH.into(),
timeout: Some(DEFAULT_TIMEOUT),
}
Expand Down
Loading

0 comments on commit bf556fe

Please sign in to comment.