@@ -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 ,
0 commit comments