Skip to content

Commit 7b25ff0

Browse files
mustard-mhjeanp413
andauthored
Use ssh proxy command instead of daemon IDE-72 (#57)
Co-authored-by: Jean Pierre <[email protected]>
1 parent 0bfb623 commit 7b25ff0

27 files changed

+881
-2420
lines changed

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@
142142
"proto-gen": "cd ./src/proto && buf lint && buf generate"
143143
},
144144
"devDependencies": {
145+
"@bufbuild/buf": "^1.15.0-1",
145146
"@types/google-protobuf": "^3.7.4",
146147
"@types/js-yaml": "^4.0.5",
147148
"@types/mocha": "^9.1.1",
148149
"@types/node": "16.x",
149150
"@types/ps-node": "^0.1.1",
150151
"@types/semver": "^7.3.10",
151152
"@types/ssh2": "^0.5.52",
152-
"@types/sshpk": "^1.17.1",
153153
"@types/tmp": "^0.2.1",
154154
"@types/uuid": "8.0.0",
155155
"@types/vscode": "1.74.0",
@@ -159,6 +159,7 @@
159159
"@typescript-eslint/eslint-plugin": "^5.19.0",
160160
"@typescript-eslint/parser": "^5.19.0",
161161
"@vscode/vsce": "^2.18.0",
162+
"copy-webpack-plugin": "^11.0.0",
162163
"eslint": "^8.13.0",
163164
"eslint-plugin-header": "3.1.1",
164165
"eslint-plugin-jsdoc": "^19.1.0",
@@ -169,8 +170,7 @@
169170
"ts-proto": "^1.140.0",
170171
"typescript": "^4.6.3",
171172
"webpack": "^5.42.0",
172-
"webpack-cli": "^4.7.2",
173-
"@bufbuild/buf": "^1.15.0-1"
173+
"webpack-cli": "^4.7.2"
174174
},
175175
"dependencies": {
176176
"@bufbuild/connect-node": "^0.8.4",
@@ -180,9 +180,9 @@
180180
"@gitpod/supervisor-api-grpc": "0.1.5-main.6711",
181181
"@grpc/grpc-js": "^1.8.8",
182182
"@improbable-eng/grpc-web-node-http-transport": "^0.14.0",
183-
"@microsoft/dev-tunnels-ssh": "^3.11.2",
184-
"@microsoft/dev-tunnels-ssh-keys": "^3.11.2",
185-
"@microsoft/dev-tunnels-ssh-tcp": "^3.11.2",
183+
"@microsoft/dev-tunnels-ssh": "^3.11.8",
184+
"@microsoft/dev-tunnels-ssh-keys": "^3.11.8",
185+
"@microsoft/dev-tunnels-ssh-tcp": "^3.11.8",
186186
"@segment/analytics-node": "^1.0.0-beta.24",
187187
"configcat-node": "^8.0.0",
188188
"js-yaml": "^4.1.0",
@@ -197,10 +197,8 @@
197197
"semver": "^7.3.7",
198198
"ssh-config": "^4.1.6",
199199
"ssh2": "^1.10.0",
200-
"sshpk": "^1.17.0",
201200
"tmp": "^0.2.1",
202201
"uuid": "8.1.0",
203-
"winston": "^3.8.2",
204202
"ws": "^8.13.0",
205203
"yazl": "^2.5.1"
206204
}

src/commands/logs.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Command } from '../commandManager';
1212
import { ILogService } from '../services/logService';
1313
import { INotificationService } from '../services/notificationService';
1414
import { ITelemetryService, UserFlowTelemetry } from '../services/telemetryService';
15-
import { Configuration } from '../configuration';
1615
import { HostService } from '../services/hostService';
1716

1817
interface IFile {
@@ -86,18 +85,7 @@ export class ExportLogsCommand implements Command {
8685
return;
8786
}
8887

89-
const daemonLogs: IFile[] = [];
90-
91-
const daemonPath = path.posix.join('./lssh', 'daemon.log');
92-
const daemonLogContent = await vscode.workspace.fs.readFile(vscode.Uri.file(Configuration.getDaemonLogPath()));
93-
if (daemonLogContent.byteLength > 0) {
94-
daemonLogs.push({
95-
path: daemonPath,
96-
contents: Buffer.from(daemonLogContent)
97-
});
98-
}
99-
100-
return zip(saveUri.fsPath, remoteLogFiles.concat(localLogFiles).concat(daemonLogs));
88+
return zip(saveUri.fsPath, remoteLogFiles.concat(localLogFiles));
10189
});
10290
}
10391
}

