Changes in 2.0

What changed from JBend 1.4, and what old code needs

JBend 1.x (2020 to 2022) was assembled in Main with method calls and grew a config language that was never finished or committed. Version 2.0 finishes that idea and rebuilds the parts that could not be trusted on a public server. Class names and the public methods 1.x applications used are kept.

New

Fixed

Area1.x2.0
ReadingOne buffer shared by every connection, decoded whole as a string. Requests split across reads were lost; binary data was mangled.Bytes are collected per connection until a whole message is there.
WritingOne non-blocking write per message. Whatever the socket would not take at once was dropped, so large files arrived truncated.Per-connection send queue, drained as the socket allows.
ConnectionsLooked up by remote port, so two clients behind different addresses with the same port were confused.Each socket carries its own connection object.
Static filesGET /../../etc/passwd was served. Most types were sent with the wrong content type.Paths are resolved and confined; a full content-type table.
HTTPNo keep-alive, no Content-Length, no HEAD.HTTP/1.1 with all three.
WebSocketSingle unfragmented frames up to 64 KB; no ping, no close handshake, no origin check.The full framing rules of RFC 6455.
PasswordsEncrypted with a key written in the source, so anyone with the code could decrypt every password.Salted PBKDF2 hashes.
IdentityA usr cookie containing the username. Anyone could set it and be anyone.Random session tokens, stored hashed.
AdminA web form that ran console commands for whoever sent the right cookie.Removed. The console is the terminal.
SQLStatements built by joining strings, including text from requests.Prepared statements with parameters.
DatabaseA queue shared between threads without synchronisation; a lost connection meant a restart; the caretaker called System.exit when a check failed.A thread-safe queue, automatic reconnect, and a caretaker that only reports.
CPUThe console, login handler, data manager and application loop spun without sleeping, each holding a core at 100%.Every thread blocks or sleeps when it has nothing to do.
RepositoryThe MySQL driver's full source tree, a built jar, object files and editor files were committed.The driver jar and its licence only.

Running a 1.x application on 2.0

Applications that compiled against 1.4 need these changes:

1.x2.0
Your own com.Main building a LauncherDelete it and describe the application in config/application.conf; or keep it, using new Launcher() and the add... methods, which still exist.
new Server(new WebSocket(port) { ... }) inlineA named subclass, referenced by handler. processCustomMessage is unchanged.
users, bans, settings tablesjbend_users, jbend_sessions, jbend_bans. Old tables are left alone and no longer read. Accounts must be registered again.
Checking the usr cookiereq.user() or c.getUser().
Form posts with packet=0/1/3 for register, login, logoutPOST /api/register, /api/login, /api/logout.
env.cfg and routes.cfg next to srcconfig/application.conf; routes inline or in a file named by routes.
ServerQuery with SQL built from stringsStill runs. Move values to ? parameters.
getResponse() text parsingStill works. value("column") is simpler.
processGET / processPOST overridesStill called. New code should override handle.
Main.launcher.cryptography()Still there. The hand-written ciphers in com.util.crypt were a learning exercise and are not used by JBend for anything; do not protect real data with them.