• PROXY protocol (HAPROXY_PROTO): one slow client stalls the listener wh

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Sat Nov 21 19:34:04 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1393
    2026-11-21 19:34:04 -0800

    With `HAPROXY_PROTO` enabled (Web Server or Terminal Server), one slow client can stop the server from accepting any other connection for up to about two minutes.

    ## Where

    `xpms_accept()` (`xpdev/multisock.c`) accepts the connection and then, still inside the call, reads the PROXY protocol header with `read_socket_line()` / `read_socket()`. Those read one byte at a time and wait up to 1 second (`socket_readable(sock, 1000)`) for each byte. The servers call `xpms_accept()` from their single accept loop (`websrvr.cpp`, `main.cpp`), so no other connection is accepted until it returns.

    ## Effect

    A peer that connects and sends a byte just under every second keeps the read going for up to 107 bytes (the v1 line buffer, 108 bytes), about 107 seconds, and longer for a v2 header, which is read in further pieces. During that time the listener accepts nothing; new connections queue in the listen backlog and time out. A few such peers, one after another, hold off every client indefinitely, using one connection each.

    This happens before any `ip.can`, `ip-silent.can`, connection rate-limit or concurrent-connection check, so none of them can stop it, and when the option is enabled any client that can reach the port can trigger it (no proxy needed; see #1391).

    ## Proposal

    - Read the PROXY header after the accept loop has handed the connection off (in the session thread, as the TLS handshake already is), so a slow peer holds only its own thread; or
    - at least, bound the whole header read by one overall deadline of a few seconds, not 1 second per byte.

    #1391 covers the other PROXY protocol problem: the header is believed from any peer.

    -- *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)