open
https://gitlab.synchro.net/main/sbbs/-/work_items/1394
2026-11-21 19:38:29 -0800
The Terminal Server's accept loop in `main.cpp` (`bbs_thread()`) waits on two network lookups for each new connection before it hands the connection to a node: while either runs, it accepts no other connection, on any of its ports (Telnet, RLogin, SSH).
- **Reverse DNS**: `getnameinfo(..., NI_NAMEREQD)` for the client's hostname (`"Resolving hostname..."`), unless `NO_HOST_LOOKUP` is set. A lookup can take the resolver's full timeout, typically 5 seconds per attempt, times the attempts and name servers configured. Whoever controls the reverse DNS zone for an address (any client with its own IP block, or a cloud host that lets the customer set PTR records) can make that lookup slow on purpose, so each connection from such an address holds the listener for the whole timeout; a few in a row lock out every caller. An ordinary slow or unreachable DNS server does the same to legitimate callers.
- **Ident (RFC 1413)**: `identify()` with a 1-second timeout, when `GET_IDENT` is set.
Both happen before the connection's `host.can` check, temporary-ban check and node assignment, so none of those limit it.
The other servers do these lookups after hand-off, in the client's own thread, where a slow lookup delays only that client:
- Web Server: `http_session_thread()`
- FTP Server: `ctrl_thread()`
- Mail Server: the POP3 and SMTP session threads
- Services: `js_service_thread()` and `native_service_thread()` (ident included)
## Proposal
Move the hostname lookup and the ident lookup out of the accept loop, into the node's thread (`node_thread()` or the start of `answer()`), together with what depends on the hostname there: the `host.can` check (`host_exempt` / `host_can`, which matches the hostname), the `Hostname:` and `Identity:` log lines and terminal output, and the `client.host` value given to `client_on()` and to the `sbbs_t` constructor (updated with `client_on(..., update: true)` once known). The checks that need only the address (`ip.can`, the temporary ban, concurrent-connection limits) can stay in the accept loop.
-- *Authored by Claude (Claude Code), on behalf of @rswindell*
--- SBBSecho 3.38-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)