mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-18 15:41:54 +03:00
automatically reconnect without x11 forwarding if rejected (fixes #1880)
This commit is contained in:
parent
5a9625424c
commit
0a451c5876
@ -1,6 +1,6 @@
|
|||||||
import { BaseSession } from 'terminus-terminal'
|
import { BaseSession } from 'terminus-terminal'
|
||||||
import { Server, Socket, createServer, createConnection } from 'net'
|
import { Server, Socket, createServer, createConnection } from 'net'
|
||||||
import { Client, ClientChannel } from 'ssh2'
|
import { Client, ClientChannel, Channel } from 'ssh2'
|
||||||
import { Logger } from 'terminus-core'
|
import { Logger } from 'terminus-core'
|
||||||
import { Subject, Observable } from 'rxjs'
|
import { Subject, Observable } from 'rxjs'
|
||||||
|
|
||||||
@ -84,19 +84,35 @@ export class SSHSession extends BaseSession {
|
|||||||
this.scripts = connection.scripts || []
|
this.scripts = connection.scripts || []
|
||||||
}
|
}
|
||||||
|
|
||||||
async start () {
|
private openShellChannel (options): Promise<ClientChannel> {
|
||||||
this.open = true
|
return new Promise<ClientChannel>((resolve, reject) => {
|
||||||
|
this.ssh.shell({ term: 'xterm-256color' }, options, (err, shell) => {
|
||||||
this.shell = await new Promise<ClientChannel>((resolve, reject) => {
|
|
||||||
this.ssh.shell({ term: 'xterm-256color' }, { x11: true }, (err, shell) => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
this.emitServiceMessage(`Remote rejected opening a shell channel: ${err}`)
|
|
||||||
reject(err)
|
reject(err)
|
||||||
} else {
|
} else {
|
||||||
resolve(shell)
|
resolve(shell)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async start () {
|
||||||
|
this.open = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
this.shell = await this.openShellChannel({ x11: true })
|
||||||
|
} catch (e) {
|
||||||
|
if (e.toString().includes('Unable to request X11')) {
|
||||||
|
this.logger.debug('X11 forwarding rejected, trying without')
|
||||||
|
this.shell = await this.openShellChannel({})
|
||||||
|
} else {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.emitServiceMessage(`Remote rejected opening a shell channel: ${err}`)
|
||||||
|
}
|
||||||
|
|
||||||
this.shell.on('greeting', greeting => {
|
this.shell.on('greeting', greeting => {
|
||||||
this.emitServiceMessage(`Shell greeting: ${greeting}`)
|
this.emitServiceMessage(`Shell greeting: ${greeting}`)
|
||||||
|
Loading…
Reference in New Issue
Block a user