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", "md5": "^2.3.0",
"serverline": "^1.5.0", "serverline": "^1.5.0",
"ssh2": "^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", "ts-node": "^10.4.0",
"tsconfig-paths": "^3.12.0", "tsconfig-paths": "^3.12.0",
"typescript": "^4.5.3", "typescript": "^4.5.3",

View File

@ -9,7 +9,7 @@ export default function ls(flags: any) {
console.log( console.log(
' ' ' '
+ autoColorString(k.substring(0, 4)) + 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 "serverline";
declare module "telnet"; declare module "telnet";
declare module "@kernel:base"; declare module "@kernel:base";
declare module "@kernel:log-hook";
declare module "@commands:executor"; declare module "@commands:executor";
declare module "@commands:create"; declare module "@commands:create";
declare module "@commands:ls"; declare module "@commands:ls";

View File

@ -1,11 +1,8 @@
import telnet from 'telnet'; import telnet from 'telnet';
import { exec } from '@kernel:base'; import { exec } from '@kernel:base';
import log from '@kernel:log-hook';
export default { export function start() {
start() {
var telnet = require('telnet');
telnet.createServer(function (client: any) { telnet.createServer(function (client: any) {
// make unicode characters work properly // make unicode characters work properly
@ -17,18 +14,20 @@ export default {
// listen for the window size events from the client // listen for the window size events from the client
client.on('window size', function (e: any) { client.on('window size', function (e: any) {
if (e.command === 'sb') { if (e.command === 'sb') {
console.log('telnet window resized to %d x %d', e.width, e.height) // 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 // listen for the actual data from the client
client.on('data', function (b: any) { client.on('data', function (b: any) {
exec(b); exec(b.toString().trim());
client.write(b)
}) })
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", "baseUrl": "./src",
"outDir": "./dist", "outDir": "./dist",
"declaration": true, "declaration": true,
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true,
"target": "ESNext"
}, },
"paths": { "paths": {
"@commands:executor": [""] "@commands:executor": [""]

View File

@ -220,6 +220,10 @@ telnet@^0.0.1:
buffers "*" buffers "*"
debug "*" 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": "traverse@>=0.3.0 <0.4":
version "0.3.9" version "0.3.9"
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"