Skip to main content

Module ipc

Module ipc 

Source
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.