2.4 KiB
2.4 KiB
Milestone 5: Management & Plugins (The Power)
Goal: Add persistent storage, an admin web dashboard, and the Wasm sandbox.
1. Database Setup (server_node/database.rs)
- Dependencies: Add
sqlxwith thesqliteandruntime-tokiofeatures. - AI Context Trap (SQLite Locking): SQLite will throw
database is lockederrors under heavy async load. Ensure thesqlx::sqlite::SqliteConnectOptionsexplicitly setsPRAGMA journal_mode=WALto allow concurrent UDP/TCP access. - Schema Migrations: Create
users(ID, Name, Hash, Role) andchannels(ID, Name, ParentID, RequiredRole, Bitrate). Run migrations on startup viasqlx::migrate!(). - Permissions Check: During the TCP
ChannelJoinevent, query the DB to ensure the user's Role\getheRequiredRoleof the channel.
2. Web Admin Dashboard (server_node/admin_api)
- Dependencies: Add
axum,rust-embed,jsonwebtoken,prometheus. - Static Assets: Build the HTML/CSS for the classic control panel UI. Use
rust-embedto compile these assets directly into the server binary. - API Endpoints: Build POST routes for
/api/kick,/api/ban,/api/channel/create, and/api/channel/bitrate. - Telemetry: Expose a
/metricsPrometheus endpoint to track high-level health (concurrent users, UDP packet drops, CPU usage). - Security: Implement an Axum middleware that verifies a Bearer JWT before allowing access to the API routes.
3. Server Bookmarks (Client-Side Persistence)
- Local Storage: Use
directoriescrate to find the OS config path (~/.config/voiceappor%APPDATA%). - Serialization: Serialize a
Vec<ServerBookmark>to abookmarks.tomlor.jsonfile usingserde. - UI Integration: Render the saved bookmarks in the
eguilogin screen so users can 1-click connect.
4. Wasm Sandbox (client_node/plugins.rs)
- Dependencies: Add
extismto the client. - Initialization: Load external
.wasmfiles from a local/pluginsfolder. - Plugin Hooks (Chat): Before rendering a chat message, serialize it to JSON, allocate memory in the Wasm instance, call the Wasm function, and read the modified JSON back.
- Plugin Hooks (Audio): Pass the
&mut [f32]array to the Wasm module before the Opus encoder, allowing plugins to mutate the raw audio (Voice Changers, Soundboards).