aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* {main,ws,wsm}.go: Attempt to cancel old sessionsRunxi Yu2024-10-033-23/+87
| | | | | | | | | | | | | | | | | | | When beginning to handle a WebSocket connection, we shall create a new context, with the request context as its parent. We use the new context for everything from now on, except for reporting error messages, which is handled by creating a reportError function in a closure in makeReportError and passing it along to command-handling functions. Note that if one user attempts to rapidly launch WebSocket connections, there might still be a race condition where the old connection hasn't been completely established yet (i.e. an entry hasn't been added to cancelPool) and the new connection isn't able to cancel the old connection. I'm a bit tired to think of a solution now but it could probably be solved by moving the cancellation registration and cancelling sooner during the initial handshake. Note that more parts of the event loop needs to select from ctx.Done (from newCtx) for this to work reliably.
* README.md, student.html: Correct spellingRunxi Yu2024-10-032-2/+2
|
* README.md: Remove CI badgesRunxi Yu2024-10-031-6/+0
|
* ws.go: Update comment on disallowed charactersRunxi Yu2024-10-021-5/+4
|
* student.html: Update error messages to be a bit more friendlyRunxi Yu2024-10-021-6/+15
|
* index.go, *.html: index->student, index_login->loginRunxi Yu2024-10-023-5/+5
| | | | | | | The new names are a bit more descriptive in what each do, and I intend to add an "admin" template in the future. This has no user-facing effects.
* index{,_login}.html: Improve accessibilityRunxi Yu2024-10-022-2/+4
|
* main.js: Un-disable already-chosen courses during HELLO/HIRunxi Yu2024-10-021-0/+1
|
* index.html, style.css: Remove ID column because nobody caresRunxi Yu2024-10-022-5/+3
|
* main.js: Unset indeterminate when receiving NRunxi Yu2024-10-021-0/+1
|
* main.js: Set checkbox.indeterminate = true when uncheckingRunxi Yu2024-10-021-1/+1
|
* tcourse.sql: Add 1000 of each course for testingRunxi Yu2024-10-021-5/+5
|
* bench: Don't log errors for nowRunxi Yu2024-10-021-3/+3
|
* wsm.go, main.js: Use M for number, N for deselectRunxi Yu2024-10-022-3/+6
| | | | | | | Previously both commands used N, and deselection wasn't really implemented on the JavaScript side. It worked and didn't throw an exception but it's technically wrong and the user could see an empty number field for a split second.
* Makefile: Add wsm.go to the source file listRunxi Yu2024-10-021-1/+1
|
* bench: Attempt to choose random coursesRunxi Yu2024-10-021-4/+18
|
* bench: Add initial benchmarking suiteRunxi Yu2024-10-025-0/+106
| | | | Currently only connects and creates a fake user
* {auth,utils,ws}.go: randomBytes -> randomStringRunxi Yu2024-10-023-4/+4
|
* {config,ws}.go, cca.scfg.example: Add fake auth supportRunxi Yu2024-10-025-16/+72
| | | | | Fake authentication is useful when benchmarking the server with an external program without going insane with the OpenID Connect forms.
* style.css: message-box border 1pxRunxi Yu2024-10-021-1/+1
|
* {auth,db,wsm}.go: Make 23505 (uniqueness violation) a constantRunxi Yu2024-10-013-2/+4
|
* main.js: Only try to mark courses as checked if mar[1] !== ""v0.1.1Runxi Yu2024-10-011-3/+5
| | | | | Otherwise, users may get something like "TypeError: Cannot set properties of null (setting 'checked')"
* main.js: Everything should be after DOMContentLoadedRunxi Yu2024-10-011-99/+101
| | | | | | | This is technically a race condition, and users with extremely slow computers and very bad luck might get exceptions from this. I think.
* style.css: Make light header background lighterRunxi Yu2024-10-011-1/+1
|
* style.css: Remove thick table borderRunxi Yu2024-10-011-1/+1
|
* wsm.go, main.js: Display the user's selected courses on first runv0.1.0Runxi Yu2024-10-012-2/+22
| | | | | It's done in the WebSocket routines rather than in the template maker because it's relatively easier to write the logic this way.
* style.css: Switch the header to a grey themeRunxi Yu2024-10-011-4/+8
|
* style.css: Revert back to blue themeRunxi Yu2024-10-011-3/+5
|
* {ws,wsm}.go: Split message handlers into their own functionsRunxi Yu2024-10-012-124/+182
|
* lint.sh: Disable dogsled and unparamRunxi Yu2024-10-011-1/+1
| | | | | | | dogsled forbids patterns such as "_, _, _ = a, b, c" for no reason. unparam warns about unused parameters even when I'm assigning them to _ to indicate that it's fine for them to be unused.
* {auth,ws}.go: Remove unnecessary TODOsRunxi Yu2024-10-012-19/+2
|
* ws.go: Allow deselecting coursesRunxi Yu2024-10-011-0/+34
|
* lint.sh: Disable yet another cyclomatic complexity checkerRunxi Yu2024-10-011-1/+1
|
* ws.go: Fix logic error when reaffirming a course choiceRunxi Yu2024-10-011-2/+2
| | | | | | | | | | | | | | When a user has already chosen a course choice but sends a message to choose it again, a database error occurs as the uniqueness constraint is violated. In this case, we "reaffirm" the user's course choice, to hopefully get their client's state back in sync. However, we previously forgot to return back to the event loop after this reaffirmation, causing the control flow to fall into the course-increment and transaction-commit stage. The error is discovered at tx.Commit, where pgx raises a ErrTxCommitRollback, because in that case we're trying to commit a transaction that has already encountered an error.
* {main,pw}.go, Makefile, index_login.html: Remove password auth stubRunxi Yu2024-10-014-92/+1
| | | | | | | | | | I don't think password authentication is really useful, since Microsoft Entra ID is the "proper" way of doing authentication in our school system and there's just little reason to have a password login. I previously wanted to use password authentication for stress testing, but stress testing really could just use completely fake authentication and there's no need for any password whatsoever.
* ws.go: protocolError instead of R on unexpected database errorsRunxi Yu2024-10-011-23/+7
| | | | | | | When an unknown database error is encoutered, the connection should be considered broken and the error should be reported as a fatal error to the end user. Rejecting the course choice unsets the checkbox and lets the page to be continued to be used, which is not intended.
* index.go, ws.go: Fix race condition surrounding coursesRunxi Yu2024-10-012-13/+21
| | | | | | handleIndex and handleConn used to access the courses map without RLock'ing coursesLock, which may cause issues if courses is being written to, by a function such as setupCourses.
* courses.go: Propagate course.Selected when setting up coursesRunxi Yu2024-10-011-2/+7
|
* ws.go: Decrement course.Selected counter on commit failuresRunxi Yu2024-10-011-0/+6
|
* ws.go: Reaffirm course choice when duplicate is requestedRunxi Yu2024-10-011-5/+13
| | | | | | | | Laggy clients, extremely fast clicks, or other conditions could cause duplicate course choices to be sent, which would violate the uniqueness constraint. In this case the fact that the user has already chosen the course should be reaffirmed, rather than making it look like their choice was rejected.
* ws.go: propagateCouldFail -> propagateIgnoreFailuresRunxi Yu2024-10-011-2/+2
| | | | | | I think the new name better reflects the fact that it just ignores failures when propagating to each channel. The old name sounds like "this function itself could fail".
* ws.go, schema.sql: Enforce uniqueness of course choicesRunxi Yu2024-10-012-43/+65
| | | | References: https://todo.sr.ht/~runxiyu/cca/1
* lint.sh: Disable yet another cyclomatic complexity checkerRunxi Yu2024-10-011-1/+1
|
* ws.go, *.sql: Add course choices to the databaseRunxi Yu2024-10-013-7/+47
| | | | | | | | | | | | | | | | | | | | Note that this naive implementation currently allows users to submit multiple requests for the same course. See the TODO comment below: /* * TODO: Ensure that the user is not already enrolled in this course * and pay attention to relevant race conditions. It might be useful * to restructure this part, to begin a transaction that adds the user * to the database (and check the (currently not existing) uniqueness) * constraint at that exact moment, and abort the transaction if the * course limit is exceeded. * Or perhaps choices should be also stored in an internal data * structure, though that requires extra attention on consistency * issues between the internal data structure and the database. * (Sometime I should really go fix the LMDB bindings...) */ References: https://todo.sr.ht/~runxiyu/cca/1
* postgres_run.sh: Run in debug level 2Runxi Yu2024-10-011-1/+1
| | | | | This allows SQL statements to be logged which makes debugging much easier. Also "$@" is added so any extra arguments may be passed.
* ws.go: propagate -> propagateCouldFailRunxi Yu2024-10-011-3/+8
|
* ws.go: propagate course number updates in another goroutineRunxi Yu2024-10-011-1/+1
|
* auth.go: Add TODO about INSERTRunxi Yu2024-10-011-0/+7
|
* admin_handbook: List configuration caveatsRunxi Yu2024-09-301-3/+7
|
* iadocs: cover_page.{html->htm}Runxi Yu2024-09-302-353/+352
| | | | Cgit was kinda broken in serving HTML, it was a caching issue