switched to sshwifty
This commit is contained in:
parent
d23d710e9c
commit
01f070337e
3 changed files with 1 additions and 90 deletions
|
@ -1,43 +0,0 @@
|
|||
const { spawn } = require("child_process");
|
||||
const pty = require("node-pty");
|
||||
|
||||
module.exports = (app) => {
|
||||
app.ws("/xterm/live", (ws) => {
|
||||
login(session);
|
||||
|
||||
function login(call) {
|
||||
let line = "";
|
||||
ws.send("username: ");
|
||||
ws.on("message", watch);
|
||||
function watch(data) {
|
||||
ws.send(data);
|
||||
if(data === "\r") {
|
||||
ws.send("\n");
|
||||
ws.off("message", watch);
|
||||
call(line);
|
||||
} else if(data === "\x7F") {
|
||||
if(line.length) ws.send("\x08 \x08");
|
||||
line = line.slice(0, -1);
|
||||
} else {
|
||||
line += data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function session(username) {
|
||||
if(!/^[a-z]+$/.test(username)) {
|
||||
ws.send("bad username\r\n\r\n");
|
||||
return login(session);
|
||||
}
|
||||
|
||||
const shell = pty.spawn("ssh", [`${username}@celery.eu.org`], {
|
||||
name: "xterm-color",
|
||||
cols: 80,
|
||||
rows: 26,
|
||||
});
|
||||
shell.on("data", d => ws.send(d))
|
||||
ws.on("message", d => shell.write(d));
|
||||
ws.on("close", () => shell.kill());
|
||||
}
|
||||
});
|
||||
}
|
|
@ -12,7 +12,6 @@
|
|||
"dotenv": "^16.0.0",
|
||||
"express": "^4.17.3",
|
||||
"express-ws": "^5.0.2",
|
||||
"git-http-backend": "^1.0.2",
|
||||
"highlight.js": "^11.5.1",
|
||||
"lru-cache": "^7.8.1",
|
||||
"markdown-it": "^12.3.2",
|
||||
|
@ -20,9 +19,6 @@
|
|||
"multer": "^1.4.4",
|
||||
"mustache": "^4.2.0",
|
||||
"mustache-express": "^1.3.2",
|
||||
"node-os-utils": "^1.3.6",
|
||||
"node-pty": "^0.10.1",
|
||||
"xterm": "^4.18.0",
|
||||
"xterm-addon-attach": "^0.6.0"
|
||||
"node-os-utils": "^1.3.6"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ specifiers:
|
|||
dotenv: ^16.0.0
|
||||
express: ^4.17.3
|
||||
express-ws: ^5.0.2
|
||||
git-http-backend: ^1.0.2
|
||||
highlight.js: ^11.5.1
|
||||
lru-cache: ^7.8.1
|
||||
markdown-it: ^12.3.2
|
||||
|
@ -13,15 +12,11 @@ specifiers:
|
|||
mustache: ^4.2.0
|
||||
mustache-express: ^1.3.2
|
||||
node-os-utils: ^1.3.6
|
||||
node-pty: ^0.10.1
|
||||
xterm: ^4.18.0
|
||||
xterm-addon-attach: ^0.6.0
|
||||
|
||||
dependencies:
|
||||
dotenv: 16.0.0
|
||||
express: 4.17.3
|
||||
express-ws: 5.0.2_express@4.17.3
|
||||
git-http-backend: 1.0.2
|
||||
highlight.js: 11.5.1
|
||||
lru-cache: 7.8.1
|
||||
markdown-it: 12.3.2
|
||||
|
@ -30,9 +25,6 @@ dependencies:
|
|||
mustache: 4.2.0
|
||||
mustache-express: 1.3.2
|
||||
node-os-utils: 1.3.6
|
||||
node-pty: 0.10.1
|
||||
xterm: 4.18.0
|
||||
xterm-addon-attach: 0.6.0_xterm@4.18.0
|
||||
|
||||
packages:
|
||||
|
||||
|
@ -250,17 +242,6 @@ packages:
|
|||
engines: {node: '>= 0.6'}
|
||||
dev: false
|
||||
|
||||
/git-http-backend/1.0.2:
|
||||
resolution: {integrity: sha1-3AHkKEIJNTBkRTpw+S+J3gg06xA=}
|
||||
dependencies:
|
||||
git-side-band-message: 0.0.3
|
||||
inherits: 2.0.4
|
||||
dev: false
|
||||
|
||||
/git-side-band-message/0.0.3:
|
||||
resolution: {integrity: sha1-uKU0jC3L8ZSf0pXFBgFOJsPyakY=}
|
||||
dev: false
|
||||
|
||||
/highlight.js/11.5.1:
|
||||
resolution: {integrity: sha512-LKzHqnxr4CrD2YsNoIf/o5nJ09j4yi/GcH5BnYz9UnVpZdS4ucMgvP61TDty5xJcFGRjnH4DpujkS9bHT3hq0Q==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
@ -421,10 +402,6 @@ packages:
|
|||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/nan/2.15.0:
|
||||
resolution: {integrity: sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==}
|
||||
dev: false
|
||||
|
||||
/negotiator/0.6.3:
|
||||
resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
@ -434,13 +411,6 @@ packages:
|
|||
resolution: {integrity: sha512-WympE9ELtdOzNak/rAuuIV5DwvX/PTJtN0LjyWeGyTTR2Kt0sY56ldLoGbVBnfM1dz46VeO3sHcNZI5BZ+EB+w==}
|
||||
dev: false
|
||||
|
||||
/node-pty/0.10.1:
|
||||
resolution: {integrity: sha512-JTdtUS0Im/yRsWJSx7yiW9rtpfmxqxolrtnyKwPLI+6XqTAPW/O2MjS8FYL4I5TsMbH2lVgDb2VMjp+9LoQGNg==}
|
||||
requiresBuild: true
|
||||
dependencies:
|
||||
nan: 2.15.0
|
||||
dev: false
|
||||
|
||||
/object-assign/4.1.1:
|
||||
resolution: {integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
@ -645,18 +615,6 @@ packages:
|
|||
engines: {node: '>=0.4'}
|
||||
dev: false
|
||||
|
||||
/xterm-addon-attach/0.6.0_xterm@4.18.0:
|
||||
resolution: {integrity: sha512-Mo8r3HTjI/EZfczVCwRU6jh438B4WLXxdFO86OB7bx0jGhwh2GdF4ifx/rP+OB+Cb2vmLhhVIZ00/7x3YSP3dg==}
|
||||
peerDependencies:
|
||||
xterm: ^4.0.0
|
||||
dependencies:
|
||||
xterm: 4.18.0
|
||||
dev: false
|
||||
|
||||
/xterm/4.18.0:
|
||||
resolution: {integrity: sha512-JQoc1S0dti6SQfI0bK1AZvGnAxH4MVw45ZPFSO6FHTInAiau3Ix77fSxNx3mX4eh9OL4AYa8+4C8f5UvnSfppQ==}
|
||||
dev: false
|
||||
|
||||
/yallist/3.1.1:
|
||||
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
|
||||
dev: false
|
||||
|
|
Loading…
Reference in a new issue