telnetting works!

stable
Valerie 2021-12-12 23:57:14 -05:00
parent 6bee40d878
commit c23d25f5db
6 changed files with 37 additions and 32 deletions

View File

@ -16,7 +16,7 @@
"md5": "^2.3.0",
"serverline": "^1.5.0",
"ssh2": "^1.5.0",
"telnet": "^0.0.1",
"telnet": "git+https://github.com/TooTallNate/node-telnet.git#780340617e1f223de384cdfcb7cecf0a1a6f1159",
"ts-node": "^10.4.0",
"tsconfig-paths": "^3.12.0",
"typescript": "^4.5.3",

View File

@ -9,7 +9,7 @@ export default function ls(flags: any) {
console.log(
' '
+ autoColorString(k.substring(0, 4))
+ ':', JSON.stringify(v.config, null, 2).replace('\n', ' ').trim()
+ ':', JSON.stringify(v.config, null, 2).replace('\n', '\n ').trim()
);
}
}

1
src/externals.d.ts vendored
View File

@ -1,6 +1,7 @@
declare module "serverline";
declare module "telnet";
declare module "@kernel:base";
declare module "@kernel:log-hook";
declare module "@commands:executor";
declare module "@commands:create";
declare module "@commands:ls";

View File

@ -1,34 +1,33 @@
import telnet from 'telnet';
import { exec } from '@kernel:base';
import log from '@kernel:log-hook';
export default {
start() {
var telnet = require('telnet');
export function start() {
telnet.createServer(function (client: any) {
telnet.createServer(function (client: any) {
// make unicode characters work properly
client.do.transmit_binary()
// make unicode characters work properly
client.do.transmit_binary()
// make the client emit 'window size' events
client.do.window_size()
// make the client emit 'window size' events
client.do.window_size()
// listen for the window size events from the client
client.on('window size', function (e: any) {
if (e.command === 'sb') {
// console.log('telnet window resized to %d x %d', e.width, e.height)
}
})
// listen for the window size events from the client
client.on('window size', function (e: any) {
if (e.command === 'sb') {
console.log('telnet window resized to %d x %d', e.width, e.height)
}
})
console.log('Telnet client connected');
// listen for the actual data from the client
client.on('data', function (b: any) {
exec(b);
client.write(b)
})
// listen for the actual data from the client
client.on('data', function (b: any) {
exec(b.toString().trim());
})
client.write('connected to Telnet server!')
log.on('data', (e: any) => {
client.write(e)
})
}).listen(23)
}
}).listen(this.config.port ?? 2323)
}

View File

@ -7,7 +7,8 @@
"baseUrl": "./src",
"outDir": "./dist",
"declaration": true,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"target": "ESNext"
},
"paths": {
"@commands:executor": [""]

View File

@ -220,6 +220,10 @@ telnet@^0.0.1:
buffers "*"
debug "*"
"telnet@git+https://github.com/TooTallNate/node-telnet.git#780340617e1f223de384cdfcb7cecf0a1a6f1159":
version "0.0.1"
resolved "git+https://github.com/TooTallNate/node-telnet.git#780340617e1f223de384cdfcb7cecf0a1a6f1159"
"traverse@>=0.3.0 <0.4":
version "0.3.9"
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"