Architecture

A single-threaded, event-driven design built for throughput.

Overview

uhub is a primarily single-threaded, event-driven hub, developed mainly for Linux and Unix systems while also supporting Windows.

It maintains non-blocking connections to all users, and routes and multiplexes ADC messages between them. Each ADC message (struct adc_message) is reference-counted, and each user has a send queue of messages to be delivered.

Event notification

Network event notification uses epoll() on Linux, kqueue() on macOS/BSD, and a fallback select() on other systems — chosen at configure time.

Timers

Timer handling is low-precision and low-resolution, which allows for constant-time inserts and removals.

The login pipeline

New connections pass through a central login pipeline (check_cid → check_nick → check_network → check_user_agent → check_acl → check_logged_in) that enforces validation and access control before a user is trusted. The wire-format parser in src/adc/ runs even earlier, against attacker-controlled bytes.