mirror of
https://github.com/ION606/web-to-fish.git
synced 2026-05-14 18:36:53 +00:00
removed extras
This commit is contained in:
@@ -1,7 +1,3 @@
|
|||||||
// file: index.js
|
|
||||||
// run: node index.js
|
|
||||||
// then open http://localhost:3000 in your browser
|
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
@@ -9,8 +5,8 @@ import session from 'express-session';
|
|||||||
import expressWs from 'express-ws';
|
import expressWs from 'express-ws';
|
||||||
import { spawn } from 'node-pty';
|
import { spawn } from 'node-pty';
|
||||||
import json from './secrets/config.json' with { type: 'json' };
|
import json from './secrets/config.json' with { type: 'json' };
|
||||||
import stripAnsi from 'strip-ansi';
|
|
||||||
|
|
||||||
|
// TODO: add web portal mirroring integration
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
@@ -32,9 +28,6 @@ app.use(express.urlencoded({ extended: true }));
|
|||||||
app.use(express.json({ extended: true }));
|
app.use(express.json({ extended: true }));
|
||||||
app.use('/node_modules', express.static('node_modules'));
|
app.use('/node_modules', express.static('node_modules'));
|
||||||
|
|
||||||
// simple hard-coded credentials (for demonstration)
|
|
||||||
const validUsername = 'user';
|
|
||||||
const validPassword = 'pass';
|
|
||||||
|
|
||||||
// authentication middleware
|
// authentication middleware
|
||||||
function requireAuth(req, res, next) {
|
function requireAuth(req, res, next) {
|
||||||
@@ -97,7 +90,7 @@ app.get('/logout', (req, res) => {
|
|||||||
|
|
||||||
// when a websocket is opened at /shell-ws, spawn a fish shell in a pty
|
// when a websocket is opened at /shell-ws, spawn a fish shell in a pty
|
||||||
app.ws('/shell-ws', (ws, req) => {
|
app.ws('/shell-ws', (ws, req) => {
|
||||||
// spawn a fish shell using node-pty, with a pseudo-terminal
|
// spawn a fish shell using node-pty with a pseudo-terminal
|
||||||
const shell = spawn('fish', [], {
|
const shell = spawn('fish', [], {
|
||||||
cols: 80,
|
cols: 80,
|
||||||
rows: 24,
|
rows: 24,
|
||||||
@@ -119,6 +112,4 @@ app.ws('/shell-ws', (ws, req) => {
|
|||||||
ws.on('close', () => shell.kill());
|
ws.on('close', () => shell.kill());
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => console.log('server listening on http://localhost:' + PORT));
|
||||||
console.log('server listening on http://localhost:' + PORT);
|
|
||||||
});
|
|
||||||
Generated
+1
-29
@@ -14,8 +14,7 @@
|
|||||||
"express": "^4.21.2",
|
"express": "^4.21.2",
|
||||||
"express-session": "^1.18.1",
|
"express-session": "^1.18.1",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"node-pty": "^1.0.0",
|
"node-pty": "^1.0.0"
|
||||||
"strip-ansi": "^7.1.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@xterm/addon-fit": {
|
"node_modules/@xterm/addon-fit": {
|
||||||
@@ -46,18 +45,6 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ansi-regex": {
|
|
||||||
"version": "6.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
|
|
||||||
"integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/array-flatten": {
|
"node_modules/array-flatten": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||||
@@ -947,21 +934,6 @@
|
|||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/strip-ansi": {
|
|
||||||
"version": "7.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
|
|
||||||
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-regex": "^6.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/toidentifier": {
|
"node_modules/toidentifier": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||||
|
|||||||
+1
-2
@@ -14,8 +14,7 @@
|
|||||||
"express": "^4.21.2",
|
"express": "^4.21.2",
|
||||||
"express-session": "^1.18.1",
|
"express-session": "^1.18.1",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"node-pty": "^1.0.0",
|
"node-pty": "^1.0.0"
|
||||||
"strip-ansi": "^7.1.0"
|
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user