diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | client-web/source/protocol/crypto.ts | 2 | ||||
-rw-r--r-- | client-web/source/protocol/mod.ts | 4 | ||||
-rw-r--r-- | common/packets.d.ts | 2 | ||||
-rw-r--r-- | config/config.example.toml (renamed from config/client.example.toml) | 0 | ||||
-rw-r--r-- | server/Cargo.toml | 2 | ||||
-rw-r--r-- | server/src/config.rs | 17 | ||||
-rw-r--r-- | server/src/main.rs | 24 | ||||
-rw-r--r-- | server/src/protocol.rs | 2 | ||||
-rw-r--r-- | server/src/room.rs | 1 |
11 files changed, 35 insertions, 23 deletions
@@ -1,3 +1,3 @@ /target -/config/client.toml +/config/config.toml @@ -2434,7 +2434,7 @@ dependencies = [ [[package]] name = "keks-meet-server" -version = "0.1.0" +version = "0.1.1" dependencies = [ "env_logger", "futures-util", diff --git a/client-web/source/protocol/crypto.ts b/client-web/source/protocol/crypto.ts index c5de90f..6bd5407 100644 --- a/client-web/source/protocol/crypto.ts +++ b/client-web/source/protocol/crypto.ts @@ -31,7 +31,7 @@ export async function crypto_seeded_key(seed: string): Promise<CryptoKey> { return key } -export async function crypt_hash(input: string): Promise<string> { +export async function crypto_hash(input: string): Promise<string> { const buf = new TextEncoder().encode("also-a-very-good-salt" + input) const h = await window.crypto.subtle.digest({ name: "SHA-512" }, buf) const hex = buf_to_hex(new Uint8Array(h)) diff --git a/client-web/source/protocol/mod.ts b/client-web/source/protocol/mod.ts index 71c2b93..a7e1f63 100644 --- a/client-web/source/protocol/mod.ts +++ b/client-web/source/protocol/mod.ts @@ -5,7 +5,7 @@ */ import { ClientboundPacket, RelayMessage, RelayMessageWrapper, ServerboundPacket } from "../../../common/packets.d.ts" import { log } from "../logger.ts" -import { crypto_encrypt, crypto_seeded_key, crypt_decrypt, crypt_hash } from "./crypto.ts" +import { crypto_encrypt, crypto_seeded_key, crypt_decrypt, crypto_hash } from "./crypto.ts" export class SignalingConnection { room!: string @@ -20,7 +20,7 @@ export class SignalingConnection { constructor() { } async connect(room: string): Promise<SignalingConnection> { this.key = await crypto_seeded_key(room) - this.signaling_id = await crypt_hash(room) + this.signaling_id = await crypto_hash(room) log("ws", "connecting…") const ws_url = new URL(`${window.location.protocol.endsWith("s:") ? "wss" : "ws"}://${window.location.host}/signaling/${encodeURIComponent(this.signaling_id)}`) this.websocket = new WebSocket(ws_url) diff --git a/common/packets.d.ts b/common/packets.d.ts index 75e7c8e..8bec80a 100644 --- a/common/packets.d.ts +++ b/common/packets.d.ts @@ -18,11 +18,13 @@ export interface ClientboundPacket { client_join?: { id: number } // join: more like "appear" - also sent when you join for others that were there before you. client_leave?: { id: number } message?: { sender: number, message: string /* encrypted RelayMessageWrapper */ } + room_info?: { hash: string, user_count: number } } export interface ServerboundPacket { ping?: null relay?: { recipient?: number, message: string /* encrypted RelayMessageWrapper */ } + watch_rooms?: string[] } export interface RelayMessageWrapper { diff --git a/config/client.example.toml b/config/config.example.toml index 39e942a..39e942a 100644 --- a/config/client.example.toml +++ b/config/config.example.toml diff --git a/server/Cargo.toml b/server/Cargo.toml index 3252cd7..498f85d 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "keks-meet-server" -version = "0.1.0" +version = "0.1.1" edition = "2021" [dependencies] diff --git a/server/src/config.rs b/server/src/config.rs index 870315e..0ae90eb 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -1,13 +1,20 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ClientConfig { - pub webrtc: ClientWebrtcConfig, - pub appearance: ClientAppearanceConfig, +pub struct Config { + pub features: FeaturesConfig, + pub webrtc: WebrtcConfig, + pub appearance: AppearanceConfig, } +#[rustfmt::skip] #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ClientWebrtcConfig { +pub struct FeaturesConfig { + #[serde(default)] pub watch_rooms: bool, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct WebrtcConfig { pub stun: String, pub turn: Option<String>, pub turn_user: Option<String>, @@ -15,7 +22,7 @@ pub struct ClientWebrtcConfig { } #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ClientAppearanceConfig { +pub struct AppearanceConfig { pub accent: String, pub accent_light: String, pub accent_dark: String, diff --git a/server/src/main.rs b/server/src/main.rs index e637805..3d0af50 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -10,7 +10,7 @@ pub mod protocol; pub mod room; use assets::css; -use config::{ClientAppearanceConfig, ClientConfig}; +use config::{AppearanceConfig, Config}; use hyper::{header, StatusCode}; use listenfd::ListenFd; use log::{debug, error}; @@ -38,10 +38,10 @@ fn main() { async fn run() { env_logger::init_from_env("LOG"); - let client_config: ClientConfig = toml::from_str(include_str!("../../config/client.toml")) + let config: Config = toml::from_str(include_str!("../../config/config.toml")) .expect("client configuration invalid"); - let client_config_json = serde_json::to_string(&client_config).unwrap(); - let client_config_css = css_overrides(&client_config.appearance); + let client_config_json = serde_json::to_string(&config).unwrap(); + let client_config_css = css_overrides(&config.appearance); let rooms: _ = Rooms::default(); let rooms: _ = warp::any().map(move || rooms.clone()); @@ -154,22 +154,22 @@ fn signaling_connect(rsecret: String, rooms: Rooms, ws: warp::ws::Ws) -> impl Re } fn css_overrides( - ClientAppearanceConfig { + AppearanceConfig { accent, accent_light, accent_dark, background, background_dark, - }: &ClientAppearanceConfig, + }: &AppearanceConfig, ) -> String { format!( r#":root {{ - --bg: {background}; - --bg-dark: {background_dark}; - --ac: {accent}; - --ac-dark: {accent_dark}; - --ac-dark-transparent: {accent_dark}c9; - --ac-light: {accent_light}; +--bg: {background}; +--bg-dark: {background_dark}; +--ac: {accent}; +--ac-dark: {accent_dark}; +--ac-dark-transparent: {accent_dark}c9; +--ac-light: {accent_light}; }} "# ) diff --git a/server/src/protocol.rs b/server/src/protocol.rs index cc40cb6..a27e339 100644 --- a/server/src/protocol.rs +++ b/server/src/protocol.rs @@ -12,6 +12,7 @@ pub enum ClientboundPacket { ClientJoin { id: usize }, ClientLeave { id: usize }, Message { sender: usize, message: String }, + RoomInfo { hash: String, user_count: usize }, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -22,4 +23,5 @@ pub enum ServerboundPacket { recipient: Option<usize>, message: String, }, + WatchRooms(Vec<String>), } diff --git a/server/src/room.rs b/server/src/room.rs index bfc391b..abc1a52 100644 --- a/server/src/room.rs +++ b/server/src/room.rs @@ -117,6 +117,7 @@ impl Room { self.broadcast(Some(sender), packet).await } } + ServerboundPacket::WatchRooms(list) => {} } } |