https://gitlab.synchro.net/main/sbbs/-/work_items/1213#note_11446
Thanks for this! TLS support in `irc.js` would be welcome, but this patch can't be applied as-is.
Patches are normally submitted, and accepted, as merge requests rather than as issues with attachments. An MR shows the diff against current master, can be reviewed line by line, and is merged with your authorship intact.
**It's based on an older `irc.js`.** Using the attached file as a drop-in would revert three later commits on master:
- 37fd799175 -- WEBIRC (passes the user's real IP address to the IRC server)
- fc82a6d911 -- `js.terminate_on_disconnect` handling
- d36741c77f -- top-level `const` `var` (needed for the upcoming SpiderMonkey 128 upgrade)
The `.patch` file has the same base, so it doesn't apply cleanly to master either.
**TLS should be opt-in, not tried on every connection.** As written, every connection starts a TLS handshake, then closes and reconnects in plaintext if that fails:
- Servers on plaintext ports (e.g. irc.synchro.net:6667) get two connections per user, the first one sending a TLS ClientHello they can't parse. That can trip connection throttling, and a server that just waits on the handshake leaves the user waiting for a timeout.
- Any TLS failure, including a failed certificate check, silently falls back to plaintext. `tls_error` is captured but never logged or shown. Anyone who can block TLS can force a plaintext session without the user knowing.
Please make TLS an explicit choice (e.g. a command-line option, a `+6697`-style port, or a `modopts.ini` `[irc]` key), and when it's chosen, report a failure as an error instead of falling back.
**Hostname verification.** Validating the certificate chain without checking the hostname doesn't provide authenticity: any CA-signed certificate for any domain will pass. When TLS is explicitly enabled, name verification should be on, with a way to turn it off for servers reached by an alias.
**Main loop.** The `recvline(512, timeout)` drain loop plus the unconditional `screen.update(100)` looks like a workaround for `Socket.poll()` not seeing plaintext cryptlib had already buffered. That was fixed in the engine (059de49b8e, in v3.21e), so it shouldn't be needed now. It also adds up to 100 ms of keyboard wait after each batch of incoming lines.
**Leftover debugging.** Please remove the "Diagnostic code" `Lost connection` message, and keep tabs for indentation to match the rest of the file.
**Separate fixes worth keeping:** adding `001` to the welcome `wait_for()` list, and treating `422` (MOTD missing) like `376` so the default channel still gets joined. These would be good as a small MR of their own.
If you rebase onto current master with TLS as an opt-in, please open a merge request.
-- *Authored by Claude (Claude Code), on behalf of @rswindell*
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net