Browse Source

add basic shell indepdent buffer

pull/126/head
butlerx 7 years ago
parent
commit
b0838aed90
No known key found for this signature in database GPG Key ID: B37CA765BAA89170
  1. BIN
      bin/buffer
  2. 16
      docker-compose.yml
  3. 4
      lib/emitter.mjs
  4. 5
      lib/term.mjs
  5. 0
      src/index.js
  6. 2
      webpack.config.js
  7. 54
      yarn.lock

BIN
bin/buffer

Binary file not shown.

16
docker-compose.yml

@ -11,15 +11,19 @@ services:
environment: environment:
SSHHOST: 'localhost' SSHHOST: 'localhost'
SSHPORT: 22 SSHPORT: 22
NODE_ENV: 'development'
command: yarn start --sshhost redbrick.dcu.ie
volumes:
- ./lib:/app/lib
web: web:
image: nginx image: nginx
volumes: volumes:
- ./bin/nginx.template:/etc/nginx/conf.d/wetty.template - ./bin/nginx.template:/etc/nginx/conf.d/wetty.template
ports: ports:
- "80:80" - "80:80"
environment: environment:
- NGINX_DOMAIN=wetty.com - NGINX_DOMAIN=wetty.com
- NGINX_PORT=80 - NGINX_PORT=80
- WETTY_HOST=wetty - WETTY_HOST=wetty
- WETTY_PORT=3000 - WETTY_PORT=3000
command: /bin/bash -c "envsubst '$${NGINX_DOMAIN},$${NGINX_PORT},$${WETTY_HOST},$${WETTY_PORT}' < /etc/nginx/conf.d/wetty.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" command: /bin/bash -c "envsubst '$${NGINX_DOMAIN},$${NGINX_PORT},$${WETTY_HOST},$${WETTY_PORT}' < /etc/nginx/conf.d/wetty.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

4
lib/emitter.mjs

