From 3bc7cf8ed36016ca3da9438a98f4fe8b8e6f9e61 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Thu, 15 Feb 2024 17:17:30 +0100 Subject: Closes #10 & #12. Added `thiserror` crate and changed to `IntoSocketAddr` for easier usage and error handling --- src/routes/start.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/routes/start.rs') diff --git a/src/routes/start.rs b/src/routes/start.rs index ce95bf3..66b7cb4 100644 --- a/src/routes/start.rs +++ b/src/routes/start.rs @@ -20,7 +20,7 @@ pub async fn start( ) -> Result, Error> { info!("POST request"); let secret = headers.get("authorization"); - let authorized = auth(&state.config, secret).map_err(Error::Auth)?; + let authorized = auth(&state.config, secret)?; if authorized { let device = sqlx::query_as!( Device, @@ -32,16 +32,15 @@ pub async fn start( payload.id ) .fetch_one(&state.db) - .await - .map_err(Error::DB)?; + .await?; info!("starting {}", device.id); let bind_addr = "0.0.0.0:0"; let _ = send_packet( - &bind_addr.parse().map_err(Error::IpParse)?, - &device.broadcast_addr.parse().map_err(Error::IpParse)?, + bind_addr, + &device.broadcast_addr, &create_buffer(&device.mac)?, )?; let dev_id = device.id.clone(); -- cgit v1.2.3