From dac8b3db498c9c832005c0e4fdc2edb70f878938 Mon Sep 17 00:00:00 2001 From: strawberry <strawberry@puppygock.gay> Date: Sun, 11 Feb 2024 12:23:15 -0500 Subject: [PATCH] move these config checks to main.rs Signed-off-by: strawberry <strawberry@puppygock.gay> --- src/database/mod.rs | 8 -------- src/main.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/database/mod.rs b/src/database/mod.rs index d6171208f..26cb88038 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -257,14 +257,6 @@ pub async fn load_or_create(config: Config) -> Result<()> { } }; - if config.registration_token == Some(String::new()) { - return Err(Error::bad_config("Registration token is empty")); - } - - if config.max_request_size < 4096 { - error!(?config.max_request_size, "Max request size is less than 4KB. Please increase it."); - } - let (presence_sender, presence_receiver) = mpsc::unbounded_channel(); let db_raw = Box::new(Self { diff --git a/src/main.rs b/src/main.rs index d6ccb3d30..1613812cf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -153,6 +153,16 @@ async fn main() { /* ad-hoc config validation/checks */ + // check if the user specified a registration token as `""` + if config.registration_token == Some(String::new()) { + error!("Registration token was specified but is empty (\"\")"); + return; + } + + if config.max_request_size < 4096 { + error!(?config.max_request_size, "Max request size is less than 4KB. Please increase it."); + } + // check if user specified valid IP CIDR ranges on startup for cidr in services().globals.ip_range_denylist() { let _ = ipaddress::IPAddress::parse(cidr) -- GitLab