Compare commits
No commits in common. "2fa2bbc856c95164767453688b0994d287b9c8b2" and "df06b39e88d3e026f93a1ad2d3341ce59521b1f5" have entirely different histories.
2fa2bbc856
...
df06b39e88
21
index.js
21
index.js
@ -9,8 +9,6 @@ const port = process.argv[3] || 23;
|
|||||||
const hostname = process.argv[2] || (process.pkg ? "dom.ht-dev.de" : "localhost");
|
const hostname = process.argv[2] || (process.pkg ? "dom.ht-dev.de" : "localhost");
|
||||||
let delayMs = process.argv[4] || 100; // Command delay in milliseconds
|
let delayMs = process.argv[4] || 100; // Command delay in milliseconds
|
||||||
|
|
||||||
const advancedFeatures = false; // Enable advanced features
|
|
||||||
|
|
||||||
// Diffie-Hellman parameters
|
// Diffie-Hellman parameters
|
||||||
const keyCurve = "prime256v1"; // key exchange curve, make this negotiable in the future
|
const keyCurve = "prime256v1"; // key exchange curve, make this negotiable in the future
|
||||||
|
|
||||||
@ -26,7 +24,6 @@ class MemoryStream extends Transform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const writer = new MemoryStream();
|
const writer = new MemoryStream();
|
||||||
let initialized = false; // Initialization status, do not modify directly, runtime only
|
|
||||||
let encrypted = false; // Encryption status, do not modify directly, runtime only
|
let encrypted = false; // Encryption status, do not modify directly, runtime only
|
||||||
let privateKey; // Private key, do not modify directly, runtime only
|
let privateKey; // Private key, do not modify directly, runtime only
|
||||||
const key = createECDH(keyCurve);
|
const key = createECDH(keyCurve);
|
||||||
@ -158,7 +155,7 @@ process.stdin.on('data', async (key) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("data", (data) => {
|
socket.on("data", (data) => {
|
||||||
if (!encrypted || !initialized) {
|
if (!encrypted) {
|
||||||
if (data.equals(PAUSE)) {
|
if (data.equals(PAUSE)) {
|
||||||
process.stdin.pause();
|
process.stdin.pause();
|
||||||
} else if (data.equals(RESUME)) {
|
} else if (data.equals(RESUME)) {
|
||||||
@ -192,8 +189,6 @@ socket.on("data", (data) => {
|
|||||||
} else {
|
} else {
|
||||||
process.stdout.write(data);
|
process.stdout.write(data);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// decrypt data
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -208,22 +203,18 @@ socket.on("connect", async () => {
|
|||||||
await delay(delayMs);
|
await delay(delayMs);
|
||||||
socket.write(Buffer.concat([IAC, DO, ECHO])); // Echo
|
socket.write(Buffer.concat([IAC, DO, ECHO])); // Echo
|
||||||
await delay(delayMs);
|
await delay(delayMs);
|
||||||
if (advancedFeatures) {
|
socket.write(Buffer.concat([IAC, WILL, CUSTOM_CLIENT_INIT])); // Custom Client Initialization
|
||||||
socket.write(Buffer.concat([IAC, WILL, CUSTOM_CLIENT_INIT])); // Custom Client Initialization
|
await delay(delayMs);
|
||||||
await delay(delayMs);
|
// socket.write(Buffer.from([0x0d, 0x0a])); // Line Feed
|
||||||
}
|
|
||||||
socket.write(Buffer.from([0x0d, 0x0a])); // Line Feed
|
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
// increase delay for encryption
|
// increase delay for encryption
|
||||||
delayMs += 200;
|
delayMs += 500;
|
||||||
}
|
}
|
||||||
// from here on encryption is enabled, do not use socket.write() directly anymore
|
// from here on encryption is enabled, do not use socket.write() directly anymore
|
||||||
await delay(delayMs);
|
await delay(delayMs);
|
||||||
console.debug("Initialization complete");
|
|
||||||
initialized = true;
|
|
||||||
// initialization complete
|
// initialization complete
|
||||||
|
|
||||||
await send("help");
|
// await send("help");
|
||||||
await delay(500);
|
await delay(500);
|
||||||
process.stdout.write("\rCtrl+X for client side commands\r\nCtrl+C to exit, Ctrl+D to force close\r\n> ");
|
process.stdout.write("\rCtrl+X for client side commands\r\nCtrl+C to exit, Ctrl+D to force close\r\n> ");
|
||||||
process.stdin.resume(); // Resume input
|
process.stdin.resume(); // Resume input
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "telnet-client",
|
"name": "telnet-client",
|
||||||
"version": "0.0.2",
|
"version": "0.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "telnet-client",
|
"name": "telnet-client",
|
||||||
"version": "0.0.2",
|
"version": "0.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"telnet-client": "file:"
|
"telnet-client": "file:"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "telnet-client",
|
"name": "telnet-client",
|
||||||
"version": "0.0.2",
|
"version": "0.0.1",
|
||||||
"description": "To be used with HTDev BBS Server for encrypted communication and extended functionality.",
|
"description": "To be used with HTDev BBS Server for encrypted communication and extended functionality.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": "index.js",
|
"bin": "index.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user