This commit is contained in:
Alexander Dines 2024-09-04 15:33:02 -07:00
parent e4a152b5b3
commit 5d25216bf3
4 changed files with 1 additions and 270 deletions

View file

@ -1,75 +0,0 @@
{
"listen": {
"ip": "0.0.0.0",
"port": 2224
},
"socketio": {
"serveClient": false,
"path": "/ssh/socket.io",
"origins": ["localhost:2224"]
},
"user": {
"name": null,
"password": null,
"privatekey": null,
"overridebasic": false
},
"ssh": {
"host": null,
"port": 22,
"localAddress": null,
"localPort": null,
"term": "xterm-color",
"readyTimeout": 20000,
"keepaliveInterval": 120000,
"keepaliveCountMax": 10,
"allowedSubnets": []
},
"terminal": {
"cursorBlink": true,
"scrollback": 10000,
"tabStopWidth": 8,
"bellStyle": "sound",
"fontSize": 14
},
"header": {
"text": null,
"background": "green"
},
"session": {
"name": "WebSSH2",
"secret": "mysecret"
},
"options": {
"challengeButton": true,
"allowreauth": false
},
"algorithms": {
"kex": [
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha1"
],
"cipher": [
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"aes128-gcm",
"aes128-gcm@openssh.com",
"aes256-gcm",
"aes256-gcm@openssh.com",
"aes256-cbc"
],
"hmac": ["hmac-sha2-256", "hmac-sha2-512", "hmac-sha1"],
"compress": ["none", "zlib@openssh.com", "zlib"]
},
"serverlog": {
"client": false,
"server": false
},
"accesslog": false,
"verify": false,
"safeShutdownDuration": 300
}

View file

@ -1,83 +0,0 @@
{
"listen": {
"ip": "0.0.0.0",
"port": 2224
},
"socketio": {
"serveClient": false,
"path": "/ssh/socket.io",
"origins": ["localhost:2222"],
},
"user": {
"name": null,
"password": null,
"privatekey": null,
"overridebasic": false
},
"ssh": {
"host": null,
"port": 22,
"localAddress": null,
"localPort": null,
"term": "xterm-color",
"readyTimeout": 20000,
"keepaliveInterval": 120000,
"keepaliveCountMax": 10,
"allowedSubnets": []
},
"terminal": {
"cursorBlink": true,
"scrollback": 10000,
"tabStopWidth": 8,
"bellStyle": "sound",
"fontSize": 14
},
"header": {
"text": null,
"background": "green"
},
"session": {
"name": "WebSSH2",
"secret": "mysecret"
},
"options": {
"challengeButton": true,
"allowreauth": false
},
"algorithms": {
"kex": [
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha1"
],
"cipher": [
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"aes128-gcm",
"aes128-gcm@openssh.com",
"aes256-gcm",
"aes256-gcm@openssh.com",
"aes256-cbc"
],
"hmac": [
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-sha1"
],
"compress": [
"none",
"zlib@openssh.com",
"zlib"
]
},
"serverlog": {
"client": false,
"server": false
},
"accesslog": false,
"verify": false,
"safeShutdownDuration": 300
}

View file

