corrected some typos and issues
This commit is contained in:
parent
20f67a71d4
commit
98c384e46c
4 changed files with 14 additions and 32 deletions
10
README.md
10
README.md
|
@ -6,11 +6,15 @@ Bare bones example of using SSH2 as a client on a host to proxy a Websocket / So
|
|||
<img width="1044" alt="screenshot 2016-05-18 13 29 53" src="https://cloud.githubusercontent.com/assets/1668075/15368633/d2c9c4ca-1cfc-11e6-9961-b5b52a07b9ff.png">
|
||||
|
||||
# Instructions
|
||||
To install, copy to a location somewhere and 'npm install'
|
||||
To install:
|
||||
|
||||
Edit config.json to change the listener to your liking. There are also some default options which may be definied for a few of the variables.
|
||||
1. Clone to a location somewhere and `npm install`
|
||||
|
||||
Fire up a browser, navigate to IP/port of your choice and specify a host (https isn't used here because it's assumed it will be off-loaded to
|
||||
2. If desired, edit config.json to change the listener to your liking. There are also some default options which may be definied for a few of the variables.
|
||||
|
||||
3. Run `npm start`
|
||||
|
||||
4. Fire up a browser, navigate to IP/port of your choice and specify a host (https isn't used here because it's assumed it will be off-loaded to
|
||||
some sort of proxy):
|
||||
|
||||
http://localhost:2222/ssh/host/127.0.0.1
|
||||
|
|
|
@ -14,5 +14,8 @@
|
|||
"header": {
|
||||
"text": "My Header",
|
||||
"background": "green"
|
||||
},
|
||||
"options": {
|
||||
"challengeButton": true
|
||||
}
|
||||
}
|
30
index.js
30
index.js
|
@ -16,30 +16,9 @@ var ssh = require('ssh2');
|
|||
var readConfig = require('read-config'),
|
||||
config = readConfig(__dirname + '/config.json');
|
||||
|
||||
<<<<<<< HEAD
|
||||
function logErrors(err, req, res, next) {
|
||||
console.error(err.stack);
|
||||
next(err);
|
||||
=======
|
||||
function checkParams(arr) {
|
||||
return function(req, res, next) {
|
||||
// Make sure each param listed in arr is present in req.query
|
||||
var missing_params = [];
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (!eval("req.query." + arr[i])) {
|
||||
missing_params.push(arr[i]);
|
||||
}
|
||||
}
|
||||
if (missing_params.length === 0) {
|
||||
next();
|
||||
} else {
|
||||
next(JSON.stringify({
|
||||
"error": "query error",
|
||||
"message": "Parameter(s) missing: " + missing_params.join(",")
|
||||
}));
|
||||
}
|
||||
};
|
||||
>>>>>>> origin/master
|
||||
}
|
||||
|
||||
server.listen({
|
||||
|
@ -66,15 +45,9 @@ app.use(express.static(__dirname + '/public')).use(function(req, res, next) {
|
|||
config.user.password = myAuth.pass;
|
||||
next();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}).use(cookieParser()).get('/ssh/host/:host?', function(req, res) {
|
||||
res.sendFile(path.join(__dirname + '/public/client.htm'));
|
||||
config.ssh.host = req.params.host;
|
||||
=======
|
||||
}).get('/', checkParams(["host"]), function(req, res) {
|
||||
res.sendFile(path.join(__dirname + '/public/client.htm'));
|
||||
config.ssh.host = req.query.host;
|
||||
>>>>>>> origin/master
|
||||
if (typeof req.query.port !== 'undefined' && req.query.port !== null){ config.host.port = req.query.port;}
|
||||
if (typeof req.query.header !== 'undefined' && req.query.header !== null){ config.header.text = req.query.header;}
|
||||
if (typeof req.query.headerBackground !== 'undefined' && req.query.headerBackground !== null){ config.header.background = req.query.headerBackground;}
|
||||
|
@ -111,7 +84,6 @@ io.on('connection', function(socket) {
|
|||
});
|
||||
stream.on('data', function(d) {
|
||||
socket.emit('data', d.toString('binary'));
|
||||
// console.log('data: ' + d);
|
||||
}).on('close', function() {
|
||||
conn.end();
|
||||
});
|
||||
|
@ -140,4 +112,4 @@ io.on('connection', function(socket) {
|
|||
'hmac': ['hmac-sha1', 'hmac-sha1-96', 'hmac-md5-96']
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
|
@ -34,5 +34,8 @@
|
|||
"socket.io": "^1.6.0",
|
||||
"ssh2": "^0.5.4",
|
||||
"xterm": "^2.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node index"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue