Expand description
Cross-platform IPC layer for daemon communication
This module provides socket-based IPC for the TLDR daemon using:
- Unix domain sockets on Unix systems (Linux, macOS)
- TCP localhost connections on Windows
§Security Mitigations
- TIGER-P3-01: Socket path validation (no temp dir escapes)
- TIGER-P3-03: Message size limits (10MB max) to prevent OOM
- TIGER-P3-04: Symlink rejection at socket path
- Unix sockets created with 0600 permissions (owner-only)
§Protocol
Newline-delimited JSON:
- Client sends:
{"cmd": "...", ...}\n - Server responds:
{...}\n
Structs§
- IpcListener
- Platform-agnostic IPC listener
- IpcStream
- Platform-agnostic IPC stream for bidirectional communication.
Constants§
- CONNECTION_
TIMEOUT_ SECS - Connection timeout in seconds
- MAX_
MESSAGE_ SIZE - Maximum message size in bytes (10MB) This prevents malicious clients from causing OOM via oversized messages. (TIGER-P3-03)
- READ_
TIMEOUT_ SECS - Read timeout in seconds
Functions§
- check_
not_ symlink - Check if a path is a symlink.
- check_
socket_ alive - Check if a socket exists and is connectable.
- cleanup_
socket - Clean up the socket file for a project.
- compute_
socket_ path - Compute the socket path for a project (Unix).
- compute_
tcp_ port - read_
command - Read a command from a client connection.
- send_
command - Send a command to the daemon and receive a response.
- send_
raw_ command - Send a raw JSON command to the daemon and receive a raw response.
- send_
response - Send a response to a client connection.
- validate_
socket_ path - Validate that a socket path is safe to use.