Files
TS3-vibed/Documentation/Mile_Stones/Milestone_5.md
2026-05-03 10:50:25 +02:00

2.1 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 sqlx with the sqlite and runtime-tokio features.
  • Schema Migrations: Create users (ID, Name, Hash, Role) and channels (ID, Name, ParentID, RequiredRole, Bitrate). Run migrations on startup via sqlx::migrate!().
  • Permissions Check: During the TCP ChannelJoin event, query the DB to ensure the user's Role \ge the RequiredRole of 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-embed to 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 /metrics Prometheus 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 directories crate to find the OS config path (~/.config/voiceapp or %APPDATA%).
  • Serialization: Serialize a Vec<ServerBookmark> to a bookmarks.toml or .json file using serde.
  • UI Integration: Render the saved bookmarks in the egui login screen so users can 1-click connect.

4. Wasm Sandbox (client_node/plugins.rs)

  • Dependencies: Add extism to the client.
  • Initialization: Load external .wasm files from a local /plugins folder.
  • 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).