diff --git a/src/config.rs b/src/config.rs index b6369e1d..290b1a3f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,11 @@ use log::LevelFilter; use serde::Deserialize; -use std::{env, fs::read_to_string, path::Path}; +use std::{ + env, + fs::read_to_string, + net::{IpAddr, Ipv4Addr}, + path::Path, +}; use crate::session::models::Port; @@ -60,6 +65,7 @@ pub fn load_config() -> Option { #[derive(Deserialize)] #[serde(default)] pub struct Config { + pub host: IpAddr, pub port: Port, pub qos: QosServerConfig, pub reverse_proxy: bool, @@ -73,6 +79,7 @@ pub struct Config { impl Default for Config { fn default() -> Self { Self { + host: IpAddr::V4(Ipv4Addr::UNSPECIFIED), port: 80, qos: QosServerConfig::default(), reverse_proxy: false, diff --git a/src/main.rs b/src/main.rs index aeab5222..635f5e10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,10 +9,7 @@ use crate::{ use axum::{Extension, Server}; use config::load_config; use log::{debug, error, info, LevelFilter}; -use std::{ - net::{Ipv4Addr, SocketAddr}, - sync::Arc, -}; +use std::{net::SocketAddr, sync::Arc}; use tokio::{join, signal}; use utils::logging; @@ -37,7 +34,7 @@ async fn main() { logging::setup(config.logging); // Create the server socket address while the port is still available - let addr: SocketAddr = (Ipv4Addr::UNSPECIFIED, config.port).into(); + let addr: SocketAddr = SocketAddr::new(config.host, config.port); // Config data persisted to runtime let runtime_config = RuntimeConfig {