aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-02-21 15:12:38 +0100
committermetamuffin <metamuffin@disroot.org>2023-02-21 15:12:38 +0100
commit630cd2b82887da49cacb2deb032c6a51b3c2faf7 (patch)
tree6a5eef8e1190d7e85a57d2bbe90663b71d56cabe /server
parent70e1090e7c5e5aa6ed0a621ad71924b7931ef05d (diff)
downloadkeks-meet-630cd2b82887da49cacb2deb032c6a51b3c2faf7.tar
keks-meet-630cd2b82887da49cacb2deb032c6a51b3c2faf7.tar.bz2
keks-meet-630cd2b82887da49cacb2deb032c6a51b3c2faf7.tar.zst
server-side client configuration
Diffstat (limited to 'server')
-rw-r--r--server/Cargo.toml3
-rw-r--r--server/src/assets.rs4
-rw-r--r--server/src/config.rs20
-rw-r--r--server/src/main.rs14
4 files changed, 38 insertions, 3 deletions
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<String>,
+ turn_user: Option<String>,
+ turn_cred: Option<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct ClientAppearanceConfig {
+ accent: Option<String>,
+}
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 <metamuffin@disroot.org>
*/
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)