@@ -6,6 +6,7 @@ import * as ipc from "../../lib/vscode/src/vs/server/ipc"
66import { arrayify , generateUuid } from "../common/util"
77import { rootPath } from "./constants"
88import { settings } from "./settings"
9+ import { SocketProxyProvider } from "./socket"
910import { isFile } from "./util"
1011import { ipcMain } from "./wrapper"
1112
@@ -14,6 +15,7 @@ export class VscodeProvider {
1415 public readonly vsRootPath : string
1516 private _vscode ?: Promise < cp . ChildProcess >
1617 private timeoutInterval = 10000 // 10s, matches VS Code's timeouts.
18+ private readonly socketProvider = new SocketProxyProvider ( )
1719
1820 public constructor ( ) {
1921 this . vsRootPath = path . resolve ( rootPath , "lib/vscode" )
@@ -22,6 +24,7 @@ export class VscodeProvider {
2224 }
2325
2426 public async dispose ( ) : Promise < void > {
27+ this . socketProvider . stop ( )
2528 if ( this . _vscode ) {
2629 const vscode = await this . _vscode
2730 vscode . removeAllListeners ( )
@@ -152,9 +155,11 @@ export class VscodeProvider {
152155 * VS Code expects a raw socket. It will handle all the web socket frames.
153156 */
154157 public async sendWebsocket ( socket : net . Socket , query : ipc . Query ) : Promise < void > {
155- // TODO: TLS socket proxy.
156158 const vscode = await this . _vscode
157- this . send ( { type : "socket" , query } , vscode , socket )
159+ // TLS sockets cannot be transferred to child processes so we need an
160+ // in-between. Non-TLS sockets will be returned as-is.
161+ const socketProxy = await this . socketProvider . createProxy ( socket )
162+ this . send ( { type : "socket" , query } , vscode , socketProxy )
158163 }
159164
160165 private send ( message : ipc . CodeServerMessage , vscode ?: cp . ChildProcess , socket ?: net . Socket ) : void {
0 commit comments