Fix Telnet
This commit is contained in:
@@ -158,33 +158,33 @@ class Parser {
|
|||||||
case cmdWill:
|
case cmdWill:
|
||||||
if (!oldVal) {
|
if (!oldVal) {
|
||||||
this.sendNego(cmdDo, option);
|
this.sendNego(cmdDo, option);
|
||||||
|
|
||||||
newVal(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newVal(true, cmdWill);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case cmdWont:
|
case cmdWont:
|
||||||
if (oldVal) {
|
if (oldVal) {
|
||||||
this.sendNego(cmdDont, option);
|
this.sendNego(cmdDont, option);
|
||||||
|
|
||||||
newVal(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newVal(false, cmdWont);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case cmdDo:
|
case cmdDo:
|
||||||
if (!oldVal) {
|
if (!oldVal) {
|
||||||
this.sendNego(cmdWill, option);
|
this.sendNego(cmdWill, option);
|
||||||
|
|
||||||
newVal(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newVal(true, cmdDo);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case cmdDont:
|
case cmdDont:
|
||||||
if (oldVal) {
|
if (oldVal) {
|
||||||
this.sendNego(cmdWont, option);
|
this.sendNego(cmdWont, option);
|
||||||
|
|
||||||
newVal(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newVal(false, cmdDont);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,18 +218,33 @@ class Parser {
|
|||||||
|
|
||||||
switch (o[0]) {
|
switch (o[0]) {
|
||||||
case optEcho:
|
case optEcho:
|
||||||
return this.handleOption(d[0], o[0], this.options.echoEnabled, d => {
|
return this.handleOption(
|
||||||
|
d[0],
|
||||||
|
o[0],
|
||||||
|
this.options.echoEnabled,
|
||||||
|
(d, action) => {
|
||||||
this.options.echoEnabled = d;
|
this.options.echoEnabled = d;
|
||||||
|
|
||||||
this.callbacks.setEcho(this.options.echoEnabled);
|
switch (action) {
|
||||||
});
|
case cmdWill:
|
||||||
|
case cmdDont:
|
||||||
|
this.callbacks.setEcho(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case cmdWont:
|
||||||
|
case cmdDo:
|
||||||
|
this.callbacks.setEcho(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
case optSuppressGoAhead:
|
case optSuppressGoAhead:
|
||||||
return this.handleOption(
|
return this.handleOption(
|
||||||
d[0],
|
d[0],
|
||||||
o[0],
|
o[0],
|
||||||
this.options.suppressGoAhead,
|
this.options.suppressGoAhead,
|
||||||
d => {
|
(d, _action) => {
|
||||||
this.options.suppressGoAhead = d;
|
this.options.suppressGoAhead = d;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -353,7 +368,7 @@ class Control {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
setEcho(newVal) {
|
setEcho(newVal) {
|
||||||
self.localEchoEnabled = !newVal;
|
self.localEchoEnabled = newVal;
|
||||||
},
|
},
|
||||||
getWindowDim() {
|
getWindowDim() {
|
||||||
return self.windowDim;
|
return self.windowDim;
|
||||||
@@ -364,7 +379,7 @@ class Control {
|
|||||||
let runWait = this.parser.run();
|
let runWait = this.parser.run();
|
||||||
|
|
||||||
data.events.place("inband", rd => {
|
data.events.place("inband", rd => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, _reject) => {
|
||||||
self.parser.feed(rd, () => {
|
self.parser.feed(rd, () => {
|
||||||
resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
@@ -410,18 +425,46 @@ class Control {
|
|||||||
this.enable = false;
|
this.enable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
retap(isOn) {}
|
retap(_isOn) {}
|
||||||
|
|
||||||
receive() {
|
receive() {
|
||||||
return this.subs.subscribe();
|
return this.subs.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchNextIAC(start, data) {
|
||||||
|
for (let i = start; i < data.length; i++) {
|
||||||
|
if (data[i] !== cmdIAC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
send(data) {
|
send(data) {
|
||||||
if (this.closed) {
|
if (this.closed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.sender(new TextEncoder("utf-8").encode(data));
|
let currentLen = 0;
|
||||||
|
const enc = new TextEncoder("utf-8").encode(data);
|
||||||
|
|
||||||
|
while (currentLen < enc.length) {
|
||||||
|
const iacPos = this.searchNextIAC(currentLen, enc);
|
||||||
|
|
||||||
|
if (iacPos < 0) {
|
||||||
|
this.sender(enc.slice(currentLen, enc.length));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sender(enc.slice(currentLen, iacPos + 1));
|
||||||
|
this.sender(enc.slice(iacPos, iacPos + 1));
|
||||||
|
|
||||||
|
currentLen = iacPos + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
color() {
|
color() {
|
||||||
|
|||||||
Reference in New Issue
Block a user