@ -53,14 +53,16 @@ class WeTTy extends EventEmitter {
auth, auth,
port, port,
}); });
this.emit('debug', `sshUser: ${sshUser}, args: ${args}`); this.emit('debug', `sshUser: ${sshUser}, cmd: ${args.join(' ')}`);
if (sshUser) { if (sshUser) {
term.spawn(socket, args); term.spawn(socket, args);
} else { } else {
term term
.login(socket) .login(socket)
.then(username => { .then(username => {
this.emit('debug', `username: ${username.trim()}`);
args[1] = `${username.trim()}@${args[1]}`; args[1] = `${username.trim()}@${args[1]}`;
this.emit('debug', `cmd : ${args.join(' ')}`);
return term.spawn(socket, args); return term.spawn(socket, args);
}) })
.catch(() => this.disconnected()); .catch(() => this.disconnected());

5
lib/term.mjs

@ -6,6 +6,8 @@ const xterm = {
name: 'xterm-256color', name: 'xterm-256color',
cols: 80, cols: 80,
rows: 30, rows: 30,
cwd: process.cwd(),
env: process.env,
}; };
export default class Term { export default class Term {
@ -40,8 +42,7 @@ export default class Term {
} }
static login(socket) { static login(socket) {
socket.emit('data', 'Enter your username: '); const term = spawn('./bin/buffer', [], xterm);
const term = spawn('/usr/bin/env', ['sh', '-c', 'read'], xterm);
let buf = ''; let buf = '';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
term.on('exit', () => { term.on('exit', () => {

0
src/wetty.js → src/index.js

2
webpack.config.js

@ -13,7 +13,7 @@ const loader = new webpack.ProvidePlugin({
}); });
module.exports = { module.exports = {
entry: './src/wetty.js', entry: './src/index.js',
output: { output: {
filename: '[name].js', filename: '[name].js',
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),

54
yarn.lock

@ -56,10 +56,14 @@ after@0.8.2:
version "0.8.2" version "0.8.2"
resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f"
ajv-keywords@^2.0.0, ajv-keywords@^2.1.0: ajv-keywords@^2.1.0:
version "2.1.1" version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
ajv-keywords@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.1.0.tgz#ac2b27939c543e95d2c06e7f7f5c27be4aa543be"
ajv@^4.9.1: ajv@^4.9.1:
version "4.11.8" version "4.11.8"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536"
@ -67,7 +71,7 @@ ajv@^4.9.1:
co "^4.6.0" co "^4.6.0"
json-stable-stringify "^1.0.1" json-stable-stringify "^1.0.1"
ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.3, ajv@^5.3.0: ajv@^5.0.0, ajv@^5.1.0, ajv@^5.2.3, ajv@^5.3.0:
version "5.5.2" version "5.5.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
dependencies: dependencies:
@ -76,6 +80,14 @@ ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.3, ajv@^5.3.0:
fast-json-stable-stringify "^2.0.0" fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0" json-schema-traverse "^0.3.0"
ajv@^6.1.0:
version "6.1.1"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.1.1.tgz#978d597fbc2b7d0e5a5c3ddeb149a682f2abfa0e"
dependencies:
fast-deep-equal "^1.0.0"
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0"
align-text@^0.1.1, align-text@^0.1.3: align-text@^0.1.1, align-text@^0.1.3:
version "0.1.4" version "0.1.4"
resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117"
@ -2018,20 +2030,20 @@ error-ex@^1.2.0, error-ex@^1.3.1:
dependencies: dependencies:
is-arrayish "^0.2.1" is-arrayish "^0.2.1"
es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14:
version "0.10.27" version "0.10.39"
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.27.tgz#bf926b058c62b1cb5de1a887930673b6aa6d9a66" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.39.tgz#fca21b67559277ca4ac1a1ed7048b107b6f76d87"
dependencies: dependencies:
es6-iterator "2" es6-iterator "~2.0.3"
es6-symbol "~3.1" es6-symbol "~3.1.1"
es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1: es6-iterator@^2.0.1, es6-iterator@~2.0.1, es6-iterator@~2.0.3:
version "2.0.1" version "2.0.3"
resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7"
dependencies: dependencies:
d "1" d "1"
es5-ext "^0.10.14" es5-ext "^0.10.35"
es6-symbol "^3.1" es6-symbol "^3.1.1"
es6-map@^0.1.3: es6-map@^0.1.3:
version "0.1.5" version "0.1.5"
@ -2054,7 +2066,7 @@ es6-set@~0.1.5:
es6-symbol "3.1.1" es6-symbol "3.1.1"
event-emitter "~0.3.5" event-emitter "~0.3.5"
es6-symbol@3.1.1, es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1, es6-symbol@~3.1.1: es6-symbol@3.1.1, es6-symbol@^3.1.1, es6-symbol@~3.1.1:
version "3.1.1" version "3.1.1"
resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77"
dependencies: dependencies:
@ -3098,8 +3110,8 @@ inquirer@^3.0.6:
through "^2.3.6" through "^2.3.6"
interpret@^1.0.0: interpret@^1.0.0:
version "1.0.3" version "1.1.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
invariant@^2.2.2: invariant@^2.2.2:
version "2.2.2" version "2.2.2"
@ -6096,8 +6108,8 @@ uglifyjs-webpack-plugin@^0.4.6:
webpack-sources "^1.0.1" webpack-sources "^1.0.1"
uglifyjs-webpack-plugin@^1.1.6: uglifyjs-webpack-plugin@^1.1.6:
version "1.1.6" version "1.2.2"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.6.tgz#f4ba8449edcf17835c18ba6ae99b9d610857fb19" resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.2.tgz#e7516d4367afdb715c3847841eb46f94c45ca2b9"
dependencies: dependencies:
cacache "^10.0.1" cacache "^10.0.1"
find-cache-dir "^1.0.0" find-cache-dir "^1.0.0"
@ -6284,13 +6296,13 @@ webpack-sources@^1.0.1, webpack-sources@^1.1.0:
source-map "~0.6.1" source-map "~0.6.1"
webpack@^3.10.0: webpack@^3.10.0:
version "3.10.0" version "3.11.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.10.0.tgz#5291b875078cf2abf42bdd23afe3f8f96c17d725" resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.11.0.tgz#77da451b1d7b4b117adaf41a1a93b5742f24d894"
dependencies: dependencies:
acorn "^5.0.0" acorn "^5.0.0"
acorn-dynamic-import "^2.0.0" acorn-dynamic-import "^2.0.0"
ajv "^5.1.5" ajv "^6.1.0"
ajv-keywords "^2.0.0" ajv-keywords "^3.1.0"
async "^2.1.2" async "^2.1.2"
enhanced-resolve "^3.4.0" enhanced-resolve "^3.4.0"
escope "^3.6.0" escope "^3.6.0"

Loading…
Cancel
Save