diff options
Diffstat (limited to 'src/routes/start.rs')
-rw-r--r-- | src/routes/start.rs | 9 |
1 files changed, 4 insertions, 5 deletions
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( | |||
20 | ) -> Result<Json<Value>, Error> { | 20 | ) -> Result<Json<Value>, Error> { |
21 | info!("POST request"); | 21 | info!("POST request"); |
22 | let secret = headers.get("authorization"); | 22 | let secret = headers.get("authorization"); |
23 | let authorized = auth(&state.config, secret).map_err(Error::Auth)?; | 23 | let authorized = auth(&state.config, secret)?; |
24 | if authorized { | 24 | if authorized { |
25 | let device = sqlx::query_as!( | 25 | let device = sqlx::query_as!( |
26 | Device, | 26 | Device, |
@@ -32,16 +32,15 @@ pub async fn start( | |||
32 | payload.id | 32 | payload.id |
33 | ) | 33 | ) |
34 | .fetch_one(&state.db) | 34 | .fetch_one(&state.db) |
35 | .await | 35 | .await?; |
36 | .map_err(Error::DB)?; | ||
37 | 36 | ||
38 | info!("starting {}", device.id); | 37 | info!("starting {}", device.id); |
39 | 38 | ||
40 | let bind_addr = "0.0.0.0:0"; | 39 | let bind_addr = "0.0.0.0:0"; |
41 | 40 | ||
42 | let _ = send_packet( | 41 | let _ = send_packet( |
43 | &bind_addr.parse().map_err(Error::IpParse)?, | 42 | bind_addr, |
44 | &device.broadcast_addr.parse().map_err(Error::IpParse)?, | 43 | &device.broadcast_addr, |
45 | &create_buffer(&device.mac)?, | 44 | &create_buffer(&device.mac)?, |
46 | )?; | 45 | )?; |
47 | let dev_id = device.id.clone(); | 46 | let dev_id = device.id.clone(); |