src/common/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,3 @@ export function arrayEquals<T>(one: ReadonlyArray<T> | undefined, other: Readonl
124124
export function getServiceURL(gitpodHost: string): string {
125125
return new URL(gitpodHost).toString().replace(/\/$/, '');
126126
}
127-
128-
export function getLocalSSHUrl(gitpodHost: string): string {
129-
return 'lssh.' + (new URL(gitpodHost)).hostname;
130-
}

src/configuration.ts

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { tmpdir } from 'os';
7-
import { join } from 'path';
86
import * as vscode from 'vscode';
97

108
// Use these functions instead of `vscode.workspace.getConfiguration` API
@@ -22,40 +20,16 @@ function getUseLocalApp(useLocalSSHServer?: boolean) {
2220
return vscode.workspace.getConfiguration('gitpod').get<boolean>('remote.useLocalApp', false);
2321
}
2422

25-
function getLocalSSHServerPort() {
26-
// TODO(local-ssh): VSCodium?
27-
// use `sudo lsof -i:<port>` to check if the port is already in use
28-
let defaultPort = 42025;
23+
function getLocalSshExtensionIpcPort() {
24+
let defaultPort = 43025;
2925
if (vscode.env.appName.includes('Insiders')) {
30-
defaultPort = 42026;
26+
defaultPort = 43026;
3127
}
32-
return vscode.workspace.getConfiguration('gitpod').get<number>('lsshPort', defaultPort) || defaultPort;
33-
}
34-
35-
function getLocalSshIpcPort() {
36-
let defaultPort = 41025;
37-
if (vscode.env.appName.includes('Insiders')) {
38-
defaultPort = 41026;
39-
}
40-
return vscode.workspace.getConfiguration('gitpod').get<number>('lsshIpcPort', defaultPort) || defaultPort;
41-
}
42-
43-
function getDaemonLogFileName(): string {
44-
if (vscode.env.appName.includes('Insiders')) {
45-
return 'gitpod-vscode-daemon-insiders.log';
46-
}
47-
return 'gitpod-vscode-daemon.log';
48-
}
49-
50-
function getDaemonLogPath(): string {
51-
return join(tmpdir(), getDaemonLogFileName());
28+
return vscode.workspace.getConfiguration('gitpod').get<number>('lsshExtensionIpcPort', defaultPort) || defaultPort;
5229
}
5330

5431
export const Configuration = {
5532
getGitpodHost,
5633
getUseLocalApp,
57-
getLocalSSHServerPort,
58-
getLocalSshIpcPort,
59-
getDaemonLogPath,
60-
getDaemonLogFileName,
34+
getLocalSshExtensionIpcPort,
6135
};

src/daemonStarter.ts

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/extension.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import { SessionService } from './services/sessionService';
2020
import { CommandManager } from './commandManager';
2121
import { SignInCommand } from './commands/account';
2222
import { ExportLogsCommand } from './commands/logs';
23-
import { ensureDaemonStarted } from './daemonStarter';
24-
import { ExtensionServiceServer } from './local-ssh/ipc/extension';
2523
import { Configuration } from './configuration';
24+
import { LocalSSHService } from './services/localSSHService';
2625

2726
// connect-web uses fetch api, so we need to polyfill it
2827
if (!global.fetch) {
@@ -73,6 +72,9 @@ export async function activate(context: vscode.ExtensionContext) {
7372
hostService = new HostService(context, notificationService, logger);
7473
context.subscriptions.push(hostService);
7574

75+
const localSSHService = new LocalSSHService(context, hostService, logger);
76+
context.subscriptions.push(localSSHService);
77+
7678
const sessionService = new SessionService(hostService, logger);
7779
context.subscriptions.push(sessionService);
7880

@@ -82,12 +84,9 @@ export async function activate(context: vscode.ExtensionContext) {
8284
const settingsSync = new SettingsSync(commandManager, logger, telemetryService, notificationService);
8385
context.subscriptions.push(settingsSync);
8486

85-
const remoteConnector = new RemoteConnector(context, sessionService, hostService, experiments, logger, telemetryService, notificationService);
87+
const remoteConnector = new RemoteConnector(context, sessionService, hostService, experiments, logger, telemetryService, notificationService, localSSHService);
8688
context.subscriptions.push(remoteConnector);
8789

88-
const extensionIPCService = new ExtensionServiceServer(logger, sessionService, hostService, telemetryService, experiments);
89-
context.subscriptions.push(extensionIPCService);
90-
9190
context.subscriptions.push(vscode.window.registerUriHandler({
9291
handleUri(uri: vscode.Uri) {
9392
// logger.trace('Handling Uri...', uri.toString());
@@ -103,8 +102,6 @@ export async function activate(context: vscode.ExtensionContext) {
103102
commandManager.register(new SignInCommand(sessionService));
104103
commandManager.register(new ExportLogsCommand(context.logUri, notificationService, telemetryService, logger, hostService));
105104

106-
ensureDaemonStarted(logger, telemetryService, 3).then(() => { }).catch(e => { logger?.error(e); });
107-
108105
if (!context.globalState.get<boolean>(FIRST_INSTALL_KEY, false)) {
109106
context.globalState.update(FIRST_INSTALL_KEY, true);
110107
telemetryService.sendTelemetryEvent(hostService.gitpodHost, 'gitpod_desktop_installation', { kind: 'install' });

src/local-ssh/common.ts

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)