Skip to content

Commit dabf8e4

Browse files
review fix
1 parent a10f4b9 commit dabf8e4

File tree

7 files changed

+56
-62
lines changed

7 files changed

+56
-62
lines changed

devolutions-agent/src/config.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,12 @@ pub mod dto {
244244

245245
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
246246
#[serde(rename_all = "PascalCase")]
247+
#[derive(Default)]
247248
pub struct PedmConf {
248249
/// Enable PEDM module (disabled by default)
249250
pub enabled: bool,
250251
}
251252

252-
impl Default for PedmConf {
253-
fn default() -> Self {
254-
Self { enabled: false }
255-
}
256-
}
257-
258253
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
259254
#[serde(rename_all = "PascalCase")]
260255
pub struct SessionConf {

devolutions-agent/src/remote_desktop/graphics.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ impl RdpServerDisplayUpdates for DisplayUpdates {
4646
let left: u16 = rng.gen_range(0..WIDTH);
4747
let width = NonZeroU16::new(rng.gen_range(1..=WIDTH - left)).expect("never zero");
4848

49-
let data: Vec<u8> = std::iter::repeat([rng.r#gen(), rng.r#gen(), rng.r#gen(), 255])
50-
.take(usize::from(width.get()) * usize::from(height.get()))
51-
.flatten()
52-
.collect();
49+
let data: Vec<u8> = std::iter::repeat_n(
50+
[rng.r#gen(), rng.r#gen(), rng.r#gen(), 255],
51+
usize::from(width.get()) * usize::from(height.get()),
52+
)
53+
.flatten()
54+
.collect();
5355

5456
trace!(left, top, width, height, "BitmapUpdate");
5557

devolutions-gateway/src/api/net.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,19 @@ impl TryFrom<ScannerEvent> for NetworkScanResponse {
370370
protocol,
371371
port,
372372
}) => {
373-
let protocol = match protocol {
374-
None => None,
375-
Some(protocol) => Some(match protocol {
376-
scanner::ServiceType::Rdp => Protocol::Rdp,
377-
scanner::ServiceType::Ard => Protocol::Ard,
378-
scanner::ServiceType::Vnc => Protocol::Vnc,
379-
scanner::ServiceType::Ssh => Protocol::Ssh,
380-
scanner::ServiceType::Sftp => Protocol::Sftp,
381-
scanner::ServiceType::Scp => Protocol::Scp,
382-
scanner::ServiceType::Telnet => Protocol::Telnet,
383-
scanner::ServiceType::Http => Protocol::Http,
384-
scanner::ServiceType::Https => Protocol::Https,
385-
scanner::ServiceType::Ldap => Protocol::Ldap,
386-
scanner::ServiceType::Ldaps => Protocol::Ldaps,
387-
}),
388-
};
373+
let protocol = protocol.map(|protocol| match protocol {
374+
scanner::ServiceType::Rdp => Protocol::Rdp,
375+
scanner::ServiceType::Ard => Protocol::Ard,
376+
scanner::ServiceType::Vnc => Protocol::Vnc,
377+
scanner::ServiceType::Ssh => Protocol::Ssh,
378+
scanner::ServiceType::Sftp => Protocol::Sftp,
379+
scanner::ServiceType::Scp => Protocol::Scp,
380+
scanner::ServiceType::Telnet => Protocol::Telnet,
381+
scanner::ServiceType::Http => Protocol::Http,
382+
scanner::ServiceType::Https => Protocol::Https,
383+
scanner::ServiceType::Ldap => Protocol::Ldap,
384+
scanner::ServiceType::Ldaps => Protocol::Ldaps,
385+
});
389386

390387
let protocol = match protocol {
391388
Some(protocol) => TcpKnockProbe::NamedApplication(protocol),

devolutions-gateway/src/credential.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ pub struct AppCredentialMapping {
2929
#[derive(Debug, Clone)]
3030
pub struct CredentialStoreHandle(Arc<Mutex<CredentialStore>>);
3131

32+
impl Default for CredentialStoreHandle {
33+
fn default() -> Self {
34+
Self::new()
35+
}
36+
}
37+
3238
impl CredentialStoreHandle {
3339
pub fn new() -> Self {
3440
Self(Arc::new(Mutex::new(CredentialStore::new())))

devolutions-gateway/src/rd_clean_path.rs

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ async fn read_cleanpath_pdu(mut stream: impl AsyncRead + Unpin + Send) -> io::Re
7777
std::cmp::Ordering::Less => {}
7878
std::cmp::Ordering::Equal => break,
7979
std::cmp::Ordering::Greater => {
80-
return Err(io::Error::new(
81-
ErrorKind::Other,
82-
"no leftover is expected when reading cleanpath PDU",
83-
));
80+
return Err(io::Error::other("no leftover is expected when reading cleanpath PDU"));
8481
}
8582
}
8683
}
@@ -234,30 +231,31 @@ async fn process_cleanpath(
234231
debug!(%selected_target, "Connected to destination server");
235232
span.record("target", selected_target.to_string());
236233

237-
// Preconnection Blob (PCB) is currently only used for Hyper-V VMs.
234+
// Preconnection Blob (PCB) is currently used for Hyper-V VMs almost exclusively in practice.
235+
// However, we still leave space for future extensions of usages of PCB.
238236
//
239-
// Connection sequence with Hyper-V VMs (PCB enabled):
240-
// ┌─────────────────────┐ ┌─────────────────────────────────────────────────────────────┐
241-
// │ handled by handled by IronRDP client
242-
// │ Gateway │ │ │
243-
// └─────────────────────┘ └─────────────────────────────────────────────────────────────┘
244-
// │PCB → TLS handshake │ → │CredSSP → X224 connection request → X224 connection response │
245-
// └─────────────────────┘ └─────────────────────────────────────────────────────────────┘
237+
// Connection sequence with Hyper-V VMs (PCB included and X224 connection request is not present):
238+
// ┌───────────────────────┐ ┌───────────────────────────────────────────────────────────────┐
239+
// │ handled by │ handled by IronRDP client │
240+
// │ Gateway │ │
241+
// └───────────────────────┘ └───────────────────────────────────────────────────────────────┘
242+
// │ PCB → TLS handshake │ → │ CredSSP → X224 connection request → X224 connection response
243+
// └───────────────────────┘ └───────────────────────────────────────────────────────────────┘
246244
//
247-
// Connection sequence without Hyper-V VMs (PCB disabled):
248-
// ┌─────────────────────────────────────────────────────────────┐ ──────────────────────┐
249-
// │ handled by Gateway handled by IronRDP
250-
// │ │ │ client
251-
// └─────────────────────────────────────────────────────────────┘ ──────────────────────┘
252-
// │X224 connection request → X224 connection response → TLS hs │ → │CredSSP → ...
253-
// └─────────────────────────────────────────────────────────────┘ ──────────────────────┘
245+
// Connection sequence without Hyper-V VMs (PCB optional):
246+
// ┌─────────────────────────────────────────────────────────────── ┌───────────────────────┐
247+
// │ handled by Gateway │ handled by IronRDP │
248+
// │ client
249+
// └─────────────────────────────────────────────────────────────── └───────────────────────┘
250+
// │ PCB → X224 connection request → X224 connection response → TLS| │ → CredSSP → ... │
251+
// └─────────────────────────────────────────────────────────────── └───────────────────────┘
254252
//
255253
// Summary:
256-
// - With PCB: Gateway handles (1) sending PCB, (2) TLS handshake, then leaves CredSSP
257-
// and X224 connection request/response to IronRDP client
258-
// - Without PCB: Gateway handles (1) X224 connection request, (2) X224 connection response,
259-
// then leaves TLS handshake and CredSSP to IronRDP client
260-
// Send preconnection blob and/or X224 connection request
254+
// - With PCB but not X224 connection request: Gateway handles (1) sending PCB/VmConnectID, (2) TLS handshake, then leaves CredSSP
255+
// and X224 connection request/response to IronRDP client.
256+
// - With PCB and X224 connection request: Gateway handles (1) sending PCB/VmConnectID, (2) X224 connection request, (3) X224 connection response, (4) TLS handshake,
257+
// then leaves CredSSP to IronRDP client.
258+
// - Without PCB: In this case, X224 MUST be present! Gateway handles (1) X224 connection request, (2) X224 connection response, (3) TLS handshake, then leaves CredSSP to IronRDP client.
261259
match (&cleanpath_pdu.preconnection_blob, &cleanpath_pdu.x224_connection_pdu) {
262260
(None, None) => {
263261
return Err(CleanPathError::BadRequest(anyhow::anyhow!(
@@ -310,13 +308,13 @@ async fn process_cleanpath(
310308
target_server: selected_target.to_owned(),
311309
})?;
312310

313-
return Ok(CleanPathResult {
311+
Ok(CleanPathResult {
314312
destination: selected_target.to_owned(),
315313
claims,
316314
server_addr,
317315
server_stream,
318316
x224_rsp,
319-
});
317+
})
320318
}
321319

322320
#[allow(clippy::too_many_arguments)]
@@ -380,12 +378,8 @@ pub async fn handle(
380378

381379
trace!("Sending RDCleanPath response");
382380

383-
let rdcleanpath_rsp = RDCleanPathPdu::new_response(
384-
server_addr.to_string(),
385-
x224_rsp,
386-
x509_chain,
387-
)
388-
.map_err(|e| anyhow::anyhow!("couldn’t build RDCleanPath response: {e}"))?;
381+
let rdcleanpath_rsp = RDCleanPathPdu::new_response(server_addr.to_string(), x224_rsp, x509_chain)
382+
.context("couldn’t build RDCleanPath response")?;
389383

390384
send_clean_path_response(&mut client_stream, &rdcleanpath_rsp).await?;
391385

@@ -504,7 +498,7 @@ enum WsaError {
504498
WSAESTALE = 10070,
505499
WSAEREMOTE = 10071,
506500
WSASYSNOTREADY = 10091,
507-
WSAVERNOTSUPPORTED = 10092,
501+
WSAVERNOT_SUPPORTED = 10092,
508502
WSANOTINITIALISED = 10093,
509503
WSAEDISCON = 10101,
510504
WSAENOMORE = 10102,

devolutions-gateway/src/tls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn build_server_config(cert_source: CertificateSource) -> anyhow::Result<rus
7676
} => {
7777
let first_certificate = certificates.first().context("empty certificate list")?;
7878

79-
if let Ok(report) = check_certificate_now(&first_certificate) {
79+
if let Ok(report) = check_certificate_now(first_certificate) {
8080
if report.issues.intersects(
8181
CertIssues::MISSING_SERVER_AUTH_EXTENDED_KEY_USAGE | CertIssues::MISSING_SUBJECT_ALT_NAME,
8282
) {

jetsocat/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ impl CommonArgs {
463463
let pid = u32::try_from(process_id).context("invalid value for process ID")?;
464464
Some(sysinfo::Pid::from_u32(pid))
465465
} else if c.bool_flag("watch-parent") {
466-
use sysinfo::{ProcessRefreshKind, RefreshKind, System};
466+
use sysinfo::System;
467467

468468
// Find current process' parent process ID
469469
let current_pid =
@@ -850,7 +850,7 @@ fn clean_old_log_files(logging: &Logging) -> anyhow::Result<()> {
850850
match entry
851851
.metadata()
852852
.and_then(|metadata| metadata.modified())
853-
.and_then(|time| time.elapsed().map_err(|e| io::Error::new(io::ErrorKind::Other, e)))
853+
.and_then(|time| time.elapsed().map_err(io::Error::other))
854854
{
855855
Ok(modified) if modified > MAX_AGE => {
856856
info!("Delete log file");

0 commit comments

Comments
 (0)