Browse Source

upgrade dependencies

pull/150/head^2
cbutler 6 years ago
parent
commit
9d8a5eeac8
No known key found for this signature in database GPG Key ID: 9EB3D625BD14DDEC
  1. 4
      .babelrc
  2. 2
      bin/index.js
  3. 36
      cli.mjs
  4. 31
      gulpfile.js
  5. 2
      index.js
  6. 29
      package.json
  7. 2
      public/wetty/wetty.min.js
  8. 55
      wetty.mjs
  9. 4150
      yarn.lock

4
.babelrc

@ -1,11 +1,11 @@
{ {
"presets": [ "presets": [
[ [
"es2015", "@babel/preset-env",
{ {
"modules": false "modules": false
} }
] ]
], ],
"compact": true, "compact": true
} }

2
bin/index.js

@ -1,3 +1,3 @@
#! /usr/bin/env node #! /usr/bin/env node
require = require('@std/esm')(module); // eslint-disable-line no-global-assign require = require('esm')(module, { cjs: true }); // eslint-disable-line no-global-assign
require('../cli.mjs'); require('../cli.mjs');

36
cli.mjs

@ -6,45 +6,46 @@ import wetty from './wetty';
const opts = optimist const opts = optimist
.options({ .options({
sslkey: { sslkey: {
demand : false, demand: false,
description: 'path to SSL key', description: 'path to SSL key',
}, },
sslcert: { sslcert: {
demand : false, demand: false,
description: 'path to SSL certificate', description: 'path to SSL certificate',
}, },
sshhost: { sshhost: {
demand : false, demand: false,
description: 'ssh server host', description: 'ssh server host',
}, },
sshport: { sshport: {
demand : false, demand: false,
description: 'ssh server port', description: 'ssh server port',
}, },
sshuser: { sshuser: {
demand : false, demand: false,
description: 'ssh user', description: 'ssh user',
}, },
sshpass: { sshpass: {
demand : false, demand: false,
description: 'ssh password', description: 'ssh password',
}, },
sshauth: { sshauth: {
demand : false, demand: false,
description: 'defaults to "password", you can use "publickey,password" instead', description: 'defaults to "password", you can use "publickey,password" instead',
}, },
sshkey: { sshkey: {
demand : false, demand: false,
description: 'path to an optional client private key (connection will be password-less and insecure!)', description:
'path to an optional client private key (connection will be password-less and insecure!)',
}, },
port: { port: {
demand : false, demand: false,
alias : 'p', alias: 'p',
description: 'wetty listen port', description: 'wetty listen port',
}, },
help: { help: {
demand : false, demand: false,
alias : 'h', alias: 'h',
description: 'Print help message', description: 'Print help message',
}, },
}) })
@ -60,7 +61,7 @@ const sshpass = opts.sshpass || process.env.SSHPASS || '';
const sshhost = opts.sshhost || process.env.SSHHOST || 'localhost'; const sshhost = opts.sshhost || process.env.SSHHOST || 'localhost';
const sshauth = opts.sshauth || process.env.SSHAUTH || 'password,keyboard-interactive'; const sshauth = opts.sshauth || process.env.SSHAUTH || 'password,keyboard-interactive';
const sshport = opts.sshport || process.env.SSHPORT || 22; const sshport = opts.sshport || process.env.SSHPORT || 22;
const sshkey = opts.sshkey || process.env.SSHKEY || ''; const sshkey = opts.sshkey || process.env.SSHKEY || '';
const port = opts.port || process.env.PORT || 3000; const port = opts.port || process.env.PORT || 3000;
loadSSL(opts) loadSSL(opts)
@ -72,13 +73,12 @@ loadSSL(opts)
process.exit(1); process.exit(1);
}); });
const sshkeyWarning = const sshkeyWarning = `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
`!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Password-less auth enabled using private key from ${sshkey}.
! Password-less auth enabled using private key from \'%s\'.
! This is dangerous, anything that reaches the wetty server ! This is dangerous, anything that reaches the wetty server
! will be able to run remote operations without authentication. ! will be able to run remote operations without authentication.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`;
if(sshkey) { if (sshkey) {
console.warn(sshkeyWarning); console.warn(sshkeyWarning);
} }

31
gulpfile.js

@ -5,7 +5,7 @@ const babel = require('gulp-babel');
const shell = require('gulp-shell'); const shell = require('gulp-shell');
const del = require('del'); const del = require('del');
gulp.task('compress', [], () => const compress = () =>
gulp gulp
.src(['./src/hterm_all.js', './src/wetty.js']) .src(['./src/hterm_all.js', './src/wetty.js'])
.pipe(concat('wetty.js')) .pipe(concat('wetty.js'))
@ -20,21 +20,22 @@ gulp.task('compress', [], () =>
ignoreFiles: ['.combo.js', '*.min.js'], ignoreFiles: ['.combo.js', '*.min.js'],
}), }),
) )
.pipe(gulp.dest('./public/wetty')), .pipe(gulp.dest('./public/wetty'));
);
gulp.task('default', gulp.series(compress));
gulp.task( gulp.task(
'hterm', 'upgrade',
shell.task( gulp.series(
[ shell.task(
'git clone https://chromium.googlesource.com/apps/libapps', [
'LIBDOT_SEARCH_PATH=$(pwd)/libapps ./libapps/libdot/bin/concat.sh -i ./libapps/hterm/concat/hterm_all.concat -o ./src/hterm_all.js', 'git clone https://chromium.googlesource.com/apps/libapps',
], 'LIBDOT_SEARCH_PATH=$(pwd)/libapps ./libapps/libdot/bin/concat.sh -i ./libapps/hterm/concat/hterm_all.concat -o ./src/hterm_all.js',
{ ],
verbose: true, {
}, verbose: true,
},
),
() => del(['./libapps']),
), ),
); );
gulp.task('default', ['compress']);
gulp.task('upgrade', ['hterm'], () => del(['./libapps']));

2
index.js

@ -1,2 +1,2 @@
require = require('@std/esm')(module); // eslint-disable-line no-global-assign require = require('esm')(module, { cjs: true }); // eslint-disable-line no-global-assign
module.exports = require('./wetty.mjs').default; module.exports = require('./wetty.mjs').default;

29
package.json

@ -29,29 +29,26 @@
"commit" "commit"
], ],
"preferGlobal": "true", "preferGlobal": "true",
"@std/esm": {
"cjs": "true"
},
"dependencies": { "dependencies": {
"@std/esm": "^0.12.1", "esm": "^3.0.84",
"express": "^4.15.3", "express": "^5.15.3",
"fs-extra": "^4.0.1", "fs-extra": "^4.0.1",
"node-pty": "^0.7.4",
"optimist": "^0.6", "optimist": "^0.6",
"pre-commit": "^1.2.2", "pre-commit": "^1.2.2",
"node-pty": "^0.7.4",
"serve-favicon": "^2.4.3", "serve-favicon": "^2.4.3",
"socket.io": "^1.3.7" "socket.io": "^1.3.7"
}, },
"devDependencies": { "devDependencies": {
"babel-cli": "6.24.1", "@babel/cli": "^7.0.0",
"babel-core": "6.24.1", "@babel/core": "^7.0.0",
"babel-eslint": "7.2.3", "@babel/plugin-transform-async-to-generator": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-eslint": "^9.0.0",
"babel-plugin-add-module-exports": "0.2.1", "babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-es6-promise": "1.1.1", "babel-plugin-es6-promise": "1.1.1",
"babel-plugin-syntax-async-functions": "6.13.0", "babel-plugin-syntax-async-functions": "6.13.0",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-preset-es2015": "6.24.1",
"del": "^3.0.0", "del": "^3.0.0",
"es6-promise": "^4.1.1", "es6-promise": "^4.1.1",
"eslint": "3.19.0", "eslint": "3.19.0",
@ -63,11 +60,11 @@
"eslint-plugin-promise": "^3.5.0", "eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.1.0", "eslint-plugin-react": "^7.1.0",
"eslint-plugin-standard": "^3.0.1", "eslint-plugin-standard": "^3.0.1",
"gulp": "^3.9.1", "gulp": "^4.0.0",
"gulp-babel": "^6.1.2", "gulp-babel": "^8.0.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-minify": "^1.0.0", "gulp-minify": "^3.1.0",
"gulp-shell": "^0.6.3" "gulp-shell": "^0.6.5"
}, },
"contributors": [ "contributors": [
"Krishna Srinivas <krishna.srinivas@gmail.com>", "Krishna Srinivas <krishna.srinivas@gmail.com>",

2
public/wetty/wetty.min.js

File diff suppressed because one or more lines are too long

55
wetty.mjs

@ -3,29 +3,31 @@ import http from 'http';
import https from 'https'; import https from 'https';
import path from 'path'; import path from 'path';
import server from 'socket.io'; import server from 'socket.io';
import { spawn } from 'node-pty'; import pty from 'node-pty';
import EventEmitter from 'events'; import EventEmitter from 'events';
import favicon from 'serve-favicon'; import favicon from 'serve-favicon';
import url from 'url'; import url from 'url';
const dirname = path.resolve();
const app = express(); const app = express();
app.use(favicon(`${__dirname}/public/favicon.ico`)); app.use(favicon(`${dirname}/public/favicon.ico`));
// For using wetty at /wetty on a vhost // For using wetty at /wetty on a vhost
app.get('/wetty/ssh/:user', (req, res) => { app.get('/wetty/ssh/:user', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`); res.sendFile(`${dirname}/public/wetty/index.html`);
}); });
app.get('/wetty/', (req, res) => { app.get('/wetty/', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`); res.sendFile(`${dirname}/public/wetty/index.html`);
}); });
// For using wetty on a vhost by itself // For using wetty on a vhost by itself
app.get('/ssh/:user', (req, res) => { app.get('/ssh/:user', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`); res.sendFile(`${dirname}/public/wetty/index.html`);
}); });
app.get('/', (req, res) => { app.get('/', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`); res.sendFile(`${dirname}/public/wetty/index.html`);
}); });
// For serving css and javascript // For serving css and javascript
app.use('/', express.static(path.join(__dirname, 'public'))); app.use('/', express.static(path.join(dirname, 'public')));
function createServer(port, sslopts) { function createServer(port, sslopts) {
return sslopts && sslopts.key && sslopts.cert return sslopts && sslopts.key && sslopts.cert
@ -43,29 +45,32 @@ function getCommand(socket, sshuser, sshpass, sshhost, sshport, sshauth, sshkey)
const sshAddress = sshuser ? `${sshuser}@${sshhost}` : sshhost; const sshAddress = sshuser ? `${sshuser}@${sshhost}` : sshhost;
const referer = url.parse(request.headers.referer, true); const referer = url.parse(request.headers.referer, true);
sshpass = referer.query.sshpass ? referer.query.sshpass : sshpass; sshpass = referer.query.sshpass ? referer.query.sshpass : sshpass;
let sshPath = sshuser || match ? 'ssh' : path.join(__dirname, 'bin/ssh'); const sshPath = sshuser || match ? 'ssh' : path.join(dirname, 'bin/ssh');
const ssh = match ? `${match[0].split('/ssh/').pop().split('?')[0]}@${sshhost}` : sshAddress; const ssh = match
? `${
match[0]
.split('/ssh/')
.pop()
.split('?')[0]
}@${sshhost}`
: sshAddress;
const sshRemoteOptsBase = [ const sshRemoteOptsBase = [
sshPath, sshPath,
ssh, ssh,
'-p', '-p',
sshport, sshport,
'-o', '-o',
`PreferredAuthentications=${sshauth}`, `PreferredAuthentications=${sshauth}`,
] ];
let sshRemoteOpts; let sshRemoteOpts;
if (sshkey) if (sshkey) sshRemoteOpts = sshRemoteOptsBase.concat(['-i', sshkey]);
sshRemoteOpts = sshRemoteOptsBase.concat(['-i', sshkey]); else if (sshpass) sshRemoteOpts = ['sshpass', '-p', sshpass].concat(sshRemoteOptsBase);
else if (sshpass) else sshRemoteOpts = sshRemoteOptsBase;
sshRemoteOpts = ['sshpass', '-p', sshpass].concat(sshRemoteOptsBase);
else
sshRemoteOpts = sshRemoteOptsBase;
return [ return [
process.getuid() === 0 && sshhost === 'localhost' process.getuid() === 0 && sshhost === 'localhost'
? ['login', '-h', socket.client.conn.remoteAddress.split(':')[3]] ? ['login', '-h', socket.client.conn.remoteAddress.split(':')[3]]
: sshRemoteOpts : sshRemoteOpts,
,
ssh, ssh,
]; ];
} }
@ -76,7 +81,7 @@ export default function start(port, sshuser, sshpass, sshhost, sshport, sshauth,
io.on('connection', socket => { io.on('connection', socket => {
console.log(`${new Date()} Connection accepted.`); console.log(`${new Date()} Connection accepted.`);
const [args, ssh] = getCommand(socket, sshuser, sshpass, sshhost, sshport, sshauth, sshkey); const [args, ssh] = getCommand(socket, sshuser, sshpass, sshhost, sshport, sshauth, sshkey);
const term = spawn('/usr/bin/env', args, { const term = pty.spawn('/usr/bin/env', args, {
name: 'xterm-256color', name: 'xterm-256color',
cols: 80, cols: 80,
rows: 30, rows: 30,

4150
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save