@@ -77,10 +77,7 @@ async fn read_cleanpath_pdu(mut stream: impl AsyncRead + Unpin + Send) -> io::Re
77
77
std:: cmp:: Ordering :: Less => { }
78
78
std:: cmp:: Ordering :: Equal => break ,
79
79
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" ) ) ;
84
81
}
85
82
}
86
83
}
@@ -234,30 +231,31 @@ async fn process_cleanpath(
234
231
debug ! ( %selected_target, "Connected to destination server" ) ;
235
232
span. record ( "target" , selected_target. to_string ( ) ) ;
236
233
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.
238
236
//
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
+ // └─────────────────────── ┘ └── ─────────────────────────────────────────────────────────────┘
246
244
//
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
+ // └─────────────────────────────────────────────────────────────── ┘ └─ ──────────────────────┘
254
252
//
255
253
// 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.
261
259
match ( & cleanpath_pdu. preconnection_blob , & cleanpath_pdu. x224_connection_pdu ) {
262
260
( None , None ) => {
263
261
return Err ( CleanPathError :: BadRequest ( anyhow:: anyhow!(
@@ -310,13 +308,13 @@ async fn process_cleanpath(
310
308
target_server : selected_target. to_owned ( ) ,
311
309
} ) ?;
312
310
313
- return Ok ( CleanPathResult {
311
+ Ok ( CleanPathResult {
314
312
destination : selected_target. to_owned ( ) ,
315
313
claims,
316
314
server_addr,
317
315
server_stream,
318
316
x224_rsp,
319
- } ) ;
317
+ } )
320
318
}
321
319
322
320
#[ allow( clippy:: too_many_arguments) ]
@@ -380,12 +378,8 @@ pub async fn handle(
380
378
381
379
trace ! ( "Sending RDCleanPath response" ) ;
382
380
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" ) ?;
389
383
390
384
send_clean_path_response ( & mut client_stream, & rdcleanpath_rsp) . await ?;
391
385
@@ -504,7 +498,7 @@ enum WsaError {
504
498
WSAESTALE = 10070 ,
505
499
WSAEREMOTE = 10071 ,
506
500
WSASYSNOTREADY = 10091 ,
507
- WSAVERNOTSUPPORTED = 10092 ,
501
+ WSAVERNOT_SUPPORTED = 10092 ,
508
502
WSANOTINITIALISED = 10093 ,
509
503
WSAEDISCON = 10101 ,
510
504
WSAENOMORE = 10102 ,
0 commit comments