From 33e9e87c8c90d70a9ead467a707aeb30225d10e0 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 15 Aug 2026 07:14:56 +0200 Subject: [PATCH] Port with sock addr --- src/config.rs | 5 +++++ src/main.rs | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 3f3e224..7bf6349 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,7 @@ use crate::protocol::ServerMeta; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Config { pub meta: ServerMeta, + pub port: u16, pub public_hostname: String, pub hostnames: HashSet, } @@ -19,6 +20,10 @@ impl Config { description: String::new(), }, + port: 3415, + + public_hostname: "localhost:3000".to_string(), + hostnames: HashSet::from_iter(["localhost:3000".to_string()]), } } diff --git a/src/main.rs b/src/main.rs index a4db3c4..cd992dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,10 @@ pub mod protocol; pub mod server; pub mod signature; -use std::sync::Arc; +use std::{ + net::{IpAddr, Ipv4Addr, SocketAddr}, + sync::Arc, +}; use axum::{ Router, @@ -21,9 +24,13 @@ async fn main() -> anyhow::Result<()> { let app = Router::new() .route("/meta", get(meta)) .route("/", any(ws_handler)) - .with_state(server); + .with_state(server.clone()); - let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?; + let listener = tokio::net::TcpListener::bind(SocketAddr::new( + IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), + server.config.port, + )) + .await?; axum::serve(listener, app).await?;