mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2025-03-14 18:55:37 +00:00
add option to disable listeners
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
e56d3c6cb3
commit
5167e1f06d
3 changed files with 20 additions and 4 deletions
|
@ -1503,6 +1503,11 @@
|
|||
#
|
||||
#sender_workers = 0
|
||||
|
||||
# Enables listener sockets; can be set to false to disable listening. This
|
||||
# option is intended for developer/diagnostic purposes only.
|
||||
#
|
||||
#listening = true
|
||||
|
||||
[global.tls]
|
||||
|
||||
# Path to a valid TLS certificate file.
|
||||
|
|
|
@ -1710,6 +1710,11 @@ pub struct Config {
|
|||
#[serde(default)]
|
||||
pub sender_workers: usize,
|
||||
|
||||
/// Enables listener sockets; can be set to false to disable listening. This
|
||||
/// option is intended for developer/diagnostic purposes only.
|
||||
#[serde(default = "true_fn")]
|
||||
pub listening: bool,
|
||||
|
||||
#[serde(flatten)]
|
||||
#[allow(clippy::zero_sized_map_values)]
|
||||
// this is a catchall, the map shouldn't be zero at runtime
|
||||
|
|
|
@ -6,7 +6,7 @@ mod unix;
|
|||
use std::sync::Arc;
|
||||
|
||||
use axum_server::Handle as ServerHandle;
|
||||
use conduwuit::Result;
|
||||
use conduwuit::{err, Result};
|
||||
use conduwuit_service::Services;
|
||||
use tokio::sync::broadcast;
|
||||
|
||||
|
@ -16,13 +16,19 @@ use super::layers;
|
|||
pub(super) async fn serve(
|
||||
services: Arc<Services>,
|
||||
handle: ServerHandle,
|
||||
shutdown: broadcast::Receiver<()>,
|
||||
) -> Result<()> {
|
||||
mut shutdown: broadcast::Receiver<()>,
|
||||
) -> Result {
|
||||
let server = &services.server;
|
||||
let config = &server.config;
|
||||
if !config.listening {
|
||||
return shutdown
|
||||
.recv()
|
||||
.await
|
||||
.map_err(|e| err!(error!("channel error: {e}")));
|
||||
}
|
||||
|
||||
let addrs = config.get_bind_addrs();
|
||||
let (app, _guard) = layers::build(&services)?;
|
||||
|
||||
if cfg!(unix) && config.unix_socket_path.is_some() {
|
||||
unix::serve(server, app, shutdown).await
|
||||
} else if config.tls.certs.is_some() {
|
||||
|
|
Loading…
Add table
Reference in a new issue