From f4172b60617156a7dcb0f4fcc6c41ff76a968d42 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Tue, 5 Jun 2018 19:51:04 +0200 Subject: [PATCH] Make createSocket also create "plain" connections (no proxying etc) --- src/manager.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/manager.ts b/src/manager.ts index 2e84daf..36584d8 100644 --- a/src/manager.ts +++ b/src/manager.ts @@ -1,6 +1,7 @@ import { readFile } from 'fs'; import { parse as parseJsonc, ParseError } from 'jsonc-parser'; +import { Socket } from 'net'; import * as path from 'path'; import { Client, ConnectConfig } from 'ssh2'; import * as vscode from 'vscode'; @@ -250,7 +251,7 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid if (config.password) config.agent = undefined; return config; } - public async createSocket(config: FileSystemConfig): Promise { + public async createSocket(config: FileSystemConfig): Promise { switch (config.proxy && config.proxy.type) { case null: case undefined: @@ -261,7 +262,11 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid default: throw new Error(`Unknown proxy method`); } - return null; + return new Promise((resolve, reject) => { + const socket = new Socket(); + socket.connect(config.port || 22, config.host, () => resolve(socket as NodeJS.ReadableStream)); + socket.once('error', reject); + }); } public async createFileSystem(name: string, config?: FileSystemConfig): Promise { if (name === '') return this.configFileSystem; @@ -355,7 +360,7 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid disp = fs.watch(uri, options).dispose.bind(fs); }).catch(console.error); return new vscode.Disposable(() => disp());*/ - return new vscode.Disposable(() => {}); + return new vscode.Disposable(() => { }); } public async stat(uri: vscode.Uri): Promise { return (await assertFs(this, uri)).stat(uri);