additional debug log statements
This commit is contained in:
parent
8da0bda5ce
commit
41508276b6
3 changed files with 16 additions and 11 deletions
5
index.js
5
index.js
|
@ -20,7 +20,8 @@ var session = require('express-session')({
|
||||||
resave: true,
|
resave: true,
|
||||||
saveUninitialized: false
|
saveUninitialized: false
|
||||||
})
|
})
|
||||||
var termCols, termRows, myError
|
var colors = require('colors/safe')
|
||||||
|
var termCols, termRows
|
||||||
// var LogPrefix
|
// var LogPrefix
|
||||||
// var dataBuffer = ''
|
// var dataBuffer = ''
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ app.get('/ssh/host/:host?', function (req, res, next) {
|
||||||
config.header.background = req.query.headerBackground || config.header.background
|
config.header.background = req.query.headerBackground || config.header.background
|
||||||
console.log('webssh2 Login: user=' + req.session.username + ' from=' + req.ip + ' host=' + config.ssh.host + ' port=' + config.ssh.port + ' sessionID=' + req.sessionID + ' allowreplay=' + req.headers.allowreplay)
|
console.log('webssh2 Login: user=' + req.session.username + ' from=' + req.ip + ' host=' + config.ssh.host + ' port=' + config.ssh.port + ' sessionID=' + req.sessionID + ' allowreplay=' + req.headers.allowreplay)
|
||||||
// LogPrefix = req.session.username + '@' + req.ip + ' ssh://' + config.ssh.host + ':' + config.ssh.port + '/' + req.sessionID
|
// LogPrefix = req.session.username + '@' + req.ip + ' ssh://' + config.ssh.host + ':' + config.ssh.port + '/' + req.sessionID
|
||||||
// console.log('Headers: ' + JSON.stringify(req.headers))
|
debugWebSSH2('Headers: ' + colors.yellow(JSON.stringify(req.headers)))
|
||||||
config.options.allowreplay = req.headers.allowreplay
|
config.options.allowreplay = req.headers.allowreplay
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
var myError = myError
|
var debug = require('debug')('WebSSH2')
|
||||||
|
var myError
|
||||||
|
|
||||||
module.exports = function (socket, io) {
|
module.exports = function (socket, io) {
|
||||||
this.SSHerror = function (myFunc, err) {
|
this.SSHerror = function (myFunc, err) {
|
||||||
myError = (myError) ? myError : ((err) ? err.message:undefined)
|
myError = (myError) || ((err) ? err.message : undefined)
|
||||||
thisError = (myError) ? ': ' + myError : ''
|
thisError = (myError) ? ': ' + myError : ''
|
||||||
console.error('SSH ' + myFunc + thisError)
|
debug('SSH ' + myFunc + thisError)
|
||||||
socket.emit('ssherror', 'SSH ' + myFunc + thisError)
|
socket.emit('ssherror', 'SSH ' + myFunc + thisError)
|
||||||
socket.disconnect(true)
|
socket.disconnect(true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
var debug = require('debug')('WebSSH2')
|
||||||
var colors = require('colors')
|
var colors = require('colors')
|
||||||
var Auth = require('basic-auth')
|
var Auth = require('basic-auth')
|
||||||
|
|
||||||
|
@ -18,9 +19,11 @@ exports.basicAuth = function (req, res, next) {
|
||||||
if (myAuth) {
|
if (myAuth) {
|
||||||
req.session.username = myAuth.name
|
req.session.username = myAuth.name
|
||||||
req.session.userpassword = myAuth.pass
|
req.session.userpassword = myAuth.pass
|
||||||
|
debug('myAuth.name: ' + myAuth.name + ' and password ' + ((myAuth.pass) ? 'exists' : 'is blank'.underline.red))
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
res.statusCode = 401
|
res.statusCode = 401
|
||||||
|
debug('basicAuth credential request (401)')
|
||||||
res.setHeader('WWW-Authenticate', 'Basic realm="WebSSH"')
|
res.setHeader('WWW-Authenticate', 'Basic realm="WebSSH"')
|
||||||
res.end('Username and password required for web SSH service.')
|
res.end('Username and password required for web SSH service.')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue