From 98c384e46c2700b2654aaccfa9833b5fd1b4cf36 Mon Sep 17 00:00:00 2001 From: billchurch Date: Wed, 1 Feb 2017 16:55:34 -0500 Subject: [PATCH] corrected some typos and issues --- README.md | 10 +++++++--- config.json | 3 +++ index.js | 30 +----------------------------- package.json | 3 +++ 4 files changed, 14 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 1a13dc7..1b2aaf6 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,15 @@ Bare bones example of using SSH2 as a client on a host to proxy a Websocket / So screenshot 2016-05-18 13 29 53 # 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 diff --git a/config.json b/config.json index 96732cc..1fed90e 100644 --- a/config.json +++ b/config.json @@ -14,5 +14,8 @@ "header": { "text": "My Header", "background": "green" + }, + "options": { + "challengeButton": true } } \ No newline at end of file diff --git a/index.js b/index.js index 39d256c..cb93b90 100644 --- a/index.js +++ b/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'] } }); -}); +}); \ No newline at end of file diff --git a/package.json b/package.json index 25c69dc..87eff2f 100644 --- a/package.json +++ b/package.json @@ -34,5 +34,8 @@ "socket.io": "^1.6.0", "ssh2": "^0.5.4", "xterm": "^2.2.3" + }, + "scripts": { + "start": "node index" } }