Skip to content

Commit

Permalink
Stop local echo when remote echo is on
Browse files Browse the repository at this point in the history
  • Loading branch information
DehanLUO committed Jul 10, 2023
1 parent 77b74ad commit 9a82c4c
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions tabby-telnet/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class TelnetSession extends BaseSession {
private lastWidth = 0
private lastHeight = 0
private requestedOptions = new Set<number>()
private telnetRemoteEcho = false

constructor (
injector: Injector,
Expand Down Expand Up @@ -159,7 +160,7 @@ export class TelnetSession extends BaseSession {
data = data.slice(3)
this.logger.debug('<', commandName || command, optionName || option)

if (command === TelnetCommands.WILL || command === TelnetCommands.WONT) {
if (command === TelnetCommands.WILL || command === TelnetCommands.WONT || command === TelnetCommands.DONT) {
if (this.requestedOptions.has(option)) {
this.requestedOptions.delete(option)
continue
Expand All @@ -172,6 +173,11 @@ export class TelnetSession extends BaseSession {
TelnetOptions.ECHO,
].includes(option)) {
this.emitTelnet(TelnetCommands.DO, option)
if (option === TelnetOptions.ECHO && this.streamProcessor.forceEcho) {
this.telnetRemoteEcho = true;

Check failure on line 177 in tabby-telnet/src/session.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
this.streamProcessor.forceEcho = false;

Check failure on line 178 in tabby-telnet/src/session.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
this.requestOption(TelnetCommands.WONT, option);

Check failure on line 179 in tabby-telnet/src/session.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
}
} else {
this.logger.debug('(!) Unhandled option')
this.emitTelnet(TelnetCommands.DONT, option)
Expand All @@ -182,8 +188,13 @@ export class TelnetSession extends BaseSession {
this.emitTelnet(TelnetCommands.WILL, option)
this.emitSize()
} else if (option === TelnetOptions.ECHO) {
this.streamProcessor.forceEcho = true
this.emitTelnet(TelnetCommands.WILL, option)
if (this.telnetRemoteEcho) {
this.streamProcessor.forceEcho = false;

Check failure on line 192 in tabby-telnet/src/session.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
this.emitTelnet(TelnetCommands.WONT, option)
} else {
this.streamProcessor.forceEcho = true
this.emitTelnet(TelnetCommands.WILL, option)
}
} else if (option === TelnetOptions.TERMINAL_TYPE) {
this.emitTelnet(TelnetCommands.WILL, option)
} else {
Expand All @@ -197,7 +208,16 @@ export class TelnetSession extends BaseSession {
this.emitTelnet(TelnetCommands.WONT, option)
} else {
this.logger.debug('(!) Unhandled option')
this.emitTelnet(TelnetCommands.WILL, option)
this.emitTelnet(TelnetCommands.WONT, option)
}
}
if (command === TelnetCommands.WONT) {
if (option === TelnetOptions.ECHO) {
this.telnetRemoteEcho = false;

Check failure on line 216 in tabby-telnet/src/session.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
this.emitTelnet(TelnetCommands.DONT, option)
} else {
this.logger.debug('(!) Unhandled option')
this.emitTelnet(TelnetCommands.DONT, option)
}
}
if (command === TelnetCommands.SUBOPTION) {
Expand Down

0 comments on commit 9a82c4c

Please sign in to comment.