Initial commit

This commit is contained in:
2025-12-27 20:24:47 +01:00
commit 7b6f164130
5573 changed files with 727178 additions and 0 deletions

178
node_modules/telnet-stream/lib/telnetInput.js generated vendored Normal file
View File

@@ -0,0 +1,178 @@
// Generated by CoffeeScript 2.6.1
(function() {
// telnetInput.coffee
// Copyright 2017 Patrick Meade.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------
var DEFAULT_SUBNEGOTIATION_BUFFER_SIZE, DEFAULT_SUBNEGOTIATION_ERROR_POLICY, TELNET_COMMAND, TELNET_DATA, TELNET_DO, TELNET_DONT, TELNET_IAC, TELNET_OPTION, TELNET_SUBNEG, TELNET_SUBNEG_COMMAND, TELNET_SUB_BEGIN, TELNET_SUB_END, TELNET_WILL, TELNET_WONT, TelnetInput, Transform;
DEFAULT_SUBNEGOTIATION_BUFFER_SIZE = 8192;
DEFAULT_SUBNEGOTIATION_ERROR_POLICY = "keepBoth";
TELNET_COMMAND = "TELNET_COMMAND";
TELNET_DATA = "TELNET_DATA";
TELNET_OPTION = "TELNET_OPTION";
TELNET_SUBNEG = "TELNET_SUBNEG";
TELNET_SUBNEG_COMMAND = "TELNET_SUBNEG_COMMAND";
TELNET_DO = 253;
TELNET_DONT = 254;
TELNET_IAC = 255;
TELNET_SUB_BEGIN = 250;
TELNET_SUB_END = 240;
TELNET_WILL = 251;
TELNET_WONT = 252;
({Transform} = require("stream"));
TelnetInput = class TelnetInput extends Transform {
constructor(opt) {
var options;
options = opt || {};
super(options);
this.state = TELNET_DATA;
this.subBufSize = options.bufferSize || DEFAULT_SUBNEGOTIATION_BUFFER_SIZE;
this.subBuf = Buffer.alloc(this.subBufSize);
this.errorPolicy = options.errorPolicy || DEFAULT_SUBNEGOTIATION_ERROR_POLICY;
}
_transform(chunk, encoding, callback) {
var byte, i, len;
this.dataBuf = Buffer.alloc(chunk.length * 2);
this.dataBufIndex = 0;
for (i = 0, len = chunk.length; i < len; i++) {
byte = chunk[i];
this._handle(byte);
}
if (this.dataBufIndex > 0) {
this.push(this.dataBuf.slice(0, this.dataBufIndex));
}
return callback();
}
_handle(chunkData) {
switch (this.state) {
case TELNET_DATA:
switch (chunkData) {
case TELNET_IAC:
return this.state = TELNET_COMMAND;
default:
this.dataBuf[this.dataBufIndex] = chunkData;
return this.dataBufIndex++;
}
break;
case TELNET_COMMAND:
switch (chunkData) {
case TELNET_IAC:
this.state = TELNET_DATA;
this.dataBuf[this.dataBufIndex] = TELNET_IAC;
return this.dataBufIndex++;
case TELNET_DO:
case TELNET_DONT:
case TELNET_WILL:
case TELNET_WONT:
case TELNET_SUB_BEGIN:
this.state = TELNET_OPTION;
return this.command = chunkData;
default:
this.state = TELNET_DATA;
return this.emit("command", chunkData);
}
break;
case TELNET_OPTION:
switch (this.command) {
case TELNET_DO:
this.state = TELNET_DATA;
return this.emit("do", chunkData);
case TELNET_DONT:
this.state = TELNET_DATA;
return this.emit("dont", chunkData);
case TELNET_WILL:
this.state = TELNET_DATA;
return this.emit("will", chunkData);
case TELNET_WONT:
this.state = TELNET_DATA;
return this.emit("wont", chunkData);
case TELNET_SUB_BEGIN:
this.state = TELNET_SUBNEG;
this.option = chunkData;
this.subBufIndex = 0;
return this.subOverflowEmit = false;
}
break;
case TELNET_SUBNEG:
switch (chunkData) {
case TELNET_IAC:
return this.state = TELNET_SUBNEG_COMMAND;
default:
return this._handleSub(chunkData);
}
break;
case TELNET_SUBNEG_COMMAND:
switch (chunkData) {
case TELNET_IAC:
this.state = TELNET_SUBNEG;
return this._handleSub(TELNET_IAC);
case TELNET_SUB_END:
this.state = TELNET_DATA;
return this.emit("sub", this.option, this.subBuf.slice(0, this.subBufIndex));
default:
this.state = TELNET_SUBNEG;
this.emit("error", new Error("expected IAC or SE"));
switch (this.errorPolicy) {
case "discardBoth":
break;
case "keepData":
return this._handleSub(chunkData);
default:
// "keepBoth"
this._handleSub(TELNET_IAC);
return this._handleSub(chunkData);
}
}
}
}
_handleSub(subByte) {
if (this.subBufIndex >= this.subBufSize) {
if (!this.subOverflowEmit) {
this.subOverflowEmit = true;
this.emit("error", new Error("subnegotiation buffer overflow"));
}
return;
}
this.subBuf[this.subBufIndex] = subByte;
return this.subBufIndex++;
}
};
exports.TelnetInput = TelnetInput;
//----------------------------------------------------------------------------
// end of telnetInput.coffee
}).call(this);

117
node_modules/telnet-stream/lib/telnetOutput.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
// Generated by CoffeeScript 2.6.1
(function() {
// telnetOutput.coffee
// Copyright 2017 Patrick Meade.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------
var TELNET_DO, TELNET_DONT, TELNET_IAC, TELNET_SUB_BEGIN, TELNET_SUB_END, TELNET_WILL, TELNET_WONT, TelnetOutput, Transform;
TELNET_DO = 253;
TELNET_DONT = 254;
TELNET_IAC = 255;
TELNET_SUB_BEGIN = 250;
TELNET_SUB_END = 240;
TELNET_WILL = 251;
TELNET_WONT = 252;
({Transform} = require("stream"));
TelnetOutput = class TelnetOutput extends Transform {
constructor(options) {
super(options);
}
_transform(chunk, encoding, done) {
this.push(this._duplicateIAC(chunk));
return done();
}
_duplicateIAC(buffer) {
var byte, i, len, xlateBuf, xlateIndex;
xlateIndex = 0;
xlateBuf = Buffer.alloc(buffer.length * 2);
for (i = 0, len = buffer.length; i < len; i++) {
byte = buffer[i];
xlateBuf[xlateIndex] = byte;
xlateIndex++;
if (byte === TELNET_IAC) {
xlateBuf[xlateIndex] = byte;
xlateIndex++;
}
}
return xlateBuf.slice(0, xlateIndex);
}
_writeOption(command, option) {
var cmdBuf;
cmdBuf = Buffer.alloc(3);
cmdBuf[0] = TELNET_IAC;
cmdBuf[1] = command;
cmdBuf[2] = option;
return this.push(cmdBuf);
}
writeCommand(command) {
var cmdBuf;
cmdBuf = Buffer.alloc(2);
cmdBuf[0] = TELNET_IAC;
cmdBuf[1] = command;
return this.push(cmdBuf);
}
writeDo(option) {
return this._writeOption(TELNET_DO, option);
}
writeDont(option) {
return this._writeOption(TELNET_DONT, option);
}
writeSub(option, buffer) {
var negBuf, subBegin, subBuf, subEnd;
negBuf = this._duplicateIAC(buffer);
subBegin = Buffer.alloc(3);
subBegin[0] = TELNET_IAC;
subBegin[1] = TELNET_SUB_BEGIN;
subBegin[2] = option;
subEnd = Buffer.alloc(2);
subEnd[0] = TELNET_IAC;
subEnd[1] = TELNET_SUB_END;
subBuf = Buffer.concat([subBegin, negBuf, subEnd], negBuf.length + 5);
return this.push(subBuf);
}
writeWill(option) {
return this._writeOption(TELNET_WILL, option);
}
writeWont(option) {
return this._writeOption(TELNET_WONT, option);
}
};
exports.TelnetOutput = TelnetOutput;
//----------------------------------------------------------------------------
// end of telnetOutput.coffee
}).call(this);

137
node_modules/telnet-stream/lib/telnetSocket.js generated vendored Normal file
View File

@@ -0,0 +1,137 @@
// Generated by CoffeeScript 2.6.1
(function() {
// telnetSocket.coffee
// Copyright 2017 Patrick Meade.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------
var Socket, TelnetInput, TelnetOutput, TelnetSocket;
({Socket} = require("net"));
({TelnetInput, TelnetOutput} = require("./telnetStream"));
TelnetSocket = class TelnetSocket {
constructor(_socket, opt) {
var options;
this._socket = _socket;
if (!(this._socket instanceof Socket)) {
throw new Error("required: net.Socket");
}
options = opt || {};
this._in = new TelnetInput(options);
this._out = new TelnetOutput(options);
this._socket.pipe(this._in);
this._out.pipe(this._socket);
}
address() {
return this._socket.address.apply(this._socket, arguments);
}
connect() {
return this._socket.connect.apply(this._socket, arguments);
}
destroy() {
return this._socket.destroy.apply(this._socket, arguments);
}
end() {
return this._socket.end.apply(this._socket, arguments);
}
on(name, callback) {
switch (name) {
case "command":
case "data":
case "do":
case "dont":
case "sub":
case "will":
case "wont":
return this._in.on(name, callback);
default:
return this._socket.on(name, callback);
}
}
pause() {
return this._socket.pause.apply(this._socket, arguments);
}
ref() {
return this._socket.ref.apply(this._socket, arguments);
}
resume() {
return this._socket.resume.apply(this._socket, arguments);
}
setEncoding() {
return this._socket.setEncoding.apply(this._socket, arguments);
}
setKeepAlive() {
return this._socket.setKeepAlive.apply(this._socket, arguments);
}
setNoDelay() {
return this._socket.setNoDelay.apply(this._socket, arguments);
}
setTimeout() {
return this._socket.setTimeout.apply(this._socket, arguments);
}
unref() {
return this._socket.unref.apply(this._socket, arguments);
}
write() {
return this._out.write.apply(this._out, arguments);
}
writeCommand(command) {
return this._out.writeCommand(command);
}
writeDo(option) {
return this._out.writeDo(option);
}
writeDont(option) {
return this._out.writeDont(option);
}
writeSub(option, buffer) {
return this._out.writeSub(option, buffer);
}
writeWill(option) {
return this._out.writeWill(option);
}
writeWont(option) {
return this._out.writeWont(option);
}
};
exports.TelnetSocket = TelnetSocket;
//----------------------------------------------------------------------------
// end of telnetSocket.coffee
}).call(this);

28
node_modules/telnet-stream/lib/telnetStream.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
// Generated by CoffeeScript 2.6.1
(function() {
// telnetStream.coffee
// Copyright 2017 Patrick Meade.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------
exports.TelnetInput = require("./telnetInput").TelnetInput;
exports.TelnetOutput = require("./telnetOutput").TelnetOutput;
exports.TelnetSocket = require("./telnetSocket").TelnetSocket;
//----------------------------------------------------------------------------
// end of telnetStream.coffee
}).call(this);