added keepaliveInterval, keepaliveCountMax options

This commit is contained in:
billchurch 2018-01-30 18:09:16 -05:00
parent 7dd019d0e6
commit 08400b0544
3 changed files with 6 additions and 24 deletions

6
app.js
View file

@ -44,6 +44,8 @@ app.get('/ssh/host/:host?', function (req, res, next) {
background: req.query.headerBackground || config.header.background background: req.query.headerBackground || config.header.background
}, },
algorithms: config.algorithms, algorithms: config.algorithms,
keepaliveInterval: config.ssh.keepaliveInterval,
keepaliveCountMax: config.ssh.keepaliveCountMax,
term: (/^(([a-z]|[A-Z]|[0-9]|[!^(){}\-_~])+)?\w$/.test(req.query.sshterm) && term: (/^(([a-z]|[A-Z]|[0-9]|[!^(){}\-_~])+)?\w$/.test(req.query.sshterm) &&
req.query.sshterm) || config.ssh.term, req.query.sshterm) || config.ssh.term,
allowreplay: validator.isBoolean(req.headers.allowreplay + '') || false, allowreplay: validator.isBoolean(req.headers.allowreplay + '') || false,
@ -53,9 +55,7 @@ app.get('/ssh/host/:host?', function (req, res, next) {
server: config.serverlog.server || false server: config.serverlog.server || false
}, },
readyTimeout: (validator.isInt(req.query.readyTimeout + '', {min: 1, max: 300000}) && readyTimeout: (validator.isInt(req.query.readyTimeout + '', {min: 1, max: 300000}) &&
req.query.readyTimeout) || config.ssh.readyTimeout, req.query.readyTimeout) || config.ssh.readyTimeout
verify: config.verify || false,
keepaliveInterval: config.keepaliveInterval || 0
} }
if (req.session.ssh.header.name) validator.escape(req.session.ssh.header.name) if (req.session.ssh.header.name) validator.escape(req.session.ssh.header.name)
if (req.session.ssh.header.background) validator.escape(req.session.ssh.header.background) if (req.session.ssh.header.background) validator.escape(req.session.ssh.header.background)

View file

@ -11,7 +11,9 @@
"host": null, "host": null,
"port": 22, "port": 22,
"term": "xterm-color", "term": "xterm-color",
"readyTimeout": 20000 "readyTimeout": 20000,
"keepaliveInterval": 120000,
"keepaliveCountMax": 10
}, },
"useminified": false, "useminified": false,
"header": { "header": {
@ -60,5 +62,4 @@
}, },
"accesslog": false, // http style access logging to console.log "accesslog": false, // http style access logging to console.log
"verify": false, // verification of host key hashes, see hostkeyhashes.json "verify": false, // verification of host key hashes, see hostkeyhashes.json
"keepaliveInterval": 0 // value in milliseconds, 0 = disable
} }

View file

@ -112,25 +112,6 @@ module.exports = function socket (socket) {
tryKeyboard: true, tryKeyboard: true,
algorithms: socket.request.session.ssh.algorithms, algorithms: socket.request.session.ssh.algorithms,
readyTimeout: socket.request.session.ssh.readyTimeout, readyTimeout: socket.request.session.ssh.readyTimeout,
hostHash: 'sha1',
hostVerifier: function (hash) {
if (socket.request.session.ssh.verify) {
if (hash === hostkeys[socket.request.session.ssh.host]) {
return (verified = true)
} else {
err = { message: 'SSH HOST KEY HASH MISMATCH: ' + hash }
console.error('WEBSSH2 contents of host key hashes: ', JSON.stringify(hostkeys))
console.error('WEBSSH2 reported hash from ' + socket.request.session.ssh.host + ': ', hash)
console.error('WEBSSH2 host key hash for ' + socket.request.session.ssh.host + ': ', hostkeys[socket.request.session.ssh.host])
SSHerror('CONN CONNECT', err)
return (verified = false)
}
} else {
console.info('host key verification disabled. hash for host ' + socket.request.session.ssh.host + ': ', hash)
return (noverify = true)
}
},
keepaliveInterval: socket.request.session.ssh.keepaliveInterval,
debug: debug('ssh2') debug: debug('ssh2')
}) })
} else { } else {