From 82ce992b893d12f5982edaf9f8e852d3fbb79d5f Mon Sep 17 00:00:00 2001 From: Steven Hildreth Date: Wed, 3 Jun 2026 15:29:24 -0500 Subject: [PATCH] fix(sysop): add platform guards for unix-specific control client Wrap unix-specific socket imports and logic with `#[cfg(unix)]` to enable compilation on non-unix platforms. Provide stub implementations for `send_control_request` and `is_socket_available` that return appropriate errors or values on unsupported platforms. Additionally, update the GitHub Actions release workflow to use the `macos-15-intel` runner. --- .github/workflows/release.yml | 2 +- .../src/services/control_client.rs | 33 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa950fd..78d62f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: target: x86_64-unknown-linux-gnu exe_suffix: "" archive: tar.gz - - os: macos-13 + - os: macos-15-intel target: x86_64-apple-darwin exe_suffix: "" archive: tar.gz diff --git a/crates/oxidebbs-sysop/src/services/control_client.rs b/crates/oxidebbs-sysop/src/services/control_client.rs index b115951..5f316f7 100644 --- a/crates/oxidebbs-sysop/src/services/control_client.rs +++ b/crates/oxidebbs-sysop/src/services/control_client.rs @@ -1,16 +1,22 @@ -use std::io::{BufRead, Write}; -use std::net::Shutdown; -use std::os::unix::net::UnixStream; use std::path::{Path, PathBuf}; -use std::time::Duration; +#[cfg(unix)] +use std::{ + io::{BufRead, Write}, + net::Shutdown, + os::unix::net::UnixStream, + time::Duration, +}; use serde::{Deserialize, Serialize}; use crate::SysopError; pub const CONTROL_SOCKET_NAME: &str = "oxidebbs-control.sock"; +#[cfg(unix)] const SOCKET_READ_TIMEOUT: Duration = Duration::from_secs(2); +#[cfg(unix)] const SOCKET_WRITE_TIMEOUT: Duration = Duration::from_secs(2); +#[cfg(unix)] const MAX_REQUEST_BYTES: usize = 64 * 1024; #[derive(Debug, Serialize, Deserialize, Clone)] @@ -70,6 +76,7 @@ pub fn control_socket_path(runtime_dir: &Path) -> PathBuf { runtime_dir.join(CONTROL_SOCKET_NAME) } +#[cfg(unix)] pub fn send_control_request( socket_path: &Path, request: &ControlRequest, @@ -113,6 +120,17 @@ pub fn send_control_request( Ok(response) } +#[cfg(not(unix))] +pub fn send_control_request( + _socket_path: &Path, + _request: &ControlRequest, +) -> Result { + Err(SysopError::Control( + "live control sockets are only supported on Unix platforms".to_string(), + )) +} + +#[cfg(unix)] pub fn is_socket_available(socket_path: &Path) -> bool { if !socket_path.exists() { return false; @@ -123,7 +141,12 @@ pub fn is_socket_available(socket_path: &Path) -> bool { ) } -#[cfg(test)] +#[cfg(not(unix))] +pub fn is_socket_available(_socket_path: &Path) -> bool { + false +} + +#[cfg(all(test, unix))] mod tests { use super::*; use std::fs;