Files
ospab.network/ostp-gui/src/ipc.rs
ospab 85a2b01074 feat: Windows stack (daemon, installer, GUI)
Components:
- ostp-daemon: Windows Service with Named Pipe IPC
- ostp-installer: Setup wizard with admin privileges
- ostp-gui: Tauri dark theme UI (450x600)

Features:
- Background service management (OspabGuard)
- IPC commands: CONNECT/DISCONNECT/STATUS
- Firewall rules auto-configuration
- Wintun driver placeholder (download from wintun.net)
- Real-time stats display (upload/download/ping)

Note: Requires wintun.dll download for full functionality
2026-01-02 02:17:15 +03:00

40 lines
1.0 KiB
Rust

//! IPC communication with ostp-daemon via Named Pipe
use anyhow::{Context, Result};
use std::io::{Read, Write};
const PIPE_NAME: &str = r"\\.\pipe\ostp-daemon";
pub async fn send_command(command: &str) -> Result<String> {
#[cfg(windows)]
{
use std::fs::OpenOptions;
use std::os::windows::fs::OpenOptionsExt;
use winapi::um::winbase::FILE_FLAG_OVERLAPPED;
// Connect to Named Pipe
let mut pipe = OpenOptions::new()
.read(true)
.write(true)
.custom_flags(FILE_FLAG_OVERLAPPED)
.open(PIPE_NAME)
.context("Failed to connect to ostp-daemon. Is the service running?")?;
// Send command
pipe.write_all(command.as_bytes())?;
pipe.write_all(b"\n")?;
pipe.flush()?;
// Read response
let mut response = String::new();
pipe.read_to_string(&mut response)?;
Ok(response.trim().to_string())
}
#[cfg(not(windows))]
{
anyhow::bail!("Named pipes are only supported on Windows");
}
}