@@ -467,20 +467,25 @@ export class Remote {
467467    // "Host not found". 
468468    try  { 
469469      this . storage . writeToCoderOutputChannel ( "Updating SSH config..." ) 
470-       await  this . updateSSHConfig ( workspaceRestClient ,  parts . label ,  parts . host ,  binaryPath ,  logDir ) 
470+       await  this . updateSSHConfig ( workspaceRestClient ,  parts . label ,  parts . host ,  binaryPath ,  logDir ,   featureSet ) 
471471    }  catch  ( error )  { 
472472      this . storage . writeToCoderOutputChannel ( `Failed to configure SSH: ${ error }  ) 
473473      throw  error 
474474    } 
475475
476476    // TODO: This needs to be reworked; it fails to pick up reconnects. 
477-     this . findSSHProcessID ( ) . then ( ( pid )  =>  { 
477+     this . findSSHProcessID ( ) . then ( async   ( pid )  =>  { 
478478      if  ( ! pid )  { 
479479        // TODO: Show an error here! 
480480        return 
481481      } 
482482      disposables . push ( this . showNetworkUpdates ( pid ) ) 
483-       this . commands . workspaceLogPath  =  logDir  ? path . join ( logDir ,  `${ pid }  )  : undefined 
483+       if  ( logDir )  { 
484+         const  logFiles  =  await  fs . readdir ( logDir ) 
485+         this . commands . workspaceLogPath  =  logFiles . find ( ( file )  =>  file . endsWith ( `${ pid }  ) ) 
486+       }  else  { 
487+         this . commands . workspaceLogPath  =  undefined 
488+       } 
484489    } ) 
485490
486491    // Register the label formatter again because SSH overrides it! 
@@ -532,7 +537,14 @@ export class Remote {
532537
533538  // updateSSHConfig updates the SSH configuration with a wildcard that handles 
534539  // all Coder entries. 
535-   private  async  updateSSHConfig ( restClient : Api ,  label : string ,  hostName : string ,  binaryPath : string ,  logDir : string )  { 
540+   private  async  updateSSHConfig ( 
541+     restClient : Api , 
542+     label : string , 
543+     hostName : string , 
544+     binaryPath : string , 
545+     logDir : string , 
546+     featureSet : FeatureSet , 
547+   )  { 
536548    let  deploymentSSHConfig  =  { } 
537549    try  { 
538550      const  deploymentConfig  =  await  restClient . getDeploymentSSHConfig ( ) 
@@ -610,13 +622,21 @@ export class Remote {
610622      headerArg  =  ` --header-command ${ escapeSubcommand ( headerCommand ) }  
611623    } 
612624
625+     const  hostPrefix  =  label  ? `${ AuthorityPrefix } ${ label }   : `${ AuthorityPrefix }  
626+ 
627+     const  proxyCommand  =  featureSet . wildcardSSH 
628+       ? `${ escape ( binaryPath ) } ${ headerArg } ${ escape (  
629+           path . dirname ( this . storage . getSessionTokenPath ( label ) ) ,  
630+         ) }   ssh --stdio --network-info-dir ${ escape ( this . storage . getNetworkInfoPath ( ) ) } ${ await  this . formatLogArg ( logDir ) } ${ hostPrefix } 
631+       : `${ escape ( binaryPath ) } ${ headerArg } ${ escape (  
632+           this . storage . getNetworkInfoPath ( ) ,  
633+         ) }  ${ await  this . formatLogArg ( logDir ) } ${ escape ( this . storage . getSessionTokenPath ( label ) ) } ${ escape ( 
634+           this . storage . getUrlPath ( label ) ,  
635+         ) }   %h`
636+ 
613637    const  sshValues : SSHValues  =  { 
614-       Host : label  ? `${ AuthorityPrefix } ${ label }   : `${ AuthorityPrefix }  , 
615-       ProxyCommand : `${ escape ( binaryPath ) } ${ headerArg } ${ escape (  
616-         this . storage . getNetworkInfoPath ( ) ,  
617-       ) }  ${ await  this . formatLogArg ( logDir ) } ${ escape ( this . storage . getSessionTokenPath ( label ) ) } ${ escape ( 
618-         this . storage . getUrlPath ( label ) ,  
619-       ) }   %h`, 
638+       Host : hostPrefix  +  `*` , 
639+       ProxyCommand : proxyCommand , 
620640      ConnectTimeout : "0" , 
621641      StrictHostKeyChecking : "no" , 
622642      UserKnownHostsFile : "/dev/null" , 
0 commit comments