forked from lavina/lavina
1
0
Fork 0

xmpp: add the server's hostname to the config

This commit is contained in:
Nikita Vilunov 2024-04-05 12:18:57 +00:00
parent 0944c449ca
commit d2600c4299
2 changed files with 4 additions and 2 deletions

View File

@ -9,6 +9,7 @@ server_name = "irc.localhost"
listen_on = "127.0.0.1:5222" listen_on = "127.0.0.1:5222"
cert = "./certs/xmpp.pem" cert = "./certs/xmpp.pem"
key = "./certs/xmpp.key" key = "./certs/xmpp.key"
hostname = "localhost"
[storage] [storage]
db_path = "db.sqlite" db_path = "db.sqlite"

View File

@ -44,6 +44,7 @@ pub struct ServerConfig {
pub listen_on: SocketAddr, pub listen_on: SocketAddr,
pub cert: PathBuf, pub cert: PathBuf,
pub key: PathBuf, pub key: PathBuf,
pub hostname: Str,
} }
struct LoadedConfig { struct LoadedConfig {
@ -164,7 +165,7 @@ pub async fn launch(
} }
async fn handle_socket( async fn handle_socket(
config: Arc<LoadedConfig>, cert_config: Arc<LoadedConfig>,
mut stream: TcpStream, mut stream: TcpStream,
socket_addr: &SocketAddr, socket_addr: &SocketAddr,
mut players: PlayerRegistry, mut players: PlayerRegistry,
@ -183,7 +184,7 @@ async fn handle_socket(
let mut config = tokio_rustls::rustls::ServerConfig::builder() let mut config = tokio_rustls::rustls::ServerConfig::builder()
.with_safe_defaults() .with_safe_defaults()
.with_no_client_auth() .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()); config.key_log = Arc::new(tokio_rustls::rustls::KeyLogFile::new());
log::debug!("Accepting TLS connection..."); log::debug!("Accepting TLS connection...");