mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 22:44:55 +00:00
jump hosts
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import * as russh from 'russh'
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
||||
import colors from 'ansi-colors'
|
||||
import { Component, Injector, HostListener } from '@angular/core'
|
||||
@@ -94,17 +95,21 @@ export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile>
|
||||
}
|
||||
})
|
||||
|
||||
// session.jumpStream = await new Promise((resolve, reject) => jumpSession.ssh.forwardOut(
|
||||
// '127.0.0.1', 0, profile.options.host, profile.options.port ?? 22,
|
||||
// (err, stream) => {
|
||||
// if (err) {
|
||||
// jumpSession.emitServiceMessage(colors.bgRed.black(' X ') + ` Could not set up port forward on ${jumpConnection.name}`)
|
||||
// reject(err)
|
||||
// return
|
||||
// }
|
||||
// resolve(stream)
|
||||
// },
|
||||
// ))
|
||||
if (!(jumpSession.ssh instanceof russh.AuthenticatedSSHClient)) {
|
||||
throw new Error('Jump session is not authenticated yet somehow')
|
||||
}
|
||||
|
||||
try {
|
||||
session.jumpChannel = await jumpSession.ssh.openTCPForwardChannel({
|
||||
addressToConnectTo: profile.options.host,
|
||||
portToConnectTo: profile.options.port ?? 22,
|
||||
originatorAddress: '127.0.0.1',
|
||||
originatorPort: 0,
|
||||
})
|
||||
} catch (err) {
|
||||
jumpSession.emitServiceMessage(colors.bgRed.black(' X ') + ` Could not set up port forward on ${jumpConnection.name}`)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import { ConfigService, FileProvidersService, HostAppService, NotificationsServi
|
||||
import { Socket } from 'net'
|
||||
import { Subject, Observable } from 'rxjs'
|
||||
import { HostKeyPromptModalComponent } from '../components/hostKeyPromptModal.component'
|
||||
// import { HTTPProxyStream, ProxyCommandStream, SocksProxyStream } from '../services/ssh.service'
|
||||
// import { HTTPProxyStream, SocksProxyStream } from '../services/ssh.service'
|
||||
import { PasswordStorageService } from '../services/passwordStorage.service'
|
||||
import { SSHKnownHostsService } from '../services/sshKnownHosts.service'
|
||||
import { SFTPSession } from './sftp'
|
||||
@@ -64,7 +64,7 @@ export class SSHSession {
|
||||
ssh: russh.SSHClient|russh.AuthenticatedSSHClient
|
||||
sftp?: russh.SFTP
|
||||
forwardedPorts: ForwardedPort[] = []
|
||||
jumpStream: any
|
||||
jumpChannel: russh.Channel|null = null
|
||||
proxyCommandStream: SSHProxyStream|null = null
|
||||
savedPassword?: string
|
||||
get serviceMessage$ (): Observable<string> { return this.serviceMessage }
|
||||
@@ -225,6 +225,9 @@ export class SSHSession {
|
||||
// this.proxyCommandStream.message$.subscribe(message => {
|
||||
// this.emitServiceMessage(colors.bgBlue.black(' Proxy ') + ' ' + message.trim())
|
||||
// })
|
||||
} else if (this.jumpChannel) {
|
||||
transport = await russh.SshTransport.newSshChannel(await this.jumpChannel.take())
|
||||
this.jumpChannel = null
|
||||
} else {
|
||||
transport = await russh.SshTransport.newSocket(`${this.profile.options.host.trim()}:${this.profile.options.port ?? 22}`)
|
||||
}
|
||||
@@ -314,9 +317,6 @@ export class SSHSession {
|
||||
|
||||
|
||||
// ssh.connect({
|
||||
// host: this.profile.options.host.trim(),
|
||||
// port: this.profile.options.port ?? 22,
|
||||
// sock: this.proxyCommandStream?.socket ?? this.jumpStream,
|
||||
// agent: this.agentPath,
|
||||
// agentForward: this.profile.options.agentForward && !!this.agentPath,
|
||||
// keepaliveInterval: this.profile.options.keepaliveInterval ?? 15000,
|
||||
|
Reference in New Issue
Block a user