From e65e8d1caa4eb8abb9b9344c63930c5c011055b9 Mon Sep 17 00:00:00 2001
From: metamuffin
Date: Thu, 22 Dec 2022 08:45:26 +0100
Subject: add missing license information to some files
---
client-web/source/sw/download_stream.ts | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'client-web/source')
diff --git a/client-web/source/sw/download_stream.ts b/client-web/source/sw/download_stream.ts
index 52d9fad..35a3c7e 100644
--- a/client-web/source/sw/download_stream.ts
+++ b/client-web/source/sw/download_stream.ts
@@ -1,3 +1,9 @@
+/*
+ This file is part of keks-meet (https://codeberg.org/metamuffin/keks-meet)
+ which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
+ Copyright (C) 2022 metamuffin
+*/
+///
import { log } from "../logger.ts"
import { SW } from "./init.ts"
--
cgit v1.2.3-70-g09d2
From f85d40d8c6cc2f3b58d1e0ea7f0382db88fffd4e Mon Sep 17 00:00:00 2001
From: metamuffin
Date: Tue, 17 Jan 2023 22:28:35 +0100
Subject: refer to room name as secret instead
---
client-native-gui/src/main.rs | 4 ++--
client-web/public/start.html | 4 ++--
client-web/source/index.ts | 10 +++++-----
client-web/source/preferences/mod.ts | 10 +++++-----
server/src/main.rs | 14 +++++++-------
5 files changed, 21 insertions(+), 21 deletions(-)
(limited to 'client-web/source')
diff --git a/client-native-gui/src/main.rs b/client-native-gui/src/main.rs
index ab6387d..83de3a0 100644
--- a/client-native-gui/src/main.rs
+++ b/client-native-gui/src/main.rs
@@ -43,7 +43,7 @@ use tokio::task::JoinHandle;
/// A graphical interface to keks-meet conferences
struct Args {
#[arg(short = 'R', long, default_value = "")]
- default_room_name: String,
+ default_room_secret: String,
#[arg(short = 'U', long, default_value = "alice")]
default_username: String,
}
@@ -113,7 +113,7 @@ enum GuiResourceState {
impl App {
pub fn new(args: Args) -> Self {
- Self::Prejoin(args.default_room_name, args.default_username)
+ Self::Prejoin(args.default_room_secret, args.default_username)
}
}
diff --git a/client-web/public/start.html b/client-web/public/start.html
index aa60f35..afe771e 100644
--- a/client-web/public/start.html
+++ b/client-web/public/start.html
@@ -16,7 +16,7 @@
To get started, click 'Join' and share the URL with your
- partner. You can also optionally customize the url by entering a
+ partner. You can also optionally customize the URL by entering a
secure/unguessable(!!!) identifier below.
@@ -28,7 +28,7 @@
const room_input = document.createElement("input");
room_input.type = "text";
room_input.id = "room-id-input";
- room_input.placeholder = "Room ID";
+ room_input.placeholder = "Room Secret";
const submit = document.createElement("input");
submit.type = "button";
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index d2bd276..bc52f8b 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -52,17 +52,17 @@ let r: Room;
export async function main() {
log("*", "starting up")
document.body.querySelectorAll("p").forEach(e => e.remove())
- const room_name = load_params().rname
+ const room_secret = load_params().rsecret
if (!globalThis.RTCPeerConnection) return log({ scope: "webrtc", error: true }, "WebRTC not supported.")
if (!globalThis.isSecureContext) log({ scope: "*", warn: true }, "This page is not in a 'Secure Context'")
if (!globalThis.crypto.subtle) return log({ scope: "crypto", error: true }, "SubtleCrypto not availible")
if (!globalThis.navigator.serviceWorker) log({ scope: "*", warn: true }, "Your browser does not support the Service Worker API, some features dont work without it.")
- if (room_name.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
- if (room_name.length == 0) return window.location.href = "/" // send them back to the start page
- if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room name now - e2ee is insecure!")
+ if (room_secret.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
+ if (room_secret.length == 0) return window.location.href = "/" // send them back to the start page
+ if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room secret now - e2ee is insecure!")
- const conn = await (new SignalingConnection().connect(room_name))
+ const conn = await (new SignalingConnection().connect(room_secret))
r = new Room(conn)
setup_keybinds(r)
diff --git a/client-web/source/preferences/mod.ts b/client-web/source/preferences/mod.ts
index 5de73eb..04fae2c 100644
--- a/client-web/source/preferences/mod.ts
+++ b/client-web/source/preferences/mod.ts
@@ -85,19 +85,19 @@ export function generate_section(): string {
PREFS_EXPLICIT[key as unknown as keyof typeof PREFS_EXPLICIT]
)))
}
- return load_params().rname + "?" + section.join("&")
+ return load_params().rsecret + "?" + section.join("&")
}
-export function load_params(): { raw_params: { [key: string]: string }, rname: string } {
+export function load_params(): { raw_params: { [key: string]: string }, rsecret: string } {
const raw_params: Record = {}
- const [rname, param_str] = window.location.hash.substring(1).split("?")
- if (!param_str) return { rname, raw_params: {} }
+ const [rsecret, param_str] = window.location.hash.substring(1).split("?")
+ if (!param_str) return { rsecret, raw_params: {} }
for (const kv of param_str.split("&")) {
const [key, value] = kv.split("=")
if (key == "prototype") continue
raw_params[decodeURIComponent(key)] = decodeURIComponent(value)
}
- return { raw_params, rname }
+ return { raw_params, rsecret }
}
function get_param(ty: string, key: string): T | undefined {
diff --git a/server/src/main.rs b/server/src/main.rs
index d958d66..85f1854 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -44,11 +44,11 @@ async fn run() {
let assets: _ = warp::path("assets").and(warp::fs::dir("../client-web/public/assets"));
let sw_script: _ = warp::path("sw.js").and(warp::fs::file("../client-web/public/assets/sw.js"));
let favicon: _ = warp::path!("favicon.ico").map(|| "");
- let old_format_redirect: _ = warp::path!("room" / String).map(|rname| {
+ let old_format_redirect: _ = warp::path!("room" / String).map(|rsecret| {
reply::with_header(
StatusCode::MOVED_PERMANENTLY,
header::LOCATION,
- format!("/room#{rname}?warn_redirect=true"),
+ format!("/room#{rsecret}?warn_redirect=true"),
)
.into_response()
});
@@ -106,20 +106,20 @@ async fn handle_rejection(err: Rejection) -> Result {
Ok(warp::reply::with_status(json, code))
}
-fn signaling_connect(rname: String, rooms: Rooms, ws: warp::ws::Ws) -> impl Reply {
- async fn inner(sock: WebSocket, rname: String, rooms: Rooms) {
+fn signaling_connect(rsecret: String, rooms: Rooms, ws: warp::ws::Ws) -> impl Reply {
+ async fn inner(sock: WebSocket, rsecret: String, rooms: Rooms) {
debug!("ws upgrade");
let mut guard = rooms.write().await;
let room = guard
- .entry(rname.clone())
+ .entry(rsecret.clone())
.or_insert_with(|| Default::default())
.to_owned();
drop(guard);
room.client_connect(sock).await;
if room.should_remove().await {
- rooms.write().await.remove(&rname);
+ rooms.write().await.remove(&rsecret);
}
}
- ws.on_upgrade(move |sock| inner(sock, rname, rooms))
+ ws.on_upgrade(move |sock| inner(sock, rsecret, rooms))
}
--
cgit v1.2.3-70-g09d2
From 01b9d4a647d515672f9e4260e1cc70fe1cda910f Mon Sep 17 00:00:00 2001
From: tpart
Date: Sat, 21 Jan 2023 11:52:46 +0100
Subject: Fix logger container
---
client-web/source/index.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'client-web/source')
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index cc3492f..4772f94 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -50,6 +50,7 @@ window.onbeforeunload = ev => {
let r: Room;
export async function main() {
+ document.body.append(LOGGER_CONTAINER)
log("*", "starting up")
document.body.querySelectorAll("p").forEach(e => e.remove())
const room_secret = load_params().rsecret
@@ -70,7 +71,7 @@ export async function main() {
new BottomMenu(r).shown = true
new MenuBr().shown = true
}
- document.body.append(ROOM_CONTAINER, OVERLAYS, LOGGER_CONTAINER)
+ document.body.prepend(ROOM_CONTAINER, OVERLAYS)
if (globalThis.navigator.serviceWorker) init_serviceworker()
}
--
cgit v1.2.3-70-g09d2
From 630cd2b82887da49cacb2deb032c6a51b3c2faf7 Mon Sep 17 00:00:00 2001
From: metamuffin
Date: Tue, 21 Feb 2023 15:12:38 +0100
Subject: server-side client configuration
---
.gitignore | 2 ++
Cargo.lock | 48 +++++++++++++++++++++++++++++++++--
client-web/source/index.ts | 38 +++++++++++++++++----------
client-web/source/preferences/decl.ts | 6 +++++
client-web/source/preferences/mod.ts | 1 +
client-web/source/room.ts | 2 +-
client-web/source/user/remote.ts | 4 +--
server/Cargo.toml | 3 ++-
server/src/assets.rs | 4 +--
server/src/config.rs | 20 +++++++++++++++
server/src/main.rs | 14 ++++++++++
11 files changed, 120 insertions(+), 22 deletions(-)
create mode 100644 server/src/config.rs
(limited to 'client-web/source')
diff --git a/.gitignore b/.gitignore
index ea8c4bf..a37f649 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
/target
+/config/client.toml
+
diff --git a/Cargo.lock b/Cargo.lock
index 036d078..5f13e86 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2275,6 +2275,7 @@ dependencies = [
"serde",
"serde_json",
"tokio",
+ "toml",
"warp",
]
@@ -2964,7 +2965,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34"
dependencies = [
"once_cell",
- "toml_edit",
+ "toml_edit 0.18.1",
]
[[package]]
@@ -3421,6 +3422,15 @@ dependencies = [
"syn",
]
+[[package]]
+name = "serde_spanned"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -3887,12 +3897,33 @@ dependencies = [
"tracing",
]
+[[package]]
+name = "toml"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6"
+dependencies = [
+ "serde",
+ "serde_spanned",
+ "toml_datetime 0.6.1",
+ "toml_edit 0.19.3",
+]
+
[[package]]
name = "toml_datetime"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
+[[package]]
+name = "toml_datetime"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "toml_edit"
version = "0.18.1"
@@ -3901,7 +3932,20 @@ checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b"
dependencies = [
"indexmap",
"nom8",
- "toml_datetime",
+ "toml_datetime 0.5.1",
+]
+
+[[package]]
+name = "toml_edit"
+version = "0.19.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e6a7712b49e1775fb9a7b998de6635b299237f48b404dde71704f2e0e7f37e5"
+dependencies = [
+ "indexmap",
+ "nom8",
+ "serde",
+ "serde_spanned",
+ "toml_datetime 0.6.1",
]
[[package]]
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 4772f94..4590625 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -17,18 +17,14 @@ import { Room } from "./room.ts"
export const VERSION = "0.1.12"
export const ROOM_CONTAINER = esection({ class: "room", aria_label: "user list" })
-export const RTC_CONFIG: RTCConfiguration = {
- iceServers: [
- {
- urls: [
- "turn:meet.metamuffin.org:16900",
- "stun:meet.metamuffin.org:16900"
- ],
- username: "keksmeet",
- credential: "ujCmetg6bm0"
- },
- ],
- iceCandidatePoolSize: 10,
+export interface ClientConfig {
+ appearance: { accent: string }
+ webrtc: {
+ stun: string,
+ turn?: string,
+ turn_user?: string,
+ turn_cred?: string
+ }
}
export interface User {
@@ -51,7 +47,12 @@ window.onbeforeunload = ev => {
let r: Room;
export async function main() {
document.body.append(LOGGER_CONTAINER)
- log("*", "starting up")
+ log("*", "loading client config")
+ const config_res = await fetch("/config.json")
+ if (!config_res.ok) return log({ scope: "*", error: true }, "cannot load config")
+ const config: ClientConfig = await config_res.json()
+ log("*", "config loaded. starting")
+
document.body.querySelectorAll("p").forEach(e => e.remove())
const room_secret = load_params().rsecret
@@ -64,7 +65,16 @@ export async function main() {
if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room secret now - e2ee is insecure!")
const conn = await (new SignalingConnection().connect(room_secret))
- r = new Room(conn)
+ const rtc_config: RTCConfiguration = {
+ iceCandidatePoolSize: 10,
+ iceServers: [{
+ urls: [config.webrtc.stun, ...(config.webrtc.turn ? [config.webrtc.turn] : [])],
+ credential: config.webrtc.turn_cred,
+ username: config.webrtc.turn_user,
+ }]
+ }
+
+ r = new Room(conn, rtc_config)
setup_keybinds(r)
r.on_ready = () => {
diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts
index f3f8e84..68cb9ee 100644
--- a/client-web/source/preferences/decl.ts
+++ b/client-web/source/preferences/decl.ts
@@ -18,7 +18,13 @@ export const PREF_DECLS = {
username: { type: string, default: "guest-" + hex_id(), description: "Username", allow_url: true },
warn_redirect: { type: bool, hidden: true, default: false, description: "Internal option that is set by a server redirect.", allow_url: true },
image_view_popup: { type: bool, default: true, description: "Open image in popup instead of new tab" },
+
+ // TODO!
+ /* WEBRTC */
webrtc_debug: { type: bool, default: false, description: "Show additional information for WebRTC related stuff" },
+ webrtc_stun: { type: string, default: "stun:meet.metamuffin.org:16900", description: "Custom STUN server (all participants must use the same server)" },
+ webrtc_turn: { type: optional(string), default: "turn:meet.metamuffin.org:16900", description: "Custom TURN server (all participants must use the same server)" },
+ webrtc_turn_cred: { type: optional(string), description: "TURN server credentials" },
/* MEDIA */
microphone_enabled: { type: bool, default: false, description: "Add one microphone track on startup" },
diff --git a/client-web/source/preferences/mod.ts b/client-web/source/preferences/mod.ts
index 04fae2c..8aefb0f 100644
--- a/client-web/source/preferences/mod.ts
+++ b/client-web/source/preferences/mod.ts
@@ -15,6 +15,7 @@ export interface PrefDecl {
optional?: boolean,
hidden?: boolean
allow_url?: boolean
+ require_reload?: boolean,
}
type Type = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
diff --git a/client-web/source/room.ts b/client-web/source/room.ts
index a685f1d..27d2327 100644
--- a/client-web/source/room.ts
+++ b/client-web/source/room.ts
@@ -20,7 +20,7 @@ export class Room {
public on_ready = () => { };
- constructor(public signaling: SignalingConnection) {
+ constructor(public signaling: SignalingConnection, public rtc_config: RTCConfiguration) {
this.signaling.control_handler = (a) => this.control_handler(a)
this.signaling.relay_handler = (a, b) => this.relay_handler(a, b)
}
diff --git a/client-web/source/user/remote.ts b/client-web/source/user/remote.ts
index bd89e0e..5e81cf7 100644
--- a/client-web/source/user/remote.ts
+++ b/client-web/source/user/remote.ts
@@ -7,7 +7,7 @@
import { RelayMessage } from "../../../common/packets.d.ts";
import { notify } from "../helper.ts";
-import { ROOM_CONTAINER, RTC_CONFIG } from "../index.ts"
+import { ROOM_CONTAINER } from "../index.ts"
import { log } from "../logger.ts"
import { PREFS } from "../preferences/mod.ts";
import { new_remote_resource, RemoteResource } from "../resource/mod.ts";
@@ -28,7 +28,7 @@ export class RemoteUser extends User {
room.remote_users.set(id, this)
log("usermodel", `added remote user: ${this.display_name}`)
- this.pc = new RTCPeerConnection(RTC_CONFIG)
+ this.pc = new RTCPeerConnection(room.rtc_config)
this.pc.onicecandidate = ev => {
if (!ev.candidate) return
room.signaling.send_relay({ ice_candidate: ev.candidate.toJSON() }, this.id)
diff --git a/server/Cargo.toml b/server/Cargo.toml
index 4a61294..22413a2 100644
--- a/server/Cargo.toml
+++ b/server/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-warp = "0.3"
+warp = "0.3.3"
tokio = { version = "1.25", features = ["full"] }
log = "0.4"
env_logger = "0.10"
@@ -14,6 +14,7 @@ hyper = "0.14.24"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
include_dir = "0.7.3"
+toml = "0.7.2"
[features]
default = []
diff --git a/server/src/assets.rs b/server/src/assets.rs
index 320a4e4..51b0025 100644
--- a/server/src/assets.rs
+++ b/server/src/assets.rs
@@ -2,7 +2,7 @@
#[macro_export]
macro_rules! s_file {
($path: literal, $content_type: literal) => {
- warp::fs::file($path)
+ warp::fs::file(concat!("../", $path))
};
}
@@ -10,7 +10,7 @@ macro_rules! s_file {
#[macro_export]
macro_rules! s_asset_dir {
() => {
- warp::fs::dir("client-web/public/assets")
+ warp::fs::dir("../client-web/public/assets")
};
}
diff --git a/server/src/config.rs b/server/src/config.rs
new file mode 100644
index 0000000..9d6213c
--- /dev/null
+++ b/server/src/config.rs
@@ -0,0 +1,20 @@
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct ClientConfig {
+ webrtc: ClientWebrtcConfig,
+ appearance: ClientAppearanceConfig,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct ClientWebrtcConfig {
+ stun: String,
+ turn: Option,
+ turn_user: Option,
+ turn_cred: Option,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct ClientAppearanceConfig {
+ accent: Option,
+}
diff --git a/server/src/main.rs b/server/src/main.rs
index 61c9ad1..8a0e342 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -4,9 +4,11 @@
Copyright (C) 2022 metamuffin
*/
pub mod assets;
+pub mod config;
pub mod protocol;
pub mod room;
+use config::ClientConfig;
use hyper::{header, StatusCode};
use listenfd::ListenFd;
use log::{debug, error};
@@ -34,6 +36,10 @@ fn main() {
async fn run() {
env_logger::init_from_env("LOG");
+ let client_config: ClientConfig = toml::from_str(include_str!("../../config/client.toml"))
+ .expect("client configuration invalid");
+ let client_config_json = serde_json::to_string(&client_config).unwrap();
+
let rooms: _ = Rooms::default();
let rooms: _ = warp::any().map(move || rooms.clone());
@@ -51,6 +57,13 @@ async fn run() {
"client-web/public/assets/sw.js",
"application/javascript"
));
+ let client_config: _ = warp::path!("config.json").map(move || {
+ warp::reply::with_header(
+ client_config_json.clone(),
+ "content-type",
+ "application/json",
+ )
+ });
let favicon: _ = warp::path!("favicon.ico").map(|| "");
let old_format_redirect: _ = warp::path!("room" / String).map(|rsecret| {
reply::with_header(
@@ -65,6 +78,7 @@ async fn run() {
.or(room)
.or(index)
.or(signaling)
+ .or(client_config)
.or(favicon)
.or(sw_script)
.or(old_format_redirect)
--
cgit v1.2.3-70-g09d2
From e31c48f5a9cfe6fd8988b83b17e00538fa69d6d3 Mon Sep 17 00:00:00 2001
From: metamuffin
Date: Tue, 21 Feb 2023 15:52:06 +0100
Subject: server-side appearance config
---
client-web/source/index.ts | 16 +++++++++++++++-
client-web/source/preferences/decl.ts | 6 ------
client-web/source/protocol/mod.ts | 1 -
config/client.example.toml | 16 ++++++++++++++++
server/src/config.rs | 8 ++++++--
5 files changed, 37 insertions(+), 10 deletions(-)
create mode 100644 config/client.example.toml
(limited to 'client-web/source')
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 4590625..83f1dfc 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -18,7 +18,13 @@ export const VERSION = "0.1.12"
export const ROOM_CONTAINER = esection({ class: "room", aria_label: "user list" })
export interface ClientConfig {
- appearance: { accent: string }
+ appearance?: {
+ accent: string
+ accent_dark: string
+ accent_light: string
+ background: string
+ background_dark: string
+ }
webrtc: {
stun: string,
turn?: string,
@@ -73,6 +79,14 @@ export async function main() {
username: config.webrtc.turn_user,
}]
}
+ if (config.appearance) {
+ document.body.style.setProperty("--ac", config.appearance.accent)
+ document.body.style.setProperty("--ac-dark", config.appearance.accent_dark)
+ document.body.style.setProperty("--ac-light", config.appearance.accent_light)
+ document.body.style.setProperty("--bg", config.appearance.background)
+ document.body.style.setProperty("--bg-dark", config.appearance.background_dark)
+
+ }
r = new Room(conn, rtc_config)
diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts
index 68cb9ee..f3f8e84 100644
--- a/client-web/source/preferences/decl.ts
+++ b/client-web/source/preferences/decl.ts
@@ -18,13 +18,7 @@ export const PREF_DECLS = {
username: { type: string, default: "guest-" + hex_id(), description: "Username", allow_url: true },
warn_redirect: { type: bool, hidden: true, default: false, description: "Internal option that is set by a server redirect.", allow_url: true },
image_view_popup: { type: bool, default: true, description: "Open image in popup instead of new tab" },
-
- // TODO!
- /* WEBRTC */
webrtc_debug: { type: bool, default: false, description: "Show additional information for WebRTC related stuff" },
- webrtc_stun: { type: string, default: "stun:meet.metamuffin.org:16900", description: "Custom STUN server (all participants must use the same server)" },
- webrtc_turn: { type: optional(string), default: "turn:meet.metamuffin.org:16900", description: "Custom TURN server (all participants must use the same server)" },
- webrtc_turn_cred: { type: optional(string), description: "TURN server credentials" },
/* MEDIA */
microphone_enabled: { type: bool, default: false, description: "Add one microphone track on startup" },
diff --git a/client-web/source/protocol/mod.ts b/client-web/source/protocol/mod.ts
index 3674c08..6d49a17 100644
--- a/client-web/source/protocol/mod.ts
+++ b/client-web/source/protocol/mod.ts
@@ -33,7 +33,6 @@ export class SignalingConnection {
this.on_open()
r()
})
- log("ws", "connection opened")
return this
}
diff --git a/config/client.example.toml b/config/client.example.toml
new file mode 100644
index 0000000..39e942a
--- /dev/null
+++ b/config/client.example.toml
@@ -0,0 +1,16 @@
+
+[appearance]
+accent = "#5e3f84"
+accent_dark = "#2d0d52"
+accent_light = "#7c43bd"
+background = "#151315"
+background_dark = "#070707"
+
+# If you decide to host your own TURN server, adjust this.
+[webrtc]
+stun = "stun:meet.metamuffin.org:16900"
+# turn = "turn:meet.metamuffin.org:16900"
+## Set the default turn credentials.
+## If not provided, TURN is disabled by default and requires manual activation via password (TODO).
+# turn_user = "keksmeet"
+# turn_cred = "thatsmypassword"
diff --git a/server/src/config.rs b/server/src/config.rs
index 9d6213c..6dd380f 100644
--- a/server/src/config.rs
+++ b/server/src/config.rs
@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientConfig {
webrtc: ClientWebrtcConfig,
- appearance: ClientAppearanceConfig,
+ appearance: Option,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -16,5 +16,9 @@ pub struct ClientWebrtcConfig {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientAppearanceConfig {
- accent: Option,
+ accent: String,
+ accent_light: String,
+ accent_dark: String,
+ background: String,
+ background_dark: String,
}
--
cgit v1.2.3-70-g09d2
From 0cc79a94471d4b12caad8e29dfbedba0149aae02 Mon Sep 17 00:00:00 2001
From: metamuffin
Date: Mon, 27 Feb 2023 18:19:50 +0100
Subject: properly apply configured theme everywheere
---
client-web/source/index.ts | 8 --------
server/src/config.rs | 22 +++++++++++-----------
server/src/main.rs | 29 ++++++++++++++++++++++++++++-
3 files changed, 39 insertions(+), 20 deletions(-)
(limited to 'client-web/source')
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 83f1dfc..c92ca2b 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -79,14 +79,6 @@ export async function main() {
username: config.webrtc.turn_user,
}]
}
- if (config.appearance) {
- document.body.style.setProperty("--ac", config.appearance.accent)
- document.body.style.setProperty("--ac-dark", config.appearance.accent_dark)
- document.body.style.setProperty("--ac-light", config.appearance.accent_light)
- document.body.style.setProperty("--bg", config.appearance.background)
- document.body.style.setProperty("--bg-dark", config.appearance.background_dark)
-
- }
r = new Room(conn, rtc_config)
diff --git a/server/src/config.rs b/server/src/config.rs
index 6dd380f..870315e 100644
--- a/server/src/config.rs
+++ b/server/src/config.rs
@@ -2,23 +2,23 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientConfig {
- webrtc: ClientWebrtcConfig,
- appearance: Option,
+ pub webrtc: ClientWebrtcConfig,
+ pub appearance: ClientAppearanceConfig,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientWebrtcConfig {
- stun: String,
- turn: Option,
- turn_user: Option,
- turn_cred: Option,
+ pub stun: String,
+ pub turn: Option,
+ pub turn_user: Option,
+ pub turn_cred: Option,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientAppearanceConfig {
- accent: String,
- accent_light: String,
- accent_dark: String,
- background: String,
- background_dark: String,
+ pub accent: String,
+ pub accent_light: String,
+ pub accent_dark: String,
+ pub background: String,
+ pub background_dark: String,
}
diff --git a/server/src/main.rs b/server/src/main.rs
index 8a0e342..78f236a 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -8,7 +8,7 @@ pub mod config;
pub mod protocol;
pub mod room;
-use config::ClientConfig;
+use config::{ClientAppearanceConfig, ClientConfig};
use hyper::{header, StatusCode};
use listenfd::ListenFd;
use log::{debug, error};
@@ -39,6 +39,7 @@ async fn run() {
let client_config: ClientConfig = toml::from_str(include_str!("../../config/client.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 rooms: _ = Rooms::default();
let rooms: _ = warp::any().map(move || rooms.clone());
@@ -64,6 +65,9 @@ async fn run() {
"application/json",
)
});
+ let client_config_css: _ = warp::path!("overrides.css").map(move || {
+ warp::reply::with_header(client_config_css.clone(), "content-type", "text/css")
+ });
let favicon: _ = warp::path!("favicon.ico").map(|| "");
let old_format_redirect: _ = warp::path!("room" / String).map(|rsecret| {
reply::with_header(
@@ -82,6 +86,7 @@ async fn run() {
.or(favicon)
.or(sw_script)
.or(old_format_redirect)
+ .or(client_config_css)
.recover(handle_rejection)
.with(warp::log("stuff"));
@@ -140,3 +145,25 @@ fn signaling_connect(rsecret: String, rooms: Rooms, ws: warp::ws::Ws) -> impl Re
}
ws.on_upgrade(move |sock| inner(sock, rsecret, rooms))
}
+
+fn css_overrides(
+ ClientAppearanceConfig {
+ accent,
+ accent_light,
+ accent_dark,
+ background,
+ background_dark,
+ }: &ClientAppearanceConfig,
+) -> 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};
+}}
+"#
+ )
+}
--
cgit v1.2.3-70-g09d2