A cross-platform Inter-Process Communication (IPC) library written in Rust with built-in anti-tampering protection against fake clients. This library provides secure, mutual TLS-authenticated communication between privileged server processes and unprivileged client applications.
- π Mutual TLS Authentication: Certificate-based security for both client and server
- π‘οΈ Anti-Tampering Protection: Process credential verification and binary hash validation
- π Cross-Platform: Unix domain sockets on Unix-like systems, named pipes on Windows
- π§ Clean Architecture: Multi-crate workspace with clear separation of concerns
- β‘ High Performance: Async-first design with tokio for concurrent client handling
- π Thread-Safe: Safe concurrent access with proper synchronization primitives
This workspace is organized into three main crates:
| Crate | Description | Purpose |
|---|---|---|
common/ |
Shared protocols and utilities | Platform-specific socket implementations, TLS streams, message definitions |
client/ |
Client library | Secure IPC client for connecting to servers |
server/ |
Server library | Secure IPC server with client validation |
- Platform Abstraction: Unified interface for Unix domain sockets and Windows named pipes
- TLS Integration: Rustls-based mutual TLS with certificate management
- Process Validation: Client binary hash verification and user credential checking
- Message Protocol: Efficient binary serialization with structured message types
- Rust 1.70+ (2021 edition)
- Valid TLS certificates for mutual authentication
# Build the entire workspace
cargo build
# Build with optimizations
cargo build --release
# Check all crates
cargo check# Client examples
cargo run --example basic # Basic client example
cargo run --example cli interactive # Interactive CLI client
cargo run --example cli ping # Quick connection test
# Server examples
cargo run --example basic -p flyme-server # Basic server setup
cargo run --example daemon -p flyme-server # Daemon server with signal handling
cargo run --example echo -p flyme-server # Echo server with custom commandsuse flyme_client::{ClientConfig, SecureIpcClient};
use std::time::Duration;
// Create client with custom configuration
let config = ClientConfig::new()
.with_timeout(Duration::from_secs(10))
.with_verbose(true);
// Connect and send requests
let mut client = SecureIpcClient::new(config)?;
client.connect()?;
let response = client.send_request("status")?;
println!("Server response: {}", response);
client.disconnect()?;use flyme_server::SecureIpcServer;
use flyme_common::config::ServerCertPath;
// Initialize server with TLS certificates
let cert_path = ServerCertPath::new();
let server = SecureIpcServer::new(cert_path, "my-socket".to_string())?;
// Start accepting connections (blocking)
server.run()?;The server crate includes several examples demonstrating different use cases:
- Basic Server (
examples/basic.rs): Simple server setup with certificate management - Daemon Server (
examples/daemon.rs): Long-running server with signal handling and graceful shutdown - Echo Server (
examples/echo.rs): Custom server implementation with command processing
- Socket Connection: Client connects to platform-specific socket
- TLS Handshake: Mutual TLS authentication with certificate verification
- Process Validation: Server verifies client user credentials and process information
- Binary Verification: Optional client binary hash validation
- Secure Communication: Encrypted message exchange over established TLS channel
The library expects the following certificate structure:
certificates/
βββ ca.pem # Certificate Authority
βββ server-cert.pem # Server certificate
βββ server-key.pem # Server private key
βββ client-cert.pem # Client certificate
βββ client-key.pem # Client private key
- Process Credential Verification: Ensures client runs with expected user privileges
- Binary Hash Validation: Verifies client executable integrity (configurable)
- Certificate Pinning: Mutual TLS prevents man-in-the-middle attacks
- Abstract Namespace Sockets: On Linux, uses abstract sockets to prevent filesystem-based attacks
| Variable | Description | Default |
|---|---|---|
FLYME_CLIENT_BINARY_HASH |
Expected SHA256 hash of client binary | Empty (validation disabled) |
FLYME_CLIENT_BINARY_HASHES |
Comma-separated list of allowed hashes | Empty |
FLYME_ENFORCE_CLIENT_HASH_VALIDATION |
Enable/disable hash validation | false |
- Unix: Abstract namespace socket
/tmp/flyme - Windows: Named pipe
\\.\pipe\flyme
flyme/
βββ Cargo.toml # Workspace configuration
βββ common/ # Shared protocols and utilities
β βββ src/
β β βββ config.rs # Message and cert path definitions
β β βββ platform_socket.rs # Cross-platform socket abstraction
β β βββ tls_stream.rs # TLS wrapper for sockets
β β βββ lib.rs # Common library entry point
β βββ Cargo.toml
βββ client/ # Client library
β βββ src/
β β βββ client.rs # Main client implementation
β β βββ lib.rs # Client library entry point
β βββ examples/ # Client usage examples
β β βββ basic.rs # Basic client example
β β βββ cli.rs # Interactive CLI client
β βββ Cargo.toml
βββ server/ # Server library
β βββ src/
β β βββ lib.rs # Server implementation
β βββ examples/ # Server usage examples
β β βββ basic.rs # Basic server setup
β β βββ daemon.rs # Daemon server with signal handling
β β βββ echo.rs # Echo server with custom commands
β βββ Cargo.toml
βββ README.md
# Run all tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Test specific crate
cargo test -p secure-ipc-client
# Run integration test (requires certificates)
./scripts/test_integration.sh- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass:
cargo test - Check formatting:
cargo fmt - Run clippy:
cargo clippy - Submit a pull request
| Platform | Socket Type | Status |
|---|---|---|
| Linux | Unix Domain Sockets (Abstract) | β Supported |
| macOS | Unix Domain Sockets | β Supported |
| Windows | Named Pipes | β Supported |
| BSD | Unix Domain Sockets | π Should work |
- rustls: TLS implementation
- tokio: Async runtime
- serde: Serialization framework
- anyhow: Error handling
- nix: Unix systems programming (Unix only)
- windows: Windows API bindings (Windows only)
- Unix: Uses
libcandnixfor socket operations and process information - Windows: Uses
windowscrate for named pipes and process APIs - Cross-platform: Runtime detection of platform capabilities
- β¨ Multi-crate workspace architecture
- β¨ Mutual TLS authentication
- β¨ Cross-platform socket support
- β¨ Process credential verification
- β¨ Binary hash validation
- β¨ Comprehensive examples and documentation
Built with β€οΈ in Rust for secure system-level communication