$ show trzsz/tsshd
tsshd is a UDP-based SSH server (and Go library) designed for unreliable networks, providing seamless client roaming and auto-reconnect. It works in conjunction with the tssh client (trzsz-ssh). The architecture is session-based: a standard SSH login spawns a tsshd process that listens on a UDP port (using KCP or QUIC transport), then the client switches to UDP communication, surviving network changes and temporary disconnections. The codebase implements a full-featured SSH replacement: session management, port forwarding (TCP/UDP), X11 and agent forwarding, terminal attach/detach, and a middleware system for custom session handlers. It also includes a reusable client library (SshUdpClient) for building custom SSH applications with roaming support. The project is well-maintained with extensive test coverage, CI/CD, and multi-platform support (Linux, macOS, Windows, FreeBSD).
The LLM identified 3 files worth highlighting for reuse:
Implements `timeoutChecker`, a self-contained heartbeat timeout monitor with callbacks for timeout and reconnection events. It uses atomic operations and channels to track last alive time, supports multiple registered callbacks, and provides `waitUntilReconnected()` blocking. This is a reusable component for any Go application needing connection health monitoring without external dependencies.
Provides `replaceableStream` and `interruptibleStream` implementations that allow hot-swapping the underlying I/O stream without losing data or causing race conditions. The design uses condition variables, atomic booleans, and channel-based synchronization to safely replace a stream at runtime. This pattern is reusable for any scenario requiring live stream replacement (e.g., reconnection, session migration) and demonstrates non-trivial concurrency handling.
A complete parser for OpenSSH sshd_config files, including Match block evaluation with User, Group, and All criteria, subsystem registration, and AcceptEnv handling. It correctly handles key-value formats with or without '=', wildcard patterns for user/group matching, and provides a query interface via `getSshdConfig()`. This is a standalone module that can be reused by any Go tool needing to read OpenSSH configuration.