From 058cbc99bb48f5372d36362b0210d48ba1454ec7 Mon Sep 17 00:00:00 2001 From: Luca Mattiazzi Date: Fri, 6 Dec 2019 15:00:10 +0100 Subject: [PATCH] fix: begun fixing merge comments --- README.md | 40 ++++++++--------- .../accurapp-scripts/utils/reverse-tunnel.js | 45 ------------------- .../accurapp-scripts/utils/tunnel-client.js | 44 +++++++++++++++++- 3 files changed, 62 insertions(+), 67 deletions(-) delete mode 100644 packages/accurapp-scripts/utils/reverse-tunnel.js diff --git a/README.md b/README.md index cb613685..148431a8 100644 --- a/README.md +++ b/README.md @@ -16,32 +16,30 @@ but significant amounts of code were rewritten and simplified. Here are some shi - **JSON5 webpack loader** to import .json5 files. [Read more about JSON5 here](https://json5.org/). ## Table of contents -- [!Accurapp](#accurapp) -- [Table of contents](#table-of-contents) - [Creating a new project](#creating-a-new-project) - - [Setting up github](#setting-up-github) - - [Setting up the automatic deploy](#setting-up-the-automatic-deploy) - - [Commands](#commands) - [Customization](#customization) - - [Customizing Webpack](#customizing-webpack) - - [Customizing Eslint](#customizing-eslint) - - [Customizing Babel](#customizing-babel) - - [Setting Env Variables](#setting-env-variables) - - [Customizing Env Variables](#customizing-env-variables) + - [Customizing Webpack](#customizing-webpack) + - [Customizing Eslint](#customizing-eslint) + - [Customizing Babel](#customizing-babel) + - [Setting Env Variables](#setting-env-variables) + - [Customizing Env Variables](#customizing-env-variables) - [Available Env Variables](#available-env-variables) - [Project Scaffolding](#project-scaffolding) - [F.A.Q.](#faq) -- [Install `react-helmet` and `react-snap`](#install-react-helmet-and-react-snap) -- [Add meta tags for each route in the `render` function](#add-meta-tags-for-each-route-in-the-render-function) -- [Add `react-snap` in `src/index.js`](#add-react-snap-in-srcindexjs) -- [Add `react-snap` to `package.json`](#add-react-snap-to-packagejson) -- [Add the `react-snap` config in `bitbucket-pipelines.yml`](#add-the-react-snap-config-in-bitbucket-pipelinesyml) -- [OK, setup done! Now, how do I check if it is working?](#ok-setup-done-now-how-do-i-check-if-it-is-working) -- [Basic troubleshooting: `react-snap` works properly, but no links are found](#basic-troubleshooting-react-snap-works-properly-but-no-links-are-found) -- [Basic troubleshooting: I get a weird error for 404 pages](#basic-troubleshooting-i-get-a-weird-error-for-404-pages) -- [Basic troubleshooting: There is unknown code in my built index.html. Is it malicious? How do I remove it?](#basic-troubleshooting-there-is-unknown-code-in-my-built-indexhtml-is-it-malicious-how-do-i-remove-it) -- [Further troubleshooting](#further-troubleshooting) -- [What goes in the ``?](#what-goes-in-the-head) + - [How do I enable hot reloading for the state?](#faq) + - [Where do I put the images?](#faq) + - [Where do I put the custom fonts?](#faq) + - [What is the public folder for?](#faq) + - [How do I handle svg files?](#faq) + - [How do I enable TypeScript?](#faq) + - [How do I override a webpack loader?](#faq) + - [What's all the fuss about FUSS?](#faq) + - [How do I enable prettier?](#faq) + - [I need to support IE11. What do I do?](#faq) + - [How do I use a web worker?](#faq) + - [How do I use a service worker?](#faq) + - [I need title and meta tags for each route for SEO. How do I do it?](#faq) + - [I need to build for Electron. How do I do it?](#faq) - [Contributing](#contributing) ## Creating a new project diff --git a/packages/accurapp-scripts/utils/reverse-tunnel.js b/packages/accurapp-scripts/utils/reverse-tunnel.js deleted file mode 100644 index b5b776bc..00000000 --- a/packages/accurapp-scripts/utils/reverse-tunnel.js +++ /dev/null @@ -1,45 +0,0 @@ -const { Socket } = require('net') -const { Client } = require('ssh2') - -function noop() {} - -function createClient(config, onReadyCb = noop, onConnectionCb = noop) { - const conn = new Client() - const errors = [] - - conn.on('ready', () => { - onReadyCb() - conn.forwardIn(config.dstHost, config.dstPort, (err, port) => { - if (err) return errors.push(err) - conn.emit('forward-in', port) - }) - }) - - conn.on('tcp connection', (info, accept, reject) => { - let remote - const srcSocket = new Socket() - - srcSocket.on('error', err => { - errors.push(err) - if (remote === undefined) { - reject() - } else { - remote.end() - } - }) - - srcSocket.connect(config.srcPort, config.srcHost, () => { - remote = accept() - srcSocket.pipe(remote).pipe(srcSocket) - if (errors.length === 0) { - onConnectionCb(null, conn) - } else { - onConnectionCb(errors, null) - } - }) - }) - conn.connect(config) - return conn -} - -module.exports = { createClient } diff --git a/packages/accurapp-scripts/utils/tunnel-client.js b/packages/accurapp-scripts/utils/tunnel-client.js index 7f8bad08..e9222923 100644 --- a/packages/accurapp-scripts/utils/tunnel-client.js +++ b/packages/accurapp-scripts/utils/tunnel-client.js @@ -1,8 +1,50 @@ const os = require('os') +const { Socket } = require('net') const got = require('got') -const { createClient } = require('./reverse-tunnel') +const { Client } = require('ssh2') const { extractCurrentRepo, extractCurrentBranch } = require('../utils/git-utils') +function noop() {} + +function createClient(config, onReadyCb = noop, onConnectionCb = noop) { + const conn = new Client() + const errors = [] + + conn.on('ready', () => { + onReadyCb() + conn.forwardIn(config.dstHost, config.dstPort, (err, port) => { + if (err) return errors.push(err) + conn.emit('forward-in', port) + }) + }) + + conn.on('tcp connection', (info, accept, reject) => { + let remote + const srcSocket = new Socket() + + srcSocket.on('error', err => { + errors.push(err) + if (remote === undefined) { + reject() + } else { + remote.end() + } + }) + + srcSocket.connect(config.srcPort, config.srcHost, () => { + remote = accept() + srcSocket.pipe(remote).pipe(srcSocket) + if (errors.length === 0) { + onConnectionCb(null, conn) + } else { + onConnectionCb(errors, null) + } + }) + }) + conn.connect(config) + return conn +} + const { USER, SSH_AUTH_SOCK, TUNNEL_DOMAIN = 'internal.accurat.io' } = process.env function generateSubdomain() {