From 581d7a66c3ca5c1be78864f41fa171750d39437e Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 21 Aug 2024 20:38:19 +0200 Subject: [PATCH] proxy support --- app/package.json | 2 +- app/yarn.lock | 8 ++++---- tabby-ssh/src/session/ssh.ts | 29 ++++++++++++++++------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/package.json b/app/package.json index fb2b93fc..7d8981d0 100644 --- a/app/package.json +++ b/app/package.json @@ -30,7 +30,7 @@ "native-process-working-directory": "^1.0.2", "npm": "6", "rxjs": "^7.5.7", - "russh": "^0.0.1-alpha.12", + "russh": "^0.0.1-alpha.13", "source-map-support": "^0.5.20", "v8-compile-cache": "^2.3.0", "yargs": "^17.7.2" diff --git a/app/yarn.lock b/app/yarn.lock index d489bf22..79b054d1 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -3613,10 +3613,10 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -russh@^0.0.1-alpha.12: - version "0.0.1-alpha.12" - resolved "https://registry.yarnpkg.com/russh/-/russh-0.0.1-alpha.12.tgz#fc8d54870fef24ce8b5c33fb372199027c6572a2" - integrity sha512-nxfOSaa5V6+lutNwhLQuemIeAgzK8TXwOXcoEsvmd90dQ3TyrTUoNLOifbv5x0SYCg9dPRUP3OSwqnGPBhchug== +russh@^0.0.1-alpha.13: + version "0.0.1-alpha.13" + resolved "https://registry.yarnpkg.com/russh/-/russh-0.0.1-alpha.13.tgz#51664cd13951647d9377091a91d6d7c4a53e657a" + integrity sha512-jWSOorimRb232xma0M8Dm8sdkhfK61D1VWtdycjihVbU4UnTI3M1BMNGt9hyJAy1+dmLjgzW8vpJVrNBI7EpOw== dependencies: "@napi-rs/cli" "^2.18.3" diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index eb64f381..51be7768 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -254,6 +254,22 @@ export class SSHSession { } else if (this.jumpChannel) { transport = await russh.SshTransport.newSshChannel(await this.jumpChannel.take()) this.jumpChannel = null + } else if (this.profile.options.socksProxyHost) { + this.emitServiceMessage(colors.bgBlue.black(' Proxy ') + ` Using ${this.profile.options.socksProxyHost}:${this.profile.options.socksProxyPort}`) + transport = await russh.SshTransport.newSocksProxy( + this.profile.options.socksProxyHost, + this.profile.options.socksProxyPort ?? 1080, + this.profile.options.host, + this.profile.options.port ?? 22, + ) + } else if (this.profile.options.httpProxyHost) { + this.emitServiceMessage(colors.bgBlue.black(' Proxy ') + ` Using ${this.profile.options.httpProxyHost}:${this.profile.options.httpProxyPort}`) + transport = await russh.SshTransport.newHttpProxy( + this.profile.options.httpProxyHost, + this.profile.options.httpProxyPort ?? 8080, + this.profile.options.host, + this.profile.options.port ?? 22, + ) } else { transport = await russh.SshTransport.newSocket(`${this.profile.options.host.trim()}:${this.profile.options.port ?? 22}`) } @@ -329,19 +345,6 @@ export class SSHSession { } try { - // if (this.profile.options.socksProxyHost) { - // this.emitServiceMessage(colors.bgBlue.black(' Proxy ') + ` Using ${this.profile.options.socksProxyHost}:${this.profile.options.socksProxyPort}`) - // this.proxyCommandStream = new SocksProxyStream(this.profile) - // } - // if (this.profile.options.httpProxyHost) { - // this.emitServiceMessage(colors.bgBlue.black(' Proxy ') + ` Using ${this.profile.options.httpProxyHost}:${this.profile.options.httpProxyPort}`) - // this.proxyCommandStream = new HTTPProxyStream(this.profile) - // } - - // await this.proxyCommandStream.start() - // } - - // ssh.connect({ // keepaliveInterval: this.profile.options.keepaliveInterval ?? 15000, // keepaliveCountMax: this.profile.options.keepaliveCountMax,