From 99aa234e59d1002ec50cac9c24cc9e837bf6bc74 Mon Sep 17 00:00:00 2001 From: Bill Church Date: Wed, 19 May 2021 10:22:29 -0400 Subject: [PATCH] 0.4.0 Release (#246) * feat: upgrade to socket.io 4.1.1 #242 * chore: lint ./app/client/src/js/index.js #242 * chore: eslint disable global Blob warning #242 * chore: lint ./app/index.js #242 * chore: lint ./app/server/app.js #242 * chore: setup eslint and airbnb rules disable standard #242 * Delete package-lock-old.json * chore: lint ./app/index.js #242 * feat: implement alpine docker image from #213 * chore: lint ./app/server/app.js still TODO for stop function #242 * chore: lint ./app/server/util.js #242 * chore: lint ./app/server/app.js reorg socket and safe shutdown * chore: grammar / spelling * chore: fix some misplaced next returns in some Express routes #242 * chore: lint ./app/server/socket.js #242 * chore: bump version in ./app/package.json #242 * docs: update docs for 0.4.0 #242 * chore: update package-lock.json * chore: install Prettier code linter #242 * chore: linting for Prettier #242 * chore: lint ./app/client/src/js/index.js #242 * chore: client linting #242 * Update package-lock.json * chore: repackage wbssh2 bundle for testing #242 * chore: convert ./app/client/src/js/index.js to typescript #242 * chore: remove html rendering from node * Update tsconfig.json * Update tsconfig.json * Delete index.js * Update ChangeLog.md * chore: config for development container #242 * Update BUILDING.md * feat: pull in #234 staged for 0.4.0 #242 * docs: update changelog * update package.json * chore: split config from app/server/app.js #242 * chore: version bump * chore: consistency * feat: overridebasic fixes #243 included for #242 * chore: remove serverlog code * docs: update changelog --- .devcontainer/Dockerfile | 16 + .devcontainer/devcontainer.json | 31 + .eslintignore | 1 - .eslintrc.yml | 277 - .github/workflows/build_publish.yml | 6 +- BUILDING.md | 2 +- ChangeLog.md | 20 + Dockerfile | 4 +- README.md | 16 +- app/.eslintrc.json | 24 + app/.prettierrc | 4 + app/client/public/client.htm | 7 +- app/client/public/webssh2.bundle.js | 2 +- .../public/webssh2.bundle.js.LICENSE.txt | 8 - app/client/src/client.htm | 7 +- app/client/src/js/index.js | 252 - app/client/src/js/index.ts | 282 + app/client/tsconfig.json | 9 + app/config.json.sample | 1 + app/index.js | 28 +- app/package-lock-old.json | 9561 ----------------- app/package-lock.json | 5533 ++-------- app/package.json | 40 +- app/scripts/webpack.common.js | 43 +- app/scripts/webpack.dev.js | 11 +- app/scripts/webpack.prod.js | 25 +- app/server/app.js | 379 +- app/server/config.js | 102 + app/server/expressOptions.js | 8 +- app/server/socket.js | 401 +- app/server/util.js | 74 +- 31 files changed, 1912 insertions(+), 15262 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json delete mode 100644 .eslintignore delete mode 100644 .eslintrc.yml create mode 100644 app/.eslintrc.json create mode 100644 app/.prettierrc delete mode 100644 app/client/src/js/index.js create mode 100644 app/client/src/js/index.ts create mode 100644 app/client/tsconfig.json delete mode 100644 app/package-lock-old.json create mode 100644 app/server/config.js diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..507670b8 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/typescript-node/.devcontainer/base.Dockerfile + +# [Choice] Node.js version: 16, 14, 12 +ARG VARIANT="16-buster" +FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT} + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment if you want to install an additional version of node using nvm +# ARG EXTRA_NODE_VERSION=10 +# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" + +# [Optional] Uncomment if you want to install more global node packages +# RUN su node -c "npm install -g " diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..3bfd1536 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,31 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/typescript-node +{ + "name": "Node.js & TypeScript", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick a Node version: 12, 14, 16 + "args": { + "VARIANT": "14" + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "dbaeumer.vscode-eslint" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "node" +} \ No newline at end of file diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 96212a35..00000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/*{.,-}min.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index a6a0ce9c..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,277 +0,0 @@ ---- -parserOptions: - sourceType: module - ecmaFeatures: - jsx: true - -env: - amd: true - browser: true - es6: true - jquery: true - node: true - -# http://eslint.org/docs/rules/ -rules: - # Possible Errors - no-await-in-loop: off - no-cond-assign: error - no-console: off - no-constant-condition: error - no-control-regex: error - no-debugger: error - no-dupe-args: error - no-dupe-keys: error - no-duplicate-case: error - no-empty-character-class: error - no-empty: error - no-ex-assign: error - no-extra-boolean-cast: error - no-extra-parens: off - no-extra-semi: error - no-func-assign: error - no-inner-declarations: - - error - - functions - no-invalid-regexp: error - no-irregular-whitespace: error - no-negated-in-lhs: error - no-obj-calls: error - no-prototype-builtins: off - no-regex-spaces: error - no-sparse-arrays: error - no-template-curly-in-string: off - no-unexpected-multiline: error - no-unreachable: error - no-unsafe-finally: off - no-unsafe-negation: off - use-isnan: error - valid-jsdoc: off - valid-typeof: error - - # Best Practices - accessor-pairs: error - array-callback-return: off - block-scoped-var: off - class-methods-use-this: off - complexity: - - error - - 6 - consistent-return: off - curly: off - default-case: off - dot-location: off - dot-notation: off - eqeqeq: error - guard-for-in: error - no-alert: error - no-caller: error - no-case-declarations: error - no-div-regex: error - no-else-return: off - no-empty-function: off - no-empty-pattern: error - no-eq-null: error - no-eval: error - no-extend-native: error - no-extra-bind: error - no-extra-label: off - no-fallthrough: error - no-floating-decimal: off - no-global-assign: off - no-implicit-coercion: off - no-implied-eval: error - no-invalid-this: off - no-iterator: error - no-labels: - - error - - allowLoop: true - allowSwitch: true - no-lone-blocks: error - no-loop-func: error - no-magic-number: off - no-multi-spaces: off - no-multi-str: off - no-native-reassign: error - no-new-func: error - no-new-wrappers: error - no-new: error - no-octal-escape: error - no-octal: error - no-param-reassign: off - no-proto: error - no-redeclare: error - no-restricted-properties: off - no-return-assign: error - no-return-await: off - no-script-url: error - no-self-assign: off - no-self-compare: error - no-sequences: off - no-throw-literal: off - no-unmodified-loop-condition: off - no-unused-expressions: error - no-unused-labels: off - no-useless-call: error - no-useless-concat: error - no-useless-escape: off - no-useless-return: off - no-void: error - no-warning-comments: off - no-with: error - prefer-promise-reject-errors: off - radix: error - require-await: off - vars-on-top: off - wrap-iife: error - yoda: off - - # Strict - strict: off - - # Variables - init-declarations: off - no-catch-shadow: error - no-delete-var: error - no-label-var: error - no-restricted-globals: off - no-shadow-restricted-names: error - no-shadow: off - no-undef-init: error - no-undef: off - no-undefined: off - no-unused-vars: off - no-use-before-define: off - - # Node.js and CommonJS - callback-return: error - global-require: error - handle-callback-err: error - no-mixed-requires: off - no-new-require: off - no-path-concat: error - no-process-env: off - no-process-exit: error - no-restricted-modules: off - no-sync: off - - # Stylistic Issues - array-bracket-spacing: off - block-spacing: off - brace-style: off - camelcase: off - capitalized-comments: off - comma-dangle: - - error - - never - comma-spacing: off - comma-style: off - computed-property-spacing: off - consistent-this: off - eol-last: off - func-call-spacing: off - func-name-matching: off - func-names: off - func-style: off - id-length: off - id-match: off - indent: off - jsx-quotes: off - key-spacing: off - keyword-spacing: off - line-comment-position: off - linebreak-style: off - lines-around-comment: off - lines-around-directive: off - max-depth: off - max-len: off - max-nested-callbacks: off - max-params: off - max-statements-per-line: off - max-statements: - - error - - 30 - multiline-ternary: off - new-cap: off - new-parens: off - newline-after-var: off - newline-before-return: off - newline-per-chained-call: off - no-array-constructor: off - no-bitwise: off - no-continue: off - no-inline-comments: off - no-lonely-if: off - no-mixed-operators: off - no-mixed-spaces-and-tabs: off - no-multi-assign: off - no-multiple-empty-lines: off - no-negated-condition: off - no-nested-ternary: off - no-new-object: off - no-plusplus: off - no-restricted-syntax: off - no-spaced-func: off - no-tabs: off - no-ternary: off - no-trailing-spaces: off - no-underscore-dangle: off - no-unneeded-ternary: off - object-curly-newline: off - object-curly-spacing: off - object-property-newline: off - one-var-declaration-per-line: off - one-var: off - operator-assignment: off - operator-linebreak: off - padded-blocks: off - quote-props: off - quotes: off - require-jsdoc: off - semi-spacing: off - semi: off - sort-keys: off - sort-vars: off - space-before-blocks: off - space-before-function-paren: off - space-in-parens: off - space-infix-ops: off - space-unary-ops: off - spaced-comment: off - template-tag-spacing: off - unicode-bom: off - wrap-regex: off - - # ECMAScript 6 - arrow-body-style: off - arrow-parens: off - arrow-spacing: off - constructor-super: off - generator-star-spacing: off - no-class-assign: off - no-confusing-arrow: off - no-const-assign: off - no-dupe-class-members: off - no-duplicate-imports: off - no-new-symbol: off - no-restricted-imports: off - no-this-before-super: off - no-useless-computed-key: off - no-useless-constructor: off - no-useless-rename: off - no-var: off - object-shorthand: off - prefer-arrow-callback: off - prefer-const: off - prefer-destructuring: off - prefer-numeric-literals: off - prefer-rest-params: off - prefer-reflect: off - prefer-spread: off - prefer-template: off - require-yield: off - rest-spread-spacing: off - sort-imports: off - symbol-description: off - template-curly-spacing: off - yield-star-spacing: off diff --git a/.github/workflows/build_publish.yml b/.github/workflows/build_publish.yml index 4e86fdcd..fea9fa1e 100644 --- a/.github/workflows/build_publish.yml +++ b/.github/workflows/build_publish.yml @@ -3,7 +3,7 @@ on: release: types: [published] schedule: - - cron: '0 6 * * 1' + - cron: '0 1 * * 1' jobs: build: @@ -19,5 +19,5 @@ jobs: imageName: ${{ secrets.DOCKER_HUB_USER }}/webssh2 platform: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7 publish: true - dockerHubUser: ${{ secrets.DOCKER_HUB_USER }} - dockerHubPassword: ${{ secrets.DOCKER_HUB_PASSWORD }} \ No newline at end of file + dockerUser: ${{ secrets.DOCKER_HUB_USER }} + dockerPassword: ${{ secrets.DOCKER_HUB_PASSWORD }} \ No newline at end of file diff --git a/BUILDING.md b/BUILDING.md index 29d452cc..1af7abd5 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,6 +1,6 @@ # Buliding -To rebuild the client files, you need at least Node v10. +To rebuild the client files, you need at least Node v14. The source of the client files are located in `./app/client/source` diff --git a/ChangeLog.md b/ChangeLog.md index 3d130099..0e608d2e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,24 @@ # Change Log +## 0.4.0 [20210519] +### BREAKING +- Disabled ssh.serverlog.client option, this disables the POC which allowed for logging of the data sent between the client/server to the console.log. +- Dropping support for node versions under 14 +### Changes +- Removed HTML menu code from ./app/server/socket.js, the menu is now fully laid out in the ./app/client/src/index.html and the option elements are hidden by default. Not sure why it wasn't done this way from the start, but there it is. +- Updated socket.io to v4.1.1 +- Client javascript `./app/client/src/js/index.ts` is now built on TypeScript (`npm run build` will generate javascript for client and place into `app/client/public/webssh2.bundle.js` as before) +- Build environment changes + - removed unused xterm-addon-search, xterm-addon-weblinks, standard, postcss-discard-comments + - added prettier 2.3.0, typescript modules, socket.io-client 4.1.1, airbnb linting tools +### Added +- Lookup ip address for hostname in URL, fixes #199 thanks to @zwiy +- Ability to override `Authorization: Basic` header and replace with credentials specified in `config.json` fixes #243. New config.json option `user.overridebasic` +### CONTRIBUTING +In this release, we're trying our best to conform to the [Airbnb Javascript Style Guide](https://airbnb.io/projects/javascript/). I'm hoping this will make contributions easier and keep the code readable. I love shortcuts more than anyone but I've found when making changes to code I've not looked at in a while, it can take me a few momements to deconstruct what was being done due to readbility issues. While I don't agree with every decision in the style guide (semi-colons, yuk), it is a good base to keep the code consistent. + +If you've not used it before, I recommend installing the [vscode extensions](https://blog.echobind.com/integrating-prettier-eslint-airbnb-style-guide-in-vscode-47f07b5d7d6a) for that and [Prettier](https://prettier.io/) and getting familiar. The autocorrections are great (especially if you hate dealing with semi-colons...) + +As of 0.4.0-testing-0, the client code is written in [TypeScript](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html). It's not that much different from JavaScript, and the introduction strong typing will ultimately help to produce better code. Eventually we want to move the whole project to TypeScript but that make take a bit more time. Take a moment to look at ./app/client/src/js/index.ts to see what TypeScript looks like. ## 0.3.1 [20210513] ### BREAKING - Ability to configure CORS settings for socket.io see [#240](../../issues/240) for more information on how this may break existing deployments. Default settings in example `config.json` are currently permissive `http.origins: ["*:*"]` please note that if a `config.json` is not present, the default is `http.origins: ["localhost:2222"] diff --git a/Dockerfile b/Dockerfile index 9cf7ec92..1382cecc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM node:8.6 +FROM node:14.17-alpine WORKDIR /usr/src COPY app/ /usr/src/ RUN npm install --production -EXPOSE 2222 +EXPOSE 2222/tcp ENTRYPOINT [ "/usr/local/bin/node", "index.js" ] diff --git a/README.md b/README.md index d04599ff..395c89c8 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf * **user.password** - _string_ - Specify password to authenticate with. In normal cases this should be left to the default `null` setting. +* **user.overridebasic** - _boolean_ - When set to `true` ignores `Authorization: Basic` header sent from client and use credentials defined in `user.name` and `user.password` instead. Defaults to `false`. [issue 242](../../issues/242) for more information. + * **ssh.host** - _string_ - Specify host to connect to. May be either hostname or IP address. Defaults to `null`. * **ssh.port** - _integer_ - Specify SSH port to connect to, defaults to `22` @@ -239,12 +241,22 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf * **safeShutdownDuration** - _integer_ - maximum delay, in seconds, given to users before the server stops when doing a safe shutdown -# Experimental client-side logging +# Client-side logging Clicking `Start logging` on the status bar will log all data to the client. A `Download log` option will appear after starting the logging. You may download at any time to the client. You may stop logging at any time my pressing the `Logging - STOP LOG`. Note that clicking the `Start logging` option again will cause the current log to be overwritten, so be sure to download first. # Example: http://localhost:2222/ssh/host/192.168.1.1?port=2244&header=My%20Header&headerBackground=red +# CONTRIBUTING +As of 0.4.0, we're trying our best to conform to the [Airbnb Javascript Style Guide](https://airbnb.io/projects/javascript/). I'm hoping this will make contributions easier and keep the code readable. I love shortcuts more than anyone but I've found when making changes to code I've not looked at in a while, it can take me a few momements to deconstruct what was being done due to readbility issues. While I don't agree with every decision in the style guide (semi-colons, yuk), it is a good base to keep the code consistent. + +If you've not used it before, I recommend installing the [vscode extensions](https://blog.echobind.com/integrating-prettier-eslint-airbnb-style-guide-in-vscode-47f07b5d7d6a) for that and [Prettier](https://prettier.io/) and getting familiar. The autocorrections are great (especially if you hate dealing with semi-colons...) + +All contributions are welcome, all may not make it into a release... To increase the chances of your contribution making it into a release, try your best to conform to the style guides and targets of the project. + # Tips -* If you want to add custom JavaScript to the browser client you can either modify `./src/client.html` and add a **