diff --git a/devolutions-gateway/src/http/controllers/http_bridge.rs b/devolutions-gateway/src/http/controllers/http_bridge.rs index e6831d9f6..39b0fd7df 100644 --- a/devolutions-gateway/src/http/controllers/http_bridge.rs +++ b/devolutions-gateway/src/http/controllers/http_bridge.rs @@ -16,6 +16,12 @@ impl HttpBridgeController { } } +impl Default for HttpBridgeController { + fn default() -> Self { + Self::new() + } +} + #[controller(name = "bridge")] impl HttpBridgeController { #[get("/message")] @@ -27,11 +33,7 @@ impl HttpBridgeController { async fn message(&self, req: Request) -> Result { use core::convert::TryFrom; - if let Some(JetAccessTokenClaims::Bridge(claims)) = req - .extensions() - .get::() - .map(|claim| claim.clone()) - { + if let Some(JetAccessTokenClaims::Bridge(claims)) = req.extensions().get::().cloned() { // FIXME: when updating reqwest 0.10 → 0.11 and hyper 0.13 → 0.14: // Use https://docs.rs/reqwest/0.11.4/reqwest/struct.Body.html#impl-From%3CBody%3E // to get a streaming reqwest Request instead of loading the whole body in memory. diff --git a/devolutions-gateway/src/http/controllers/sessions.rs b/devolutions-gateway/src/http/controllers/sessions.rs index e5bd92b10..3f980bf2b 100644 --- a/devolutions-gateway/src/http/controllers/sessions.rs +++ b/devolutions-gateway/src/http/controllers/sessions.rs @@ -29,7 +29,7 @@ impl SessionsController { async fn get_sessions(&self) -> Result>, HttpErrorStatus> { let sessions = SESSIONS_IN_PROGRESS.read().await; - let sessions_in_progress: Vec = sessions.values().map(|x| x.clone()).collect(); + let sessions_in_progress: Vec = sessions.values().cloned().collect(); Ok(Json(sessions_in_progress)) } diff --git a/devolutions-gateway/src/http/middlewares/auth.rs b/devolutions-gateway/src/http/middlewares/auth.rs index 68ed9dde3..fbed9526b 100644 --- a/devolutions-gateway/src/http/middlewares/auth.rs +++ b/devolutions-gateway/src/http/middlewares/auth.rs @@ -87,7 +87,8 @@ async fn auth_middleware( let mut ctx = ctx.clone_with_empty_state(); ctx.state = State::After(Box::new(response)); - return Ok(ctx); + + Ok(ctx) } #[derive(PartialEq)] diff --git a/devolutions-gateway/src/jet_client.rs b/devolutions-gateway/src/jet_client.rs index fc0f84d52..7309a3c90 100644 --- a/devolutions-gateway/src/jet_client.rs +++ b/devolutions-gateway/src/jet_client.rs @@ -118,27 +118,25 @@ async fn handle_build_proxy( let associations = jet_associations.lock().await; if let Some(association) = associations.get(&association_id) { - if association.record_session() { - if config.plugins.is_some() { - let mut interceptor = PcapRecordingInterceptor::new( - response.server_transport.peer_addr().unwrap(), - response.client_transport.peer_addr().unwrap(), - association_id.clone().to_string(), - response.candidate_id.clone().to_string(), - ); - - recording_dir = match &config.recording_path { - Some(path) if path.to_str().is_some() => { - interceptor.set_recording_directory(path.to_str().unwrap()); - Some(PathBuf::from(path)) - } - _ => interceptor.get_recording_directory(), - }; + if association.record_session() && config.plugins.is_some() { + let mut interceptor = PcapRecordingInterceptor::new( + response.server_transport.peer_addr().unwrap(), + response.client_transport.peer_addr().unwrap(), + association_id.clone().to_string(), + response.candidate_id.clone().to_string(), + ); + + recording_dir = match &config.recording_path { + Some(path) if path.to_str().is_some() => { + interceptor.set_recording_directory(path.to_str().unwrap()); + Some(PathBuf::from(path)) + } + _ => interceptor.get_recording_directory(), + }; - file_pattern = Some(interceptor.get_filename_pattern()); + file_pattern = Some(interceptor.get_filename_pattern()); - recording_interceptor = Some(interceptor); - } + recording_interceptor = Some(interceptor); } } diff --git a/devolutions-gateway/src/rdp/accept_connection_future.rs b/devolutions-gateway/src/rdp/accept_connection_future.rs index d48e46195..55426379c 100644 --- a/devolutions-gateway/src/rdp/accept_connection_future.rs +++ b/devolutions-gateway/src/rdp/accept_connection_future.rs @@ -109,7 +109,7 @@ impl Future for AcceptConnectionFuture { return Poll::Ready(Ok(( self.client.take().unwrap(), AcceptConnectionMode::RdpTcp { url, leftover_request }, - routing_claims.into(), + routing_claims, ))); } TokenRoutingMode::RdpTcpRendezvous(association_id) => { @@ -119,12 +119,12 @@ impl Future for AcceptConnectionFuture { association_id, leftover_request, }, - routing_claims.into(), + routing_claims, ))); } TokenRoutingMode::RdpTls(identity) => { self.buffer = leftover_request; - self.rdp_identity = Some((identity, routing_claims.into())); + self.rdp_identity = Some((identity, routing_claims)); // assume that we received connection request in the same buffer // as preconnection_pdu more_data_required = false; diff --git a/devolutions-gateway/src/websocket_client.rs b/devolutions-gateway/src/websocket_client.rs index 2fda5acff..218601fda 100644 --- a/devolutions-gateway/src/websocket_client.rs +++ b/devolutions-gateway/src/websocket_client.rs @@ -231,28 +231,26 @@ async fn handle_jet_connect_impl( let mut recording_interceptor: Option> = None; let mut has_interceptor = false; - if assc.record_session() { - if config.plugins.is_some() { - let mut interceptor = PcapRecordingInterceptor::new( - server_transport.peer_addr().unwrap(), - client_addr, - association_id.clone().to_string(), - candidate_id.to_string(), - ); - - recording_dir = match &config.recording_path { - Some(path) if path.to_str().is_some() => { - interceptor.set_recording_directory(path.to_str().unwrap()); - Some(std::path::PathBuf::from(path)) - } - _ => interceptor.get_recording_directory(), - }; - - file_pattern = Some(interceptor.get_filename_pattern()); - - recording_interceptor = Some(Box::new(interceptor)); - has_interceptor = true; - } + if assc.record_session() && config.plugins.is_some() { + let mut interceptor = PcapRecordingInterceptor::new( + server_transport.peer_addr().unwrap(), + client_addr, + association_id.clone().to_string(), + candidate_id.to_string(), + ); + + recording_dir = match &config.recording_path { + Some(path) if path.to_str().is_some() => { + interceptor.set_recording_directory(path.to_str().unwrap()); + Some(std::path::PathBuf::from(path)) + } + _ => interceptor.get_recording_directory(), + }; + + file_pattern = Some(interceptor.get_filename_pattern()); + + recording_interceptor = Some(Box::new(interceptor)); + has_interceptor = true; } // We need to manually drop mutex lock to avoid deadlock below;