Port with sock addr

This commit is contained in:
2026-08-15 07:14:56 +02:00
parent b3b147b070
commit 33e9e87c8c
2 changed files with 15 additions and 3 deletions
+5
View File
@@ -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<String>,
}
@@ -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()]),
}
}
+10 -3
View File
@@ -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?;