beszel_protocol/lib.rs
1//! Shared wire types for upstream Beszel realtime payloads and the local Unix socket stream.
2
3pub mod local;
4pub mod upstream;
5
6use std::path::PathBuf;
7
8/// Local NDJSON protocol version spoken between `beszel-relay` and clients.
9pub const LOCAL_PROTOCOL_VERSION: u32 = 1;
10
11/// Default filename for the user-only Unix domain socket.
12pub const DEFAULT_SOCKET_NAME: &str = "beszel-relay.sock";
13
14/// Resolve the default Unix socket path under `$XDG_RUNTIME_DIR`.
15pub fn default_socket_path() -> PathBuf {
16 if let Ok(runtime_dir) = std::env::var("XDG_RUNTIME_DIR")
17 && !runtime_dir.is_empty()
18 {
19 return PathBuf::from(runtime_dir).join(DEFAULT_SOCKET_NAME);
20 }
21 std::env::temp_dir().join(DEFAULT_SOCKET_NAME)
22}