aboutsummaryrefslogtreecommitdiff
path: root/hotline/client.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2026-07-10 09:48:18 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2026-07-10 09:48:18 -0700
commit21f24d24fd6f501b32f15a2bef41c89cc461f623 (patch)
treeba4952fb82f3ef9c265228633f27536866e23931 /hotline/client.go
parentae44fb222ec73cae8441f5a5d9a21f8585fe587f (diff)
Overhaul regression testing: e2e suite, fuzzing, CI, and bug fixes
Add a protocol-level end-to-end suite (in-process fully wired server on an ephemeral port pair, driven by hotline.Client over TCP) covering handshake, login, public and private chat, message board, threaded news, file list/download/upload, account admin, disconnect notification, and shutdown broadcast. The harness retries on a fresh port pair when another process steals a probed port before ListenAndServe binds it, and Server gains WithConnectionRateLimit so tests can disable the per-IP connection throttle. Add native fuzz tests for Transaction, Field, and flattened file object decoding, and fix the bugs the new tests surfaced: - Transaction.Write panicked on out-of-range attacker-controlled size fields, and transactionScanner's uint32 length addition could wrap and yield a truncated token. The information fork size declared in an untrusted fork header is now bounded too. - Client keepalive read c.done unsynchronized while Disconnect replaces it under the mutex. - The shared Agreement's Seek+ReadAll login path raced concurrent logins; the server now prefers an AgreementBytes() snapshot. Fill unit-test gaps (main's config-copy helpers, file resume data, ReloaderFunc, R2 error injection and env validation) and add a CI test workflow (build/vet + race-enabled shuffled suite), fixed lint workflow triggers with golangci-lint v2.6, and Makefile test/cover/ lint/fuzz targets.
Diffstat (limited to 'hotline/client.go')
-rw-r--r--hotline/client.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/hotline/client.go b/hotline/client.go
index 23bfe9c..b09a01d 100644
--- a/hotline/client.go
+++ b/hotline/client.go
@@ -84,15 +84,19 @@ func (c *Client) Connect(address, login, passwd string) (err error) {
return fmt.Errorf("error sending login transaction: %w", err)
}
- // start keepalive go routine
- go func() { _ = c.keepalive() }()
+ // start keepalive go routine. Capture the done channel now so keepalive never races with
+ // Disconnect, which replaces c.done under the mutex.
+ c.mu.Lock()
+ done := c.done
+ c.mu.Unlock()
+ go func() { _ = c.keepalive(done) }()
return nil
}
const keepaliveInterval = 300 * time.Second
-func (c *Client) keepalive() error {
+func (c *Client) keepalive(done <-chan struct{}) error {
ticker := time.NewTicker(keepaliveInterval)
defer ticker.Stop()
@@ -100,7 +104,7 @@ func (c *Client) keepalive() error {
select {
case <-ticker.C:
_ = c.Send(NewTransaction(TranKeepAlive, [2]byte{}))
- case <-c.done:
+ case <-done:
return nil
}
}