diff --git a/bin/buffer b/bin/buffer new file mode 100755 index 0000000..4dbe8aa Binary files /dev/null and b/bin/buffer differ diff --git a/docker-compose.yml b/docker-compose.yml index 7cb1015..00ba83c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,15 +11,19 @@ services: environment: SSHHOST: 'localhost' SSHPORT: 22 + NODE_ENV: 'development' + command: yarn start --sshhost redbrick.dcu.ie + volumes: + - ./lib:/app/lib web: image: nginx volumes: - - ./bin/nginx.template:/etc/nginx/conf.d/wetty.template + - ./bin/nginx.template:/etc/nginx/conf.d/wetty.template ports: - - "80:80" + - "80:80" environment: - - NGINX_DOMAIN=wetty.com - - NGINX_PORT=80 - - WETTY_HOST=wetty - - WETTY_PORT=3000 + - NGINX_DOMAIN=wetty.com + - NGINX_PORT=80 + - WETTY_HOST=wetty + - 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;'" diff --git a/lib/emitter.mjs b/lib/emitter.mjs index ba428a2..e31fa48 100644 --- a/lib/emitter.mjs +++ b/lib/emitter.mjs @@ -53,14 +53,16 @@ class WeTTy extends EventEmitter { auth, port, }); - this.emit('debug', `sshUser: ${sshUser}, args: ${args}`); + this.emit('debug', `sshUser: ${sshUser}, cmd: ${args.join(' ')}`); if (sshUser) { term.spawn(socket, args); } else { term .login(socket) .then(username => { + this.emit('debug', `username: ${username.trim()}`); args[1] = `${username.trim()}@${args[1]}`; + this.emit('debug', `cmd : ${args.join(' ')}`); return term.spawn(socket, args); }) .catch(() => this.disconnected()); diff --git a/lib/term.mjs b/lib/term.mjs index 6e0a7a1..b2705bb 100644 --- a/lib/term.mjs +++ b/lib/term.mjs @@ -6,6 +6,8 @@ const xterm = { name: 'xterm-256color', cols: 80, rows: 30, + cwd: process.cwd(), + env: process.env, }; export default class Term { @@ -40,8 +42,7 @@ export default class Term { } static login(socket) { - socket.emit('data', 'Enter your username: '); - const term = spawn('/usr/bin/env', ['sh', '-c', 'read'], xterm); + const term = spawn('./bin/buffer', [], xterm); let buf = ''; return new Promise((resolve, reject) => { term.on('exit', () => { diff --git a/src/wetty.js b/src/index.js similarity index 100% rename from src/wetty.js rename to src/index.js diff --git a/webpack.config.js b/webpack.config.js index 96e5fda..e6d7f24 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -13,7 +13,7 @@ const loader = new webpack.ProvidePlugin({ }); module.exports = { - entry: './src/wetty.js', + entry: './src/index.js', output: { filename: '[name].js', path: path.resolve(__dirname, 'dist'), diff --git a/yarn.lock b/yarn.lock index c85e855..480ad13 100644 --- a/yarn.lock +++ b/yarn.lock @@ -56,10 +56,14 @@ after@0.8.2: version "0.8.2" 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" 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: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" @@ -67,7 +71,7 @@ ajv@^4.9.1: co "^4.6.0" 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" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" 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" 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: version "0.1.4" 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: is-arrayish "^0.2.1" -es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: - version "0.10.27" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.27.tgz#bf926b058c62b1cb5de1a887930673b6aa6d9a66" +es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14: + version "0.10.39" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.39.tgz#fca21b67559277ca4ac1a1ed7048b107b6f76d87" dependencies: - es6-iterator "2" - es6-symbol "~3.1" + es6-iterator "~2.0.3" + es6-symbol "~3.1.1" -es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" +es6-iterator@^2.0.1, es6-iterator@~2.0.1, es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" dependencies: d "1" - es5-ext "^0.10.14" - es6-symbol "^3.1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" es6-map@^0.1.3: version "0.1.5" @@ -2054,7 +2066,7 @@ es6-set@~0.1.5: es6-symbol "3.1.1" 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" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" dependencies: @@ -3098,8 +3110,8 @@ inquirer@^3.0.6: through "^2.3.6" interpret@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" + version "1.1.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" invariant@^2.2.2: version "2.2.2" @@ -6096,8 +6108,8 @@ uglifyjs-webpack-plugin@^0.4.6: webpack-sources "^1.0.1" uglifyjs-webpack-plugin@^1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.6.tgz#f4ba8449edcf17835c18ba6ae99b9d610857fb19" + version "1.2.2" + resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.2.tgz#e7516d4367afdb715c3847841eb46f94c45ca2b9" dependencies: cacache "^10.0.1" 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" webpack@^3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.10.0.tgz#5291b875078cf2abf42bdd23afe3f8f96c17d725" + version "3.11.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.11.0.tgz#77da451b1d7b4b117adaf41a1a93b5742f24d894" dependencies: acorn "^5.0.0" acorn-dynamic-import "^2.0.0" - ajv "^5.1.5" - ajv-keywords "^2.0.0" + ajv "^6.1.0" + ajv-keywords "^3.1.0" async "^2.1.2" enhanced-resolve "^3.4.0" escope "^3.6.0"