$ show dchapyshev/aspia
Aspia is a comprehensive, cross-platform remote desktop and system administration suite. The codebase is decomposed into four primary components: a **host** (the machine being controlled), a **client** (the controlling machine), a **router** (session brokering and NAT traversal), and a **relay** (traffic forwarding). It supports Windows, Linux, macOS, and Android, with platform-specific implementations for screen capture (DXGI, X11, Wayland/PipeWire, KMS/DRM, Android MediaProjection), audio (WASAPI, PulseAudio, Oboe), input injection, and clipboard integration. The system uses encrypted communication with SRP authentication, X25519 key exchange, and AEAD ciphers (AES-256-GCM, ChaCha20-Poly1305) with key ratcheting. Beyond desktop sharing, it provides file transfer, text chat, remote terminal, task manager, system information collection, and video recording. The client features both a Qt-based desktop GUI and a custom Android UI built with native widgets. The router manages host discovery, two-factor authentication (TOTP), and relay session keys, while the relay handles peer-to-peer forwarding. The codebase is built with CMake, uses protobuf for messaging, and relies on libraries like asio, OpenSSL, libvpx, libyuv, and zstd.
The LLM identified 5 files worth highlighting for reuse:
Implements an AEAD stream encryptor (AES-256-GCM or ChaCha20-Poly1305) with automatic key ratcheting every 256 messages. The interface is simple: `encrypt()` takes plaintext and nonce, returns ciphertext+tag. The key is derived from a base key and an IV counter, providing forward secrecy. This is a self-contained, well-tested pattern that can be reused in any project needing encrypted streaming without relying on TLS.
A generic rate limiter using the Generic Cell Rate Algorithm (GCRA). It tracks per-address request rates with a configurable burst size and interval. The implementation uses a hash map of atomic timestamps and is thread-safe for concurrent access. It can be extracted and reused as a standalone component for throttling connections in any network service.
An efficient representation of a rectangular region as a set of horizontal bands (row spans). This avoids the complexity of a full quadtree or R-tree while providing fast union, intersection, and subtraction operations. The implementation is self-contained and platform-independent, making it reusable for any application that needs to manage dirty rectangles or screen updates.
A reusable worker thread abstraction that wraps an asio io_context and provides a simple interface for posting tasks, timers, and tick events. The worker manages its own thread lifecycle and supports priority-based execution. It is used extensively throughout Aspia for background processing (audio, video, network) and can be extracted as a generic async worker library.
A standalone TOTP (RFC 6238) implementation with HMAC-SHA1, configurable time step, and constant-time comparison to prevent timing attacks. It includes URI generation for QR codes (otpauth://). The code is self-contained, well-tested, and can be reused directly in any C++ project requiring time-based one-time passwords.