diff --git a/app/config.json b/app/config.json deleted file mode 100644 index 054b51c..0000000 --- a/app/config.json +++ /dev/null @@ -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 -} diff --git a/app/config.json.sample b/app/config.json.sample deleted file mode 100644 index 26f8c39..0000000 --- a/app/config.json.sample +++ /dev/null @@ -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 -} diff --git a/app/index.js b/app/index.js index 1ddef51..8384222 100644 --- a/app/index.js +++ b/app/index.js @@ -6,7 +6,6 @@ const { server } = require('./server/app'); 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}`); server.on('error', (err) => { diff --git a/app/server/config.js b/app/server/config.js index a065af3..54d5184 100644 --- a/app/server/config.js +++ b/app/server/config.js @@ -1,126 +1,19 @@ /* eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }], no-console: ["error", { allow: ["warn", "error", "info"] }] */ -const fs = require('fs'); const path = require('path'); -const debugWebSSH2 = require('debug')('WebSSH2'); const crypto = require('crypto'); -const util = require('util'); -const readconfig = require('read-config-ng'); const nodeRoot = path.dirname(require.main.filename); -const configPath = path.join(nodeRoot, 'config.json'); -let myConfig; // establish defaults const configDefault = { listen: { ip: '0.0.0.0', 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 -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; +const config = configDefault; 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_SERVECLIENT) - config.socketio.serveClient = process.env.SOCKETIO_SERVECLIENT; - module.exports = config;