Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 28 additions & 5 deletions crates/oxidebbs-sysop/src/services/control_client.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<ControlResponse, SysopError> {
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;
Expand All @@ -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;
Expand Down