From d786fedd66e1f24e51e68dc70092add2ef1bced2 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 29 Oct 2023 18:56:30 +0100 Subject: specify bind address in config --- config/config.example.toml | 19 ------------------- config/default.toml | 22 ++++++++++++++++++++++ server/src/config.rs | 7 +++++++ server/src/main.rs | 7 +------ 4 files changed, 30 insertions(+), 25 deletions(-) delete mode 100644 config/config.example.toml create mode 100644 config/default.toml diff --git a/config/config.example.toml b/config/config.example.toml deleted file mode 100644 index 780c8b5..0000000 --- a/config/config.example.toml +++ /dev/null @@ -1,19 +0,0 @@ -[features] -room_watches = true - -[appearance] -accent = "#5e3f84" -accent_dark = "#2d0d52" -accent_light = "#7c43bd" -background = "#151315" -background_dark = "#070707" -background_light = "#211c21" - -# 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. -# turn_user = "keksmeet" -# turn_cred = "thatsmypassword" diff --git a/config/default.toml b/config/default.toml new file mode 100644 index 0000000..c23fdc2 --- /dev/null +++ b/config/default.toml @@ -0,0 +1,22 @@ +[server] +bind = "127.0.0.1:24319" + +[features] +room_watches = true + +[appearance] +accent = "#5e3f84" +accent_dark = "#2d0d52" +accent_light = "#7c43bd" +background = "#151315" +background_dark = "#070707" +background_light = "#211c21" + +# 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. +# turn_user = "keksmeet" +# turn_cred = "thatsmypassword" diff --git a/server/src/config.rs b/server/src/config.rs index 1351f30..f11c83f 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -4,14 +4,21 @@ Copyright (C) 2023 metamuffin */ use serde::{Deserialize, Serialize}; +use std::net::SocketAddr; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Config { + pub server: ServerConfig, pub features: FeaturesConfig, pub webrtc: WebrtcConfig, pub appearance: AppearanceConfig, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ServerConfig { + pub bind: SocketAddr, +} + #[rustfmt::skip] #[derive(Debug, Clone, Serialize, Deserialize)] pub struct FeaturesConfig { diff --git a/server/src/main.rs b/server/src/main.rs index eb6e502..64fa96f 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -19,8 +19,6 @@ use listenfd::ListenFd; use log::{debug, error}; use logic::State; use std::convert::Infallible; -use std::net::SocketAddr; -use std::str::FromStr; use std::sync::Arc; use tokio::sync::mpsc; use warp::{ @@ -124,10 +122,7 @@ async fn run() { let server = if let Some(l) = listenfd.take_tcp_listener(0).unwrap() { Server::from_tcp(l).unwrap() } else { - Server::bind( - &SocketAddr::from_str(&std::env::var("BIND").unwrap_or(String::from("127.0.0.1:8080"))) - .unwrap(), - ) + Server::bind(&config.server.bind) }; let service = warp::service(routes); server -- cgit v1.2.3-70-g09d2