From 8ed77d7ab484121e9d70158e14c9fd6c243f1c70 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Mon, 12 Feb 2024 14:58:08 +0100 Subject: Close #9. Config impl with struct and files --- src/routes/start.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/routes/start.rs') diff --git a/src/routes/start.rs b/src/routes/start.rs index 4264588..ce95bf3 100644 --- a/src/routes/start.rs +++ b/src/routes/start.rs @@ -1,5 +1,4 @@ use crate::auth::auth; -use crate::config::SETTINGS; use crate::db::Device; use crate::error::Error; use crate::services::ping::Value as PingValue; @@ -21,7 +20,7 @@ pub async fn start( ) -> Result, Error> { info!("POST request"); let secret = headers.get("authorization"); - let authorized = auth(secret).map_err(Error::Auth)?; + let authorized = auth(&state.config, secret).map_err(Error::Auth)?; if authorized { let device = sqlx::query_as!( Device, @@ -38,9 +37,7 @@ pub async fn start( info!("starting {}", device.id); - let bind_addr = SETTINGS - .get_string("bindaddr") - .unwrap_or("0.0.0.0:1111".to_string()); + let bind_addr = "0.0.0.0:0"; let _ = send_packet( &bind_addr.parse().map_err(Error::IpParse)?, @@ -75,6 +72,7 @@ pub async fn start( crate::services::ping::spawn( state.ping_send.clone(), + &state.config, device, uuid_gen.clone(), &state.ping_map, -- cgit v1.2.3