@ -6,7 +6,6 @@ const { server } = require('./server/app');
server.listen({ host: config.listen.ip, port: config.listen.port }); server.listen({ host: config.listen.ip, port: config.listen.port });
// eslint-disable-next-line no-console
console.log(`WebSSH2 service listening on ${config.listen.ip}:${config.listen.port}`); console.log(`WebSSH2 service listening on ${config.listen.ip}:${config.listen.port}`);
server.on('error', (err) => { server.on('error', (err) => {

View file

@ -1,126 +1,19 @@
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }], /* eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }],
no-console: ["error", { allow: ["warn", "error", "info"] }] */ no-console: ["error", { allow: ["warn", "error", "info"] }] */
const fs = require('fs');
const path = require('path'); const path = require('path');
const debugWebSSH2 = require('debug')('WebSSH2');
const crypto = require('crypto'); const crypto = require('crypto');
const util = require('util');
const readconfig = require('read-config-ng');
const nodeRoot = path.dirname(require.main.filename); const nodeRoot = path.dirname(require.main.filename);
const configPath = path.join(nodeRoot, 'config.json');
let myConfig;
// establish defaults // establish defaults
const configDefault = { const configDefault = {
listen: { listen: {
ip: '0.0.0.0', ip: '0.0.0.0',
port: 2222, port: 2222,
}, },
socketio: {
serveClient: false,
path: '/ssh/socket.io',
origins: ['localhost:*'],
},
express: {
secret: crypto.randomBytes(20).toString('hex'),
name: 'WebSSH2',
resave: true,
saveUninitialized: false,
unset: 'destroy',
ssh: {
dotfiles: 'ignore',
etag: false,
extensions: ['htm', 'html'],
index: false,
maxAge: '1s',
redirect: false,
setHeaders(res) {
res.set('x-timestamp', Date.now());
},
},
},
user: {
name: null,
password: null,
privatekey: null,
overridebasic: false,
},
ssh: {
host: null,
port: 22,
term: 'xterm-color',
readyTimeout: 20000,
keepaliveInterval: 120000,
keepaliveCountMax: 10,
allowedSubnets: [],
},
terminal: {
cursorBlink: true,
scrollback: 10000,
tabStopWidth: 8,
bellStyle: 'sound',
},
header: {
text: null,
background: 'green',
},
options: {
challengeButton: true,
allowreauth: true,
},
algorithms: {
kex: [
'ecdh-sha2-nistp256',
'ecdh-sha2-nistp384',
'ecdh-sha2-nistp521',
'diffie-hellman-group-exchange-sha256',
'diffie-hellman-group14-sha1',
],
cipher: [
'aes128-ctr',
'aes192-ctr',
'aes256-ctr',
'aes128-gcm',
'aes128-gcm@openssh.com',
'aes256-gcm',
'aes256-gcm@openssh.com',
'aes256-cbc',
],
hmac: ['hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1'],
compress: ['none', 'zlib@openssh.com', 'zlib'],
},
serverlog: {
client: false,
server: false,
},
accesslog: false,
verify: false,
safeShutdownDuration: 300,
}; };
// test if config.json exists, if not provide error message but try to run anyway const config = configDefault;
try {
if (!fs.existsSync(configPath)) {
console.error(
`\n\nERROR: Missing config.json for WebSSH2. Current config: ${util.inspect(myConfig)}`,
);
console.error('\n See config.json.sample for details\n\n');
}
console.info(`WebSSH2 service reading config from: ${configPath}`);
const configFile = readconfig(configPath, { override: true });
// myConfig = merger.mergeObjects([configDefault, configFile]);
myConfig = { ...configDefault, ...configFile };
debugWebSSH2(`\nCurrent config: ${util.inspect(myConfig)}`);
} catch (err) {
myConfig = configDefault;
console.error(
`\n\nERROR: Missing config.json for WebSSH2. Current config: ${util.inspect(myConfig)}`,
);
console.error('\n See config.json.sample for details\n\n');
console.error(`ERROR:\n\n ${err}`);
}
const config = myConfig;
if (process.env.LISTEN) config.listen.ip = process.env.LISTEN; if (process.env.LISTEN) config.listen.ip = process.env.LISTEN;
@ -130,7 +23,4 @@ if (process.env.SOCKETIO_ORIGINS) config.socketio.origins = process.env.SOCKETIO
if (process.env.SOCKETIO_PATH) config.socketio.path = process.env.SOCKETIO_PATH; if (process.env.SOCKETIO_PATH) config.socketio.path = process.env.SOCKETIO_PATH;
if (process.env.SOCKETIO_SERVECLIENT)
config.socketio.serveClient = process.env.SOCKETIO_SERVECLIENT;
module.exports = config; module.exports = config;