$ show jetkvm/kvm
JetKVM is an open-source KVM-over-IP device firmware that enables remote keyboard, video, and mouse control over a network. The system is built as a full-stack embedded application: a Go backend orchestrates hardware interfaces (USB gadget emulation for HID, mass storage, audio, serial console), video capture and encoding (H.264/H.265 via Rockchip MPP), WebRTC streaming, OTA updates, MQTT integration, and network management. A React/TypeScript single-page application provides the web-based KVM console with real-time video, keyboard/mouse input, virtual media mounting, serial terminal, and device settings. The architecture separates a native C/C++ layer (LVGL UI, video pipeline) from the Go application via gRPC and a Unix socket, enabling failsafe mode and modularity. The codebase demonstrates strong engineering practices: extensive E2E tests against real hardware, a comprehensive OTA update system with GPG signature verification, a custom HID RPC protocol over WebRTC data channels, and a transactional USB gadget configuration system. While tightly coupled to Linux and Rockchip hardware, many internal packages (sync wrappers, confparser, changeset, playout delay interceptor) are well-isolated and could be reused in other Go projects.
The LLM identified 8 files worth highlighting for reuse:
A thin wrapper around Go's sync.Mutex that optionally enables lock tracing via a build tag. When the 'synctrace' tag is active, it logs lock acquisitions and releases; otherwise it's a zero-cost pass-through. This pattern allows debugging deadlocks in production without performance overhead in normal operation, and can be extracted into any Go project needing lock instrumentation.
Implements a custom RTP header extension for WebRTC playout delay control. It sets a minimum receiver-side buffering delay by inserting a standardized header extension (RFC 7273) into outbound RTP packets. This is a self-contained WebRTC interceptor that can be reused in any Pion-based media pipeline to enforce latency bounds.
Defines a binary RPC protocol for HID (keyboard/mouse) reports over WebRTC data channels. Includes message types (key press, mouse move, keepalive, macro), marshaling/unmarshaling, and a priority queue for ordered delivery. The protocol is transport-agnostic and can be extracted for any low-latency HID control system.
Implements a transactional, idempotent file-based configuration system for Linux USB gadget configfs. A ChangeSet records desired file contents and applies them only if they differ from current state, with rollback on failure. This pattern is reusable for any sysfs/configfs management where atomic, idempotent updates are needed.
A generic configuration parser that uses Go struct tags to define defaults, validation rules (one_of, required_if, validate_type), and nested struct handling. It sets defaults and validates a config struct before use. This is a standalone utility that can be extracted into any Go project needing declarative configuration validation.
An abstraction over Linux network configuration that manages interfaces, DHCP (v4/v6), static IP, hostname, and resolv.conf. It uses netlink for link state and provides a clean interface for network operations. While Linux-specific, the pattern of a network manager with pluggable DHCP clients and state reconciliation is reusable for embedded network stacks.
A reusable React button component with variants (primary, danger, light, blank), sizes, loading spinner, and link support. It uses Tailwind classes and follows a consistent API. This is a standard UI library component that can be extracted into any React project.
Defines a keyboard layout module with character mappings, key display names, and virtual keyboard layout. Each layout exports a consistent interface (KeyboardLayout) with dead key support and accent composition. The modular structure allows adding new layouts without modifying core logic, and the pattern is reusable for any application needing international keyboard input.