|
3 | 3 | All notable changes to RustChan will be documented in this file. |
4 | 4 |
|
5 | 5 | --- |
6 | | -## [1.1.0] |
| 6 | + |
| 7 | +## [1.1.0 alpha 2] |
| 8 | + |
| 9 | +### Fixed |
| 10 | + |
| 11 | +#### 🔴 Critical — HTTP 500 errors on pages with gateway posts |
| 12 | +**Problem:** Posts from the ChanNet gateway have no IP address, causing crashes when pages try to display them. |
| 13 | + |
| 14 | +**Solution:** Changed `ip_hash` from `String` to `Option<String>` throughout the codebase so `NULL` values are handled gracefully instead of panicking. |
| 15 | + |
| 16 | +**Files changed:** |
| 17 | +- `src/models.rs`, `src/db/posts.rs`, `src/db/admin.rs` — Handle optional IP hashes |
| 18 | +- `src/templates/thread.rs`, `src/templates/admin.rs` — Render empty string for missing IPs |
| 19 | +- `src/handlers/admin/backup.rs`, `src/handlers/backup.rs` — Preserve `NULL` on backup/restore |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +#### 🟠 Log files written to wrong directory |
| 24 | +**Problem:** Logs were created in the executable folder instead of `rustchan-data/`. |
| 25 | + |
| 26 | +**Solution:** Pass `data_dir` instead of `binary_dir` to the logger, and create the directory *before* logging initializes. |
| 27 | + |
| 28 | +**Files changed:** `src/main.rs` |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +#### 🟠 Log file names have wrong extension |
| 33 | +**Problem:** Rotated logs named `rustchan.log.2024-01-15` instead of `rustchan.2024-01-15.log`. |
| 34 | + |
| 35 | +**Solution:** Use `RollingFileAppender::builder()` with `.filename_prefix()` and `.filename_suffix()` for correct naming. |
| 36 | + |
| 37 | +**Files changed:** `src/logging.rs` |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +#### 🟡 Log files changed from JSON to readable text |
| 42 | +**Problem:** Logs were dense JSON, hard to read with `tail`, `grep`, etc. |
| 43 | + |
| 44 | + |
| 45 | +## Reliability & Shutdown Improvements |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Multipart Handling & Memory Safety (`src/handlers/mod.rs`) |
| 50 | + |
| 51 | +- Added strict per-field size limits for multipart text inputs: |
| 52 | + - Post body capped (~100KB) |
| 53 | + - Name, subject, and other fields capped (~4KB) |
| 54 | +- Replaced unbounded `field.text()` usage with controlled byte-reading logic |
| 55 | +- Prevented large heap allocations from oversized text fields |
| 56 | +- Eliminated OOM risk under concurrent large-form submissions |
| 57 | + |
| 58 | +- Hardened poll duration parsing: |
| 59 | + - Added validation before multiplication |
| 60 | + - Prevented intermediate integer overflow prior to clamping |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Backup System Reliability (`src/handlers/admin/backup.rs`) |
| 65 | + |
| 66 | +- Replaced fragile `VACUUM INTO` string-based SQL with `rusqlite::backup` API |
| 67 | +- Eliminated dependency on manual SQL escaping and path formatting |
| 68 | +- Improved cross-platform correctness and error transparency |
| 69 | + |
| 70 | +- Implemented guaranteed temporary file cleanup: |
| 71 | + - Introduced RAII-style cleanup mechanism |
| 72 | + - Ensures backup artifacts are removed even on: |
| 73 | + - client disconnects |
| 74 | + - early termination |
| 75 | + - runtime drops |
| 76 | + |
| 77 | +- Improved error signaling: |
| 78 | + - Database pool exhaustion now correctly returns retryable errors (503) instead of 500 |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## Tor — Arti In-Process Migration |
| 83 | + |
| 84 | +Replaced the subprocess-based C Tor launcher with **[Arti](https://gitlab.torproject.org/tpo/core/arti)** running fully in-process. **No system `tor` installation is required.** |
| 85 | + |
| 86 | +**How it works:** at startup a single Tokio task bootstraps Arti, derives a `.onion` address from a persistent Ed25519 keypair, launches the hidden service, and proxies inbound onion connections to the local HTTP port — all without spawning a child process, writing a `torrc`, or polling a `hostname` file. |
| 87 | + |
| 88 | +- Bootstrap takes ~30 s on first run (Arti downloads ~2 MB of directory data) and ~5 s on subsequent runs (consensus cached in `arti_cache/`) |
| 89 | +- The onion address is published to `AppState` the moment the service is ready; handlers read it from memory with zero filesystem I/O per request |
| 90 | +- Service keypair lives in `rustchan-data/arti_state/keys/` — back this directory up to preserve your `.onion` address; delete it to rotate to a new one |
| 91 | +- Old `rustchan-data/tor_data/`, `rustchan-data/tor_hidden_service/`, and `rustchan-data/torrc` are no longer created and can be safely deleted after migration |
| 92 | +- **Note:** the keypair location changed on migration (`tor_hidden_service/` → `arti_state/keys/`), so a new `.onion` address is generated on first run unless the old Ed25519 key is manually imported via Arti's key management tooling |
| 93 | + |
| 94 | +**Files changed:** `Cargo.toml` (+6 deps: `arti-client`, `tor-hsservice`, `tor-cell`, `futures`, `sha3`, `data-encoding`), `src/detect.rs`, `src/middleware/mod.rs`, `src/server/server.rs`, `src/handlers/board.rs`, `src/handlers/admin/mod.rs`, `src/handlers/admin/settings.rs`, `src/config.rs` |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## Database Layer Improvements (`src/db/mod.rs`) |
| 99 | + |
| 100 | +- Made database connection pool size configurable via environment/config |
| 101 | +- Removed hardcoded pool limit to improve scalability under load |
| 102 | + |
| 103 | +- Corrected error mapping: |
| 104 | + - `r2d2::Error` (pool exhaustion) now maps to `503 Service Unavailable` |
| 105 | + - Prevents misclassification of load-related failures as internal errors |
| 106 | + |
| 107 | +- Removed silent fallback in initialization logic: |
| 108 | + - Replaced `unwrap_or(0)` with proper error propagation |
| 109 | + - Prevents incorrect “first-run” detection on DB failure |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Transaction Safety & Concurrency (`src/db/threads.rs`, `src/db/posts.rs`, `src/db/admin.rs`, `src/db/boards.rs`) |
| 114 | + |
| 115 | +- Replaced `unchecked_transaction()` (DEFERRED) with explicit `BEGIN IMMEDIATE` |
| 116 | +- Ensured write locks are acquired at transaction start |
| 117 | +- Eliminated mid-transaction lock upgrade failures (`SQLITE_BUSY`) |
| 118 | +- Improved consistency and reliability under concurrent write load |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## Logging System Stability (`src/logging.rs`) |
| 123 | + |
| 124 | +- Replaced unbounded log file (`rolling::never`) with rotating log strategy |
| 125 | +- Prevented uncontrolled log growth and disk exhaustion |
| 126 | +- Improved long-term operational stability in production environments |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## HTTP Response Correctness (`src/handlers/thread.rs`, `src/handlers/board.rs`) |
| 131 | + |
| 132 | +- Removed `.unwrap_or_default()` from 304 response builders |
| 133 | +- Replaced with explicit, safe response construction |
| 134 | +- Ensured correct HTTP semantics for cache validation responses |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +## Configuration File Safety (`src/config.rs`) |
| 139 | + |
| 140 | +- Replaced non-atomic file writes with atomic write pattern: |
| 141 | + - write to temporary file |
| 142 | + - persist via rename |
| 143 | +- Prevented configuration corruption on crash or partial write |
| 144 | + |
| 145 | +--- |
| 146 | + |
| 147 | +## Cross-Cutting Improvements |
| 148 | + |
| 149 | +### Error Handling |
| 150 | + |
| 151 | +- Reduced silent error suppression patterns |
| 152 | +- Improved propagation and visibility of operational failures |
| 153 | +- Increased observability of system state under failure conditions |
| 154 | + |
| 155 | +--- |
| 156 | + |
| 157 | +### Database Reliability |
| 158 | + |
| 159 | +- Standardized transaction patterns across modules |
| 160 | +- Improved behavior under high contention scenarios |
| 161 | +- Reduced retry loops and transient DB errors |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## Summary |
| 166 | + |
| 167 | +These changes collectively improve: |
| 168 | + |
| 169 | +- Memory safety under user input |
| 170 | +- Database correctness under concurrency |
| 171 | +- Crash resilience and panic handling |
| 172 | +- Backup integrity and filesystem safety |
| 173 | +- Logging reliability and disk usage control |
| 174 | +- Accuracy of error reporting and HTTP responses |
| 175 | + |
| 176 | +Resulting in a significantly more robust and production-ready system. |
| 177 | + |
| 178 | +### Worker Lifecycle Management (`src/server/server.rs`, `src/workers/mod.rs`) |
| 179 | + |
| 180 | +- Persisted `JoinHandle`s returned by the worker pool instead of discarding them |
| 181 | +- Implemented proper graceful shutdown by: |
| 182 | + - Signaling worker cancellation via `CancellationToken` |
| 183 | + - Awaiting all worker tasks with bounded timeouts |
| 184 | +- Eliminated reliance on fixed sleep-based shutdown timing |
| 185 | +- Prevented corruption of in-progress jobs (e.g., FFmpeg transcodes) |
| 186 | +- Enabled deterministic shutdown behavior for background workers |
| 187 | + |
| 188 | +### Job Recovery |
| 189 | + |
| 190 | +- Added startup recovery logic to reset jobs stuck in `running` state |
| 191 | +- Ensures jobs interrupted during shutdown are retried instead of permanently stalled |
| 192 | + |
| 193 | +--- |
| 194 | + |
| 195 | +## ChanNet Server Shutdown (`src/server/server.rs`) |
| 196 | + |
| 197 | +- Added graceful shutdown support to ChanNet server |
| 198 | +- Unified shutdown signal with main HTTP server |
| 199 | +- Prevents abrupt termination of in-flight federation requests |
| 200 | +- Eliminates risk of partial/corrupt response streams during shutdown |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## Background Task Control (`src/server/server.rs`) |
| 205 | + |
| 206 | +- Integrated cancellation awareness into background tasks |
| 207 | +- Replaced infinite loops with `tokio::select!` to listen for shutdown signals |
| 208 | +- Ensures all periodic tasks (cleanup, pruning, etc.) terminate cleanly |
| 209 | +- Reduces risk of abrupt termination mid-operation |
| 210 | + |
| 211 | +--- |
| 212 | + |
| 213 | +## HTTP Reliability (`src/server/server.rs`) |
| 214 | + |
| 215 | +- Added request timeout middleware |
| 216 | +- Protects against slow or stalled clients holding connections indefinitely |
| 217 | +- Improves resilience against slowloris-style behavior |
| 218 | + |
| 219 | +--- |
| 220 | + |
| 221 | +## Worker System Stability (`src/workers/mod.rs`) |
| 222 | + |
| 223 | +- Ensured worker pool properly integrates with shutdown lifecycle |
| 224 | +- Improved coordination between job queue and worker threads |
| 225 | +- Reinforced guarantees around job completion and cancellation handling |
| 226 | + |
| 227 | +--- |
| 228 | + |
| 229 | +## Summary |
| 230 | + |
| 231 | +These changes significantly improve: |
| 232 | + |
| 233 | +- Graceful shutdown correctness |
| 234 | +- Background task reliability |
| 235 | +- Job processing integrity |
| 236 | +- Resistance to partial writes and corruption |
| 237 | +- Operational stability under restart conditions |
| 238 | + |
| 239 | +--- |
| 240 | + |
| 241 | +## [1.1.0 alpha 1] |
7 | 242 |
|
8 | 243 | ## 🌐 New: ChanNet API (Port 7070) |
9 | 244 |
|
|
0 commit comments