From 2ed70a4885bee6a9cd9b10cbf56d3ec23c4991ad Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Fri, 5 Apr 2024 12:18:57 +0000 Subject: [PATCH] xmpp: add the server's hostname to the config --- config.toml | 1 + crates/projection-xmpp/src/lib.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config.toml b/config.toml index 6104dce..4765aa0 100644 --- a/config.toml +++ b/config.toml @@ -9,6 +9,7 @@ server_name = "irc.localhost" listen_on = "127.0.0.1:5222" cert = "./certs/xmpp.pem" key = "./certs/xmpp.key" +hostname = "localhost" [storage] db_path = "db.sqlite" diff --git a/crates/projection-xmpp/src/lib.rs b/crates/projection-xmpp/src/lib.rs index e3cb4e5..07700f5 100644 --- a/crates/projection-xmpp/src/lib.rs +++ b/crates/projection-xmpp/src/lib.rs @@ -44,6 +44,7 @@ pub struct ServerConfig { pub listen_on: SocketAddr, pub cert: PathBuf, pub key: PathBuf, + pub hostname: Str, } struct LoadedConfig { @@ -156,7 +157,7 @@ pub async fn launch( } async fn handle_socket( - config: Arc, + cert_config: Arc, mut stream: TcpStream, socket_addr: &SocketAddr, mut players: PlayerRegistry, @@ -175,7 +176,7 @@ async fn handle_socket( let mut config = tokio_rustls::rustls::ServerConfig::builder() .with_safe_defaults() .with_no_client_auth() - .with_single_cert(vec![config.cert.clone()], config.key.clone())?; + .with_single_cert(vec![cert_config.cert.clone()], cert_config.key.clone())?; config.key_log = Arc::new(tokio_rustls::rustls::KeyLogFile::new()); log::debug!("Accepting TLS connection...");