This page is for persons who work on the code of the BBS. It gives the layout of the source, how the terminals share the screens, and what the tests cover. ## Layout | Path | What it holds | |---|---| | `cmd/bbs` | the command: serve, check, init, user and area administration | | `internal/server` | listeners, session headers, rlogin, SSH, identification of 3270s and other terminals | | `internal/telnet` | the server side of telnet: options, terminal type, window size, the handoff to go3270 | | `internal/confedit` | edits bbs.conf as a sysop does by hand, and keeps the comments; the catalog of keys read from bbs.conf.sample (embedded by the root package), and the keys that a reload applies | | `internal/sockets` | ports bound as root and given to the BBS: the BBS changes to its user, in the same process | | `internal/backup` | backups: the configuration, a database snapshot and the files in one tar.gz; list, prune, restore | | `internal/confui` | the configuration menus (sheets of internal/view), for `bbs config` and the sysop's tools: changes are kept until you save them | | `internal/view` | the description of what the screens show, written one time: menus, tables, messages, forms, panels, drafts | | `internal/script` | the sysop's JavaScript (goja): screens of internal/view, the BBS as the caller, kept data, the time limit for computation by a script | | `internal/guard` | deny lists, bans, the name filter, the hack log | | `internal/geoip` | country databases: MaxMind DB files and CSVs of ranges, with its own reader; a file that it keeps up to date | | `internal/phone` | caller IDs, from the numbering plans and places of libphonenumber (and NANPA's area codes (generated by `internal/phone/gen`: `make phone-data`) | | `internal/events` | the sysop's scheduled events | | `internal/app` | the screens after the login, for all front ends: menus, areas, mail, files, who is online, the profile, validation, a page to the sysop | | `internal/textui` | the text front end: the login, line editing, ANSI detection, paging, RIP menus; the screens as prompts and keys; chat, doors, transfers | | `internal/ui3270` | the 3270 front end: the logon, the screens as fields and PF keys on go3270; chat, IND$FILE, its graphics | | `internal/sixel` | the sixel encoder | | `internal/petscii` | the character set of the Commodore: translation of ANSI and UTF-8 output, and of keys input | | `internal/rip` | RIPscrip: MegaNums, commands, menu scenes | | `internal/vt` | terminal identification (DA1, DA2, XTVERSION, CTerm, answerback, VT52); DEC graphics and VT52 output | | `internal/files` | the storage of the file areas: names, uploads, limits | | `internal/ftp` | the FTP server: the file areas as a file system | | `internal/news` | articles: parse, check, make, decode; wildmats | | `internal/nntp` | the NNTP server and the client for the peers | | `internal/ircd` | the IRC server: channels as chat rooms; ergo's irc-go, numerics and ISUPPORT list | | `internal/mrc` | Multi Relay Chat: the BBS as its own connector, MRC's rooms as chat rooms | | `internal/qwknet` | the node of a QWK network: it calls the hub by FTP, sends REPs and receives packets | | `internal/qwk` | QWK packets and REPs: the blocks of MESSAGES.DAT, CONTROL.DAT, indexes (MBF floats), QWKE kludges, CP437 | | `internal/ftn` | the formats of FidoNet: addresses, Type 2+ packets, messages, kludges, character sets | | `internal/fido` | the BBS on FidoNet: tosser, scanner, netmail, the binkp mailer | | `internal/door` | doors: drop files, a door that runs on the caller's line | | `doors/dosemu2` | the Docker image in which DOS doors run: dosemu2, its FOSSIL on COM1 | | `internal/finger` | the finger server | | `internal/gopher` | the gopher server | | `internal/gemini` | the Gemini server: the capsule of gopher and the users of finger, over TLS | | `internal/forum` | the web forum: its pages (html/template; `themes/NAME/` holds the templates of one theme, which go over those of its parent and `templates/`), the CSS of the themes (`static/`), sessions by the tokens of the API | | `internal/api` | the HTTP API: REST, server-sent events, WebSockets, metrics, OpenAPI; the web terminal page (`web/`: xterm.js, the page) | | `proto` | the WebSocket protocol, `bbs.v1` (`make proto` generates `internal/api/pb` again) | | `internal/tcpserv` | the parts that finger, gopher and Gemini share: limits, timeouts | | `internal/screens` | the sysop's display files: how to find them, @-codes, 3270 color tags | | `internal/xfer` | XMODEM, YMODEM, ZMODEM and Kermit, in the two directions | | `internal/logo` | the logo: a PNG, or the name in a pixel font | | `internal/bbs` | the BBS: nodes, logins, new users, posts, text cleaning | | `internal/store` | the database: SQLite, PostgreSQL, MySQL or MariaDB (`dialect.go` holds the differences, `schema.go` the tables), copies between them | | `internal/config` | the configuration file | ## Screens The screens after the login are written one time, in `internal/app`. Each front end draws them. A screen is a description in the terms of `internal/view`. The BBS gives the screen to the front end. The front end shows it, waits for the caller, and reports the selection of the caller: | View | Text terminal | 3270 | |---|---|---| | `Menu` | `[K] Label` in two columns (one column below 60 columns), RIP buttons, the command prompt | a box of keys, `Option ===>` | | `Table` | numbered rows, one page at a time; `Area number, [N]ew scan, [Q]uit: ` | `S` adjacent to a row; PF keys; PF7/PF8 | | `Message` | headers, the body in pages; `[N]ext, [R]eply, ...` | headers, the body with scroll; PF10/PF11, PF4 ... | | `Form` | one question for each field | one screen of fields | | `Panel` | lines, then `[L]ocation, [P]assword, ...` | lines, PF keys | | `Draft` | `To`, `Subject`, the full-screen editor (ANSI) or the line editor | the editor screen | | `Confirm`, `Say`, `Show` | `[Y/n]`, a line, lines and a pause | a Y/N field, the message line, a page | An action has a key for text terminals and a PF key for 3270s. It also has a short label for the key line of the 3270. Functions that only one front end can do are in its `app.Frontend`: - The sysop's display files. - Chat. - Doors (text only). - File transfers (protocols on text, IND$FILE on a 3270). - The terminal line in the profile, and the settings that you can change there. - The goodbye. The front ends keep the logins, because they identify the terminal. To add a screen, write a function in `internal/app` that builds views. To add a front end, implement `app.Frontend`. The tests of `internal/app` operate the screens with a scripted front end, without a terminal. ## Tests You can set `BBS_TEST_DATABASE` to a PostgreSQL, MySQL or MariaDB server. Then each test gets its own database on that server (a schema on PostgreSQL, a database on MySQL). The test drops it after it is complete. Thus, the full suite runs on that engine: ``` BBS_TEST_DATABASE='postgres://bbs:PASSWORD@127.0.0.1/bbs?sslmode=disable' go test ./... BBS_TEST_DATABASE='mysql://bbs:PASSWORD@127.0.0.1:3306/bbs' go test ./... BBS_TEST_DATABASE='mariadb://bbs:PASSWORD@127.0.0.1:3306/bbs' go test ./... ``` The user must have permission to `CREATE SCHEMA` (or `CREATE DATABASE`). The tests of the store check the items that are different between the engines: names in all cases, ids, upserts, booleans, bytes, long text, cascades, and copies from SQLite. ### What the tests cover `make test` runs the unit tests and full sessions against a running server on unix sockets. The list that follows gives what the tests cover. - **Unit tests:** text cleaning, names and passwords, the configuration, telnet negotiation and the 3270 handoff. - **Sessions and lines:** a modem caller with a trusted dmodem-login header, and one with a header that is not trusted; a login and a post; a new user; rlogin with a correct password, a wrong password, and trusted; limits by caller ID; all lines busy; a telnet ANSI client; a TN3270 client through go3270's negotiation to the logon screen and out with PF3. - **Transfers:** the transfer protocols against lrzsz (`sx`/`rx`, `sb`/`rb`, `sz`/`rz`) and C-Kermit in the two directions, and ZMODEM over a line that causes damage to bytes; uploads and downloads through the BBS by ZMODEM, Kermit, YMODEM and XMODEM-1K; IND$FILE with a real s3270 (upload, download, a file that does not exist). - **File store and FTP:** the file store (names, limits, the daily allowance, areas for the sysop only); the FTP server with a real FTP client (uploads, downloads and their count, all refused operations, path traversal, wrong logins, anonymous access, TLS required and explicit TLS, the size limit, the limit for each address). - **Graphics:** telnet terminals with and without sixel; the sixel encoder, checked when ImageMagick (if installed) decodes its output; TN3270 clients that report programmed symbols (the BBS loads and shows the logo), vector graphics (the BBS draws the logo) or neither (the BBS sends nothing). - **News:** articles (parse, limits, decode, wildmats); the NNTP server with Python's nntplib as a newsreader (login, reading, overview, posting); its refusals (a post without a login, AUTHINFO before STARTTLS, forged headers, control messages, oversized articles, IHAVE from an unknown peer); two BBSes that are peers in the two directions, and IHAVE. With `BBS_TEST_INN=host:port`, it also synchronizes with a running INN. - **FidoNet:** packets and messages; a hub with two nodes that exchange echomail by binkp (SEEN-BY, PATH, threads, forwarding); netmail and replies; wrong passwords, unknown addresses and impostors; dupes, loops, bad and foreign packets; the echo-newsgroup gateway. When binkd and CrashMail are installed, a hub that they operate: echomail and netmail in the two directions, calls to it and calls from it. - **Doors:** the drop files; the runner (CP437 and UTF-8, time limit, hang-up, idle, single-caller doors, a pseudo-terminal); a caller who opens a door from the menu. When the bbs-dosemu2 image is built, a real DOS door in it that communicates by FOSSIL. - **Chat:** rooms, history, private rooms, flooding, node messages, pages and answers, the page command (and a check that it runs no shell); two callers who chat and page on the text BBS; a 3270 (s3270) that chats with a text caller and gets a node message on its message line. - **Finger, gopher and Gemini:** their answers and refusals, with the finger program and curl as clients, and a check that `bbs gemini cert` asks before it makes a certificate. - **Customization:** how the BBS finds display files by terminal, SAUCE, @-codes and widths, color tags; menus and strings in the configuration and what it refuses; a text caller through an ANSI logon (CP437 unchanged), the strings, a welcome screen, the sysop's menus and submenus, a screen with a pause and a goodbye screen; a 3270 (s3270) through a colored logon screen, welcome, the sysop's main menu and a screen. - **The shared screens:** `internal/app` with a scripted front end (posting, reading forward and back, a new scan and reply, a number that is not on the page, mail to no user and to the sysop, a node message, deleting, the profile, a password that is different, a validation with a bad level first); the column layout; the keys of the text prompts; a 3270 (s3270) through the areas, a post from the editor, reading it, the profile, with a text caller who reads the post of the 3270. - **The full-screen editor:** its text (wrap as you type and as given, a word that is too long for a line, join lines with Backspace and Delete, move over line ends, quotes, the line limit); an SSH caller who writes a post with the cursor keys, replies with lines from the quote window and `/S`, then selects the line editor. - **The message base:** threads from all messages, votes, polls and their answers, aliases (names that are in use are refused), signatures, groups, keep by count and by age; through internal/app and the API. - **The sysop's tools:** a sysop who monitors the screen of a caller as the BBS sends it, calls the caller into chat at the next menu, and is away when the caller pages; the user editor, statistics, bans, the hack log and events through internal/app; events that run, fail, time out, and do not run two times; their configuration and the API. - **Users:** the last callers, feedback to the sysop, the details of a user (more details to a sysop) and mail from there, a line about the user, expert menus and `?` on a text terminal. - **Callers kept out:** the deny file, read again when it changes; networks and IPv6; bans after the throttle, and the end of the bans; name patterns; the lines of the hack log; telnet over TLS with a login; a plain client on the TLS port that gets nothing; a denied address, closed immediately; the bans and the log of the API. - **Scripts:** screens; data kept for all users and for one user; posts with refusals caught; a runaway loop that the BBS stops, and a slow caller that it does not stop; failures told only to the sysop; a hang-up that the script cannot catch; exit; the sample poll; the checks of the configuration; the sample one-liners on a text terminal and on a 3270 by s3270. - **The file base:** FILE_ID.DIZ in CP437 with colors; the listings of a ZIP and a tar.gz; new files; search by the words of the DIZ; tags by numbers; a batch of two by YMODEM; ratios and the limit for the day together; the search and listings of the API. - **MRC:** a fake MRC server: the handshake, arrivals, NEWROOM, lines and actions in the two directions, colors removed, our own lines not shown two times, private messages and server answers to one user, PING and IAMHERE, !commands and !!, a user in two rooms, LOGOFF, the line dropped and the users put back, rooms that are not MRC rooms not sent, require. On IRC: the hostmask of an MRC user and the notices of the room. - **Doors at other locations:** the negotiation of a telnet server, answered and kept from the caller, doubled IACs; the start of RLogin and a refusal; the token of BBSLink, its MD5s and a wrong code; DoorParty through the tunnel of an SSH server, a wrong password and a wrong host key refused; a caller on the BBS who goes through one and comes back; their configuration. - **The IRC server:** logins by PASS and SASL PLAIN, and refused logins; a nick made from a name with a space; lines in the two directions between an IRC client and a telnet caller, /me, node messages, the history of the room with server-time, WHO, WHOIS, LIST, a page that the user answers when the user joins its room, parting, the node removed with QUIT, TLS, bad nicks; the client of irc-go with SASL and echo-message. - **BBSServ:** help, info, each of the settings and their refusals, the new scan, SSH keys added with the password and deleted, tokens revoked, the password, by /msg and by /BS, CTCP, WHOIS, notices without an answer. - **Permanent rooms:** open when empty; their topics shown when a user comes in and told when set, by /topic, TOPIC and BBSServ; refused to users who are not the sysop; kept across a restart; released; @BBSServ in NAMES, WHO, WHOIS and LIST, on all database engines; the checks of the configuration. - **QWK offline mail:** packets and REPs read back as a reader does, long subjects as QWKE kludges, CP437, the REP of a different BBS refused, the MBF floats of the indexes; the messages of a packet marked as read only after it has gone; the replies of the REP posted and mailed as the caller; a REP sent two times that posts one time; by ZMODEM on a text line, by IND$FILE from s3270, by FTP and the API. - **QWK networks:** a hub that serves FTP and two nodes: the messages from before the join are kept back, posts go up under the names of their writers, the posts of a node do not come back to it, a reply is threaded at the hub, nothing comes two times; the checks of the configuration. - **The new scan:** the areas of the new scan, messages to you and search (the scan kept, LIKE's wildcards used as text, areas that are not read left out), through internal/app and in the store on all engines; settings kept from call to call (UTF-8 off over SSH, the width of a Commodore) and through the API. - **The HTTP API:** logins, tokens and scopes, all REST endpoints and their refusals, rate limits, the OpenAPI document against the routes, server-sent events and node messages, the two WebSockets (authentication by header and by first message, chat between them, pages and answers, mail events, bad frames, refused origins and tokens) and the metrics. - **Terminal and web callers together:** a terminal caller and a web caller (the JSON WebSocket) that chat in one room in the two directions, `/who`, node messages in each direction, and the web caller who pages the sysop, who answers at the terminal. - **SSH:** login by password, keyboard-interactive and key (and no login by a wrong key, the key of a different user, or into a locked account); `new` at the prompt of the BBS; the terminal type and size of the pty; refused commands, SFTP and forwarding; a user who adds and deletes a key in the profile; host keys made and kept (ed25519, RSA, ECDSA) and refused when they are readable; the configuration; legacy ciphers only when you ask for them; the OpenSSH client that logs in by key with a pty. - **PETSCII:** the translation (letters, colors, reverse, CR and LF, cursor movement, box drawing, accents, runes split across writes, wrapping) and the keys back; a Commodore that logs in with DEL editing, its one-column menus, a .seq screen unchanged, the width in the profile, no escape sent at any time; a Commodore found during the login: by DEL typed in the name, by a shifted letter (and not by UTF-8), by a name in capitals and the DEL question (or not, with a backspace), and no question for a name in lower case. - **RIP:** MegaNums, the commands and their escapes, the menu scene; a RIP terminal found by its answer, given a .rip screen, menus as buttons, the scene cleared on a selection and a pause before the next; an ANSI terminal without RIP that gets none of it. - **Access levels:** requirements read and written back, met and not met (flags, !flags, sysop, locked users), flag edits; the levels found for a user; areas hidden and posts refused by level and by flags, mail only to the sysop, chat and pages refused, the downloads of the day counted and limited, doors, validation; the time of the day at its end (a warning, a hang-up, the count); a new user who waits and that the sysop validates on the BBS; the API (no user can increase their own level, only sysops and the user can see the levels and flags, area requirements); the configuration. - **Terminal identification:** the answers of DEC's terminals and of emulators (VT100 to VT525, old and new xterm, VTE, tmux, SyncTERM, PuTTY, the Linux console, a VT52) read into names, levels, sixel and monochrome; DEC Special Graphics and Latin-1 output, with escapes that go through it; VT52 output; a VT220 given DEC graphics, Latin-1 and bold, shown as a VT220; a VT52 given its escapes, with its cursor keys ignored; a terminal that answers nothing, left plain. - **The web terminal:** the page, its headers and files (and no other files), WebSockets refused from a different origin or without the subprotocol, and a caller who logs in through it, its size used, shown as a web terminal, and logs off. - **The web forum:** guests who read (and cannot read what needs a level); login and logout by the session tokens of the API (and not by an API key); sign-up; topics and replies; forms refused without their token; the HTML of posts escaped and links made into links; long lines wrapped and not cut; quotes, polls, likes, unread topics and areas; aliases that hide the writer; deletion (the writer deletes own posts, the sysop deletes all posts); news-only areas; search and who is online. In the store: topics threaded across areas, read marks, a topic repaired when its first post or the parent of its replies goes, and threads found for old messages. All pages in each theme, for a guest and a member; the selection of a theme (the form of a member needs its token, an unknown theme is refused, the selection cannot go to a page off the forum); and the theme of the forum until a caller selects one. **Updating xterm.js:** do these steps: 1. Run `npm pack @xterm/xterm @xterm/addon-fit @xterm/addon-image`. 2. Copy `lib/xterm.js`, `css/xterm.css`, `lib/addon-fit.js`, `lib/addon-image.js` and the license into `internal/api/web`. Remove their source map lines. 3. Make sure that the version of the image addon is the version for that xterm.js (0.8 for 5.5). **Refer to:** [Building](Building)