* listen handoff = yes: the caller's line itself from modemmenu
A raw unix listener with header = yes and handoff = yes takes the
caller's line with the header (SCM_RIGHTS), as modemmenu's item with
handoff = yes sends it: the session runs on that terminal, nothing
copied between modemmenu and the BBS. What modemmenu had read and not
used comes on the connection after the header, ahead of the terminal.
The connection then only marks the session's life: logging off closes
it (the line goes back to the menu, its flags as they came), and the
menu closing it (its time limit, the caller gone) hangs the session up.
A header without a line is an ordinary call.
Tests: four callers on handed-over lines at once, each on its own
terminal; logging off closes the connection; the connection closed
takes the terminal away.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRxseyEuLRFbFaBoX3
* handoff: a closed or hung-up line ends the call quietly
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRxseyEuLRFbFaBoX3
* oscar test: let bob's arrival come again before Carol's
TestAIMToIRC failed on CI when alice saw a second arrival for bob
before Carol Ann's; the test now passes over repeats of bob's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRxseyEuLRFbFaBoX3
---------
Co-authored-by: Claude <noreply@anthropic.com>
A CIM client (AP in its ESC I answer) now gets the GUI service instead
of "?LOG CAI", following what 24high/CompuServe-Emulator recovered from
WinCIM 3.0.2:
- Secure Login (+ before the User ID): RA:/RB:/UR:/HR:, checked
against a key kept from the password (cis_keys, bound to the password
hash, kept only while a compuserve listener runs), "No." on failure
- the terminal-mode trade: ESC [ > 0 q, ESC [ > 3;3 p, the parameter
line's sum checked, ACK (NAK and again if wrong)
- xfer.BTransport: the B Plus Transport Layer, counters per direction,
1 KB blocks, messages as M packets and a final L
- HMI: session open, pages (menus as 0x27, articles as 0x28 and their
text in pieces), the rest of a menu, Find, the directory lookup, acks,
logoff; CIS:/HOM: names on the ASCII service's page tree
Forums, Mail and CB in CIM say to use a terminal for now.
Claude-Session: https://claude.ai/code/session_01B82eRRPWCkk1Ro91AuzXFM
Co-authored-by: Claude <noreply@anthropic.com>
A listener with frontend = compuserve serves the CompuServe Information
Service on the BBS's users: Host Name, User ID (an account's number as a
CompuServe ID, or its name) and Password, ?LOG codes, ESC I terminal
identification, the banner and logoff text, and the ASCII service's menu
and article pages with GO, FIND, T/M/B/F/R/N/P, SET and ; chaining. CIM
clients are told ?LOG CAI until the HMI service is built.
internal/xfer/cisb.go is CompuServe B, Quick B and B Plus, the host's side
and the terminal's: ENQ start, + parameter negotiation, quoting, all four
check methods, a send window with ENQ resynchronization, downloads and
uploads. Tested against the spec's checksum and CRC values and over a
noisy loopback.
docs/cis holds the research and design behind it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRPWCkk1Ro91AuzXFM
The repositories moved from Neo-Desktop to the D-Modem GitHub
organisation: D-Modem-RE is now D-Modem/D-Modem, pico-serial is
D-Modem/hardware, modemmenu (PBX-Modem) is D-Modem/menu, bbs-sec is
D-Modem/bbs and go3270-sec is D-Modem/go3270. Update links, module
paths, submodule URLs and source-location strings to match. Copyright
notices still name Neo-Desktop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUwD2JJ5d6fgHmpVTw
- door: telnetClient.Read returns at once for an empty buffer; a failed
answer to an option is returned by the next Read or Write rather than
reading on for ever.
- ssh: sshTerm.pump stops once closed when the channel reads nothing
without error, instead of spinning.
- ssh: makeHostKey removes the key file when Close fails, not only Write.
- fido: flock retries EINTR; Lock retries a failed lock file briefly.
- tn3270: negotiation and its 30s watchdog decide by one flag, so a
negotiation ending as time runs out keeps its connection.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
Every function and method, tests included, has a doc comment: what it
is or does, what it returns and anything a caller needs to know. Only
comments are added; gofmt split a few aligned blocks of one-line
functions once each had its own comment. The generated protobuf code
is left as protoc writes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
[general] user (and group): started as root, bbs serve reads the
configuration, binds every socket it listens on (the listeners, TCP and
unix; the HTTP API and metrics, FTP, NNTP, IRC, finger, gopher, binkp),
gives up root (setgroups to the user's groups, setgid, setuid) and
executes itself again, the same process (its PID, for systemd and
reload), the sockets handed down; each server's listen takes the one for
its address (internal/sockets). Nothing is written as root: database,
logs, host keys, backups and a unix socket without socket_group are the
user's.
Other commands as root give root up first, so the database stays the
user's (but check and config; backup restore puts things back as root
and gives them, but the configuration, to the user). System
configuration has Run as user and group.
TestRunAs (as root) serves a port under 1024 and a unix socket as
nobody, the same process through a reload.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
TestDoorSession failed about once in 100-200 runs, two ways:
- "fork/exec door.sh: permission denied": the server made unix sockets
under a umask of 0177, and the umask is the whole process's. A file
made by another goroutine meanwhile lost its mode: here the test's
door script, written as the server started, came out 0600. In the
BBS the same could befall anything made while a listener started.
The socket is now made in a private directory beside its place, given
its mode and group there, then renamed into place: still no moment
when others could connect, and no umask touched. Closing the
listener removes the socket.
- the door's last output lost ("Bye from the door" never came): a door
without a pty wrote to cmd.StdoutPipe, which Wait closes as soon as
the door exits, while the reader may not have drained it. The door
now writes to a pipe of the runner's own, read to its end.
TestOutputAfterExit (door) lost 28-48 KB of a door's last output on
every run before; TestSocketLeavesUmask (server) saw 0755 files made
0600 within a few dozen tries. Both pass now, and TestDoorSession
passed 500 runs in a row under -race.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
- the reader gives an address's region (the first subdivision) and city
where the database has them: GeoLite2/GeoIP2 City and DB-IP's City
Lite as MaxMind DBs; DB-IP's city CSV and IP2Location LITE DB3 and up
as CSVs (now read with encoding/csv, quoted fields and all)
- CSVs stream in (gzipped or not) and are kept small: each place once,
each range by its start, IPv4 apart in 4 bytes; DB-IP's city list,
7.8 million ranges, in 135 MB
- geoip.File reads the first time at once and later changes in the
background, the old reader answering meanwhile; the server reads the
database when it starts; the image boards share the BBS's when the
file is the same
- bbs.Place has the city; the log and the sysop's node list show
"Mountain View, California, United States"; who's online, the API and
the forum's flags still show only the country
- checked against MaxMind's reader on DB-IP's city database of October
2026 in both formats: the same country, region and city for 200,000
addresses
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
NANPA's site was out of reach, so the hand-made tables were checked
against Google's libphonenumber (its data of 2026-10-08, kept up from
NANPA and the national regulators) and then replaced by it:
- the area-code check found 273 (Quebec) and 633 (Canadian personal)
missing, and nine US codes it has nowhere (357, 436, 457, 483, 624,
679, 837, 861, 924): those are gone with the old tables
- internal/phone/gen makes metadata.go (every territory's calling code,
international and trunk prefixes, shared-code rules, number kinds and
formats) and places.gz (269,198 prefixes to places, 151 calling codes)
from a libphonenumber checkout: make phone-data
- Parse follows libphonenumber's rules: national prefixes taken off and
transformed, shared codes told apart by leading digits and plans,
the kind of number (fixed line, mobile, toll-free...), the place to
the exchange where known, and numbers written as each country does
(+44 20 7123 4567, +81 3-1234-5678)
- checked against nyaruka/phonenumbers on 34,362 numbers: the same
country, kind and place for all; formats differ only for the Faroes,
where its bundled data is older
- the tables load when first wanted (about 6 MB); the sysop's node list
says which callers are on mobiles
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
- internal/phone reads modem caller IDs with its own tables: the ITU's
country calling codes (shared ones told apart), the NANP's area codes
by state and province, toll-free and other services, and how each
country dials, so national numbers read as [general] phone_country
- [general] geoip (with geoip_credit) is the BBS's country database;
[chan] geoip falls back to it. geoip.File keeps a database file up
to date for both
- bbs.Locate and Node.Place: a caller's place by caller ID, else by
address; the connect log, who's online (the country), the sysop's node
list (number and state) and the API's /who show it
- messages keep the poster's country (messages.country); the web forum
shows its flag by the poster's name in every theme and on Online
Users, with the database's credit at the foot ([http] forum_flags)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
The text BBS and 3270s have the image boards (B on the main menu, or a
menu's boards): the boards, threads by bump order, posts read as
messages with who posted, the thread, and the posts that quote them.
Callers post as the web's posters do (names, tripcodes, sage, staff's
capcodes), through the same checks: posting is now Submit, shared by
the web's form and bbs.ImageBoards. A thread's image comes by the
terminal's transfer protocol.
Pictures (view.Picture, on messages and panels) are shown as well as
the terminal can: kitty's graphics protocol (kitty, Ghostty), sixel,
iTerm2's inline images (iTerm2, mintty), or coloured half blocks in 256
colours on other UTF-8 terminals; described in words elsewhere and on
3270s. V shows the image whole; pictures on/off is on the profile. The
web terminal has xterm.js's image addon, so sixel there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
[security] in bbs.conf (internal/guard):
- deny_file: addresses and networks (IPv4, IPv6, CIDR) whose
connections every service closes at once: the terminal listeners and
SSH, FTP, NNTP, the HTTP API, finger, gopher and binkp. Read again
when it changes; bbs check warns of bad lines. Unix-socket callers
(modem servers, menus) are never refused.
- ban_minutes: an address the login throttle turns away is banned from
every service for that long. The API lists bans and lifts them.
- name_deny_file: name patterns (* wildcards, any case) no new account,
nor one an upstream menu makes, may take; the text BBS says so as the
name is typed.
- hack_log: failed logins and the names tried, locked accounts,
throttles, bans, refused connections and names, one a line; the API
shows its end.
A telnet or raw listener with tls_cert and tls_key is telnet over TLS
(1.2 or later; port 992), with 15 seconds for the handshake.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
[http] serves /terminal (and / goes there): a page with xterm.js 5.5 and
its fit addon, built into the binary (MIT licensed, license included),
joined by a WebSocket (/terminal/ws, subprotocol bbs.terminal, binary
frames) to the text BBS, run in-process as for a telnet caller: a node
shown as "web terminal", the BBS's own login, ANSI and UTF-8, the size
the page fitted.
The page has a strict Content Security Policy (scripts only from the
BBS, no inline scripts, no framing); the WebSocket is taken only from
the BBS's own pages (or the cors origin), under the HTTP server's TLS,
connection and rate limits. terminal = no turns it off.
The WebSocket's own stream closes the connection when a read deadline
passes, which the text BBS uses for idle time and notices: the line
adapter SSH sessions had (reads with deadlines that only end the read)
now serves both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
A Commodore's terminal answers no question, so petscii = auto no longer
asks every caller that is not ANSI to press DEL. Such a caller is
watched while it logs in, its logon screen and name prompt in capitals
(which a C64 and anyone else both read):
- a key only a Commodore has (DEL, cursor keys but down/XON, F1-F8, CLR,
a shifted letter not followed by a UTF-8 continuation byte) switches
to PETSCII at once: the screen cleared, with the questions' leftovers,
and the logon and name prompt again;
- a name in lower case is ASCII, with nothing asked;
- a name all in capitals brings the DEL question; a Commodore's DEL
makes it PETSCII and the name is taken in lower case, as typed.
What is not settled by the end of the login is ASCII.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
internal/vt asks an ANSI terminal everything at once (ENQ answerback,
DA1, DA2, XTVERSION, its cell size), with a cursor position report last
so the answers are complete when it comes, and reads them into a name
(XTVERSION, SyncTERM's CTerm, DEC models by DA2 and firmware, tmux,
screen, mintty, rxvt, xterm, VTE, the answerback, the VT class), a VT
level, sixel and color. A terminal that is not ANSI is asked ESC Z: a
VT52 answers.
What it said changes what the caller gets: a VT without UTF-8 (not a
PC's CP437 BBS terminal) gets line drawing in DEC Special Graphics and
Latin-1 on a VT220 or later; a DEC monochrome terminal gets bold for
color; a VT52 its own escapes (VT52Writer) with its cursor keys ignored.
Sixel now comes from the same answers. The name shows in the profile,
the log and the API's who (terminal). A listener's vt = no asks nothing.
Also: the terminal type and rlogin's rate are set under the BBS's lock
(who's online reads them).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
PETSCII: internal/petscii translates what the text BBS writes for ANSI
terminals (UTF-8, SGR colors, clearing, cursor movement, box drawing)
into the C64's lower/upper case set and color codes, and reads its keys
back (DEL, RETURN, shifted letters). A listener's petscii = yes makes
every caller a Commodore, auto asks a non-ANSI caller to press DEL, and
telnet terminal types like c64 or petscii are believed. Callers get 40
columns (80 for a C128 from the profile): one column menus and lists
that fit. .seq display files are sent as they are; doors are not
offered.
RIPscrip: internal/rip writes RIPscrip 1.54 (MegaNums, drawing, button
styles, buttons, text windows). rip = auto asks BBS terminals with
ESC [ ! and a position report; a RIP terminal gets every menu, built-in
or the sysop's, as a scene of buttons that send their keys, cleared on
a choice, and .rip display files before .ans.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
[listen NAME] type = ssh serves the text BBS over SSH. Users log in
with their BBS password (password or keyboard-interactive, throttled
and delayed as on a terminal) or with one of their public keys; the
user "new" gets the BBS's own prompt to sign up. The pty's terminal
type and size go to the text BBS. Commands, SFTP, forwarding and
second sessions are refused.
Host keys (ed25519 and RSA by default, beside the database) are made
0600 the first time and refused when others may read them; legacy = yes
adds CBC ciphers and group1 DH for old clients.
Keys live in a new ssh_keys table and are managed by bbs sshkey
add/list/del, the profile on the text BBS (after the password again),
and /api/v1/me/keys (from a login's session only, not an API key).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
Chat rooms for callers on any node (C on the text menu, Chat on a 3270):
/join, /me, /who, /rooms, /msg, the last lines of a room for who comes
in, a flood limit. A line to one node, from who's online or /msg.
Paging the sysop (S): sysops online and not /busy are told, the caller
waits in a private room, /answer joins it; with no sysop on, page_command
runs (no shell) and the caller may leave a message. On the text BBS,
lines from other nodes show at whatever prompt the caller is at, above
what they type; on a 3270, on the next screen's message line, and the
chat screen refreshes on Enter or PF5.
[finger] (RFC 1288): who is on and who a user is, no addresses, no
forwarding. [gopher] (RFC 1436): about, who's online, and the message
and file areas the sysop opens to it (none by default; bbs check warns),
selectors naming records, not paths.
Also: the TN3270 handoff set the caller's Via while who's online could
read it (a data race the new test found); it is set under the lock now.
Tested: the chat hub; two text callers chatting and paging; s3270 chatting
with a text caller; finger with the finger program, gopher with curl.
Wiki pages Chat-and-Paging and Finger-and-Gopher.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
internal/xfer has the protocols, both ways:
- XMODEM: CRC or checksum as the receiver asks, 128 or 1K blocks
- YMODEM batch: names and sizes in block 0, sizes kept exactly
- ZMODEM: hex and binary headers, CRC-16/32, ZDLE escaping; sent in
32 KB segments ended by ZCRCW, so a ZRPOS costs at most a segment
and nothing is read while streaming; refused files are skipped
- Kermit: short packets, control quoting, 8th-bit prefixing and repeat
counts as agreed, block checks 1, 2 and 3
Each has timeouts and retry limits, and takes no more than the upload
behind it allows. Tests run them against lrzsz (sx/rx, sb/rb, sz/rz)
and C-Kermit (over a raw socket), both ways, and ZMODEM over a line
that damages bytes.
In the file areas: D downloads a file, U uploads into an area (names a
terminal program sends lose their paths and odd characters; XMODEM
asks for one), then asks for descriptions. The transfer uses the
terminal's buffered reader, so nothing typed ahead is lost, and the
line is let settle afterwards. Telnet in binary mode now keeps a NUL
after a CR (it is data there); a telnet client that refused binary
mode is warned that X/Y/ZMODEM will likely fail.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
Every ANSI terminal is asked for its device attributes (CSI c) and its
cell size in pixels (CSI 16 t); one that has sixel (attribute 4) sees
the logo as a picture above the system's name: [general] logo, a PNG,
or the name drawn in a pixel font, fitted to the window. Callers turn
it off or on in their profile. Listeners have sixel = auto (telnet's
default) or no (raw and rlogin: modem lines are slow).
The encoder (internal/sixel) keeps a picture's own colors up to 255
and dithers to the web-safe palette beyond, leaves transparent pixels
as the background, run-length codes, and keeps register 0 black for
decoders that fill unset pixels with it; a test decodes its output
with ImageMagick. The logo's PNG and pixel font move to internal/logo,
shared with the 3270 logo; the PNG's size is checked before it is
decoded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
go3270 is replaced by the Neo-Desktop/go3270-sec fork, which keeps the
terminal's query replies and builds Load PS and Object Picture
structured fields. With it the 3270 BBS uses what the terminal has:
- graphic escape (nearly every 3270): a box around the main menu,
rules, bar charts of messages by area; ASCII where there is none
- programmed symbols (PCOMM, HostExplorer): the logo on the logon
screen, the system's name in a pixel font or a PNG (tn3270_logo),
cut into character cells, deduplicated and loaded into the first
loadable symbol set, format 1 (9x16) or 3 as the terminal says
- vector graphics (PCOMM's native host graphics): the logo as a bitmap
image instead, with tn3270_vector = yes; experimental
Option 7, "Your terminal", shows what the terminal reported, every
query reply in hex included, and the log has a line of it for each
3270, for setting emulators up. A panic while serving a caller now
costs that call only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
One telnet port serves both kinds of terminal: a client that says it is
a 3270 (IBM-327x, IBM-DYNAMIC) is handed to go3270 and gets full 3270
screens with PF keys; any other gets a text BBS with ANSI color where
the terminal has it. Modem callers come through the D-Modem suite:
app_dmodem's mode = tcp on a raw port, or modemmenu by rlogin, telnet,
or a unix socket whose session header (MODEM_*/DMODEM_*) gives the
call's details and, trusted, the user modemmenu logged in.
Message areas, private mail, who's online, the user list, profiles and
self-service sign-up, in SQLite. User text is cleaned of escape
sequences and control characters before it is stored and shown;
passwords are bcrypt; logins are delayed, limited and throttled per
address or caller ID; every step has a size limit and a timeout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr