Port with sock addr
This commit is contained in:
@@ -7,6 +7,7 @@ use crate::protocol::ServerMeta;
|
|||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub meta: ServerMeta,
|
pub meta: ServerMeta,
|
||||||
|
pub port: u16,
|
||||||
pub public_hostname: String,
|
pub public_hostname: String,
|
||||||
pub hostnames: HashSet<String>,
|
pub hostnames: HashSet<String>,
|
||||||
}
|
}
|
||||||
@@ -19,6 +20,10 @@ impl Config {
|
|||||||
description: String::new(),
|
description: String::new(),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
port: 3415,
|
||||||
|
|
||||||
|
public_hostname: "localhost:3000".to_string(),
|
||||||
|
|
||||||
hostnames: HashSet::from_iter(["localhost:3000".to_string()]),
|
hostnames: HashSet::from_iter(["localhost:3000".to_string()]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-3
@@ -3,7 +3,10 @@ pub mod protocol;
|
|||||||
pub mod server;
|
pub mod server;
|
||||||
pub mod signature;
|
pub mod signature;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::{
|
||||||
|
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
Router,
|
||||||
@@ -21,9 +24,13 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/meta", get(meta))
|
.route("/meta", get(meta))
|
||||||
.route("/", any(ws_handler))
|
.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?;
|
axum::serve(listener, app).await?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user