Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions devolutions-gateway/src/http/controllers/http_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ impl HttpBridgeController {
}
}

impl Default for HttpBridgeController {
fn default() -> Self {
Self::new()
}
}

#[controller(name = "bridge")]
impl HttpBridgeController {
#[get("/message")]
Expand All @@ -27,11 +33,7 @@ impl HttpBridgeController {
async fn message(&self, req: Request) -> Result<Builder, HttpErrorStatus> {
use core::convert::TryFrom;

if let Some(JetAccessTokenClaims::Bridge(claims)) = req
.extensions()
.get::<JetAccessTokenClaims>()
.map(|claim| claim.clone())
{
if let Some(JetAccessTokenClaims::Bridge(claims)) = req.extensions().get::<JetAccessTokenClaims>().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.
Expand Down
2 changes: 1 addition & 1 deletion devolutions-gateway/src/http/controllers/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl SessionsController {
async fn get_sessions(&self) -> Result<Json<Vec<GatewaySessionInfo>>, HttpErrorStatus> {
let sessions = SESSIONS_IN_PROGRESS.read().await;

let sessions_in_progress: Vec<GatewaySessionInfo> = sessions.values().map(|x| x.clone()).collect();
let sessions_in_progress: Vec<GatewaySessionInfo> = sessions.values().cloned().collect();

Ok(Json(sessions_in_progress))
}
Expand Down
3 changes: 2 additions & 1 deletion devolutions-gateway/src/http/middlewares/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
36 changes: 17 additions & 19 deletions devolutions-gateway/src/jet_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions devolutions-gateway/src/rdp/accept_connection_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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;
Expand Down
42 changes: 20 additions & 22 deletions devolutions-gateway/src/websocket_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,26 @@ async fn handle_jet_connect_impl(
let mut recording_interceptor: Option<Box<dyn PacketInterceptor>> = 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;
Expand Down