Compare commits

...

8 Commits

Author SHA1 Message Date
ef7e54be34 2.0.3 2021-02-02 00:53:58 +00:00
d800b6ed6e fix(core): update 2021-02-02 00:53:57 +00:00
af42598464 2.0.2 2020-02-23 19:04:53 +00:00
93b1048cb7 fix(core): update 2020-02-23 19:04:53 +00:00
29549b126e 2.0.1 2020-02-23 19:03:26 +00:00
736113eb4e fix(core): update 2020-02-23 19:03:25 +00:00
3b2d140836 2.0.0 2020-02-07 19:36:13 +00:00
70690f6400 BREAKING CHANGE(API): updateReversConfigs -> updateReverseConfigs 2020-02-07 19:36:12 +00:00
6 changed files with 52 additions and 34 deletions

42
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "1.0.38", "version": "2.0.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -96,9 +96,9 @@
} }
}, },
"@pushrocks/lik": { "@pushrocks/lik": {
"version": "3.0.16", "version": "3.0.19",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.16.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.19.tgz",
"integrity": "sha512-rvF4aJL6IRDZXNtSHwnkT+iXUj4peY928g7xpJh8hrFxABMbE89nH/fOBQ0m36IuI5dZBvbZv++2qiFOLsL+oA==", "integrity": "sha512-N9uTtQmTJ/iZ/V7LMCKbVx/ZAmP+b8uId0pxV9Au9T0Ulu9wcg3vNpyTQARgdWfG+tI9Qc0NHgOEa9H5mbDcDA==",
"requires": { "requires": {
"@pushrocks/smartdelay": "^2.0.6", "@pushrocks/smartdelay": "^2.0.6",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
@ -160,18 +160,12 @@
} }
}, },
"@pushrocks/smartevent": { "@pushrocks/smartevent": {
"version": "2.0.3", "version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.5.tgz",
"integrity": "sha512-x4B1mzzE6LrMATXsRLNuZpMTlB2JodL44MA4bF4FucU3SBBiWhFv3CFJRlO9B23SKZ1fwdJQrk2lT7YTUHXXJQ==", "integrity": "sha512-2cromUAgMFOLxi9IuAhDesWV4FGmsdNQV6k2OQZbH/0bMYeaCT5Q4IcMxb8J5F0S820XCXlwGdy5VP5M6L+hAA==",
"requires": { "requires": {
"@pushrocks/smartpromise": "^2.0.5" "@pushrocks/smartpromise": "^3.0.6",
}, "@pushrocks/smartrx": "^2.0.5"
"dependencies": {
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
}
} }
}, },
"@pushrocks/smartexit": { "@pushrocks/smartexit": {
@ -414,9 +408,9 @@
} }
}, },
"@tsclass/tsclass": { "@tsclass/tsclass": {
"version": "3.0.3", "version": "3.0.10",
"resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.3.tgz", "resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.10.tgz",
"integrity": "sha512-BsPx1VVyXPMMqfERTMoseRQof8kWZZqeHl74un8Ba0aBxZx4DeEgi6OBR1XroWb4Znv+yOP+QQKOwHAffkKvMQ==", "integrity": "sha512-8rDOf1aIsG3229Fy4d4xjH00dPX32UrIL7qPvHtuSAkCDsb70k9wJ5Wn+fkHmPoukMsgGIABJjjWjVnLb8yZXw==",
"requires": { "requires": {
"@pushrocks/tapbundle": "^3.0.13" "@pushrocks/tapbundle": "^3.0.13"
} }
@ -497,9 +491,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
}, },
"@types/node": { "@types/node": {
"version": "13.7.0", "version": "13.7.4",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.0.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.4.tgz",
"integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==" "integrity": "sha512-oVeL12C6gQS/GAExndigSaLxTrKpQPxewx9bOcwfvJiJge4rr7wNaph4J+ns5hrmIV2as5qxqN8YKthn9qh0jw=="
}, },
"@types/portscanner": { "@types/portscanner": {
"version": "2.1.0", "version": "2.1.0",
@ -1456,9 +1450,9 @@
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
}, },
"moment-timezone": { "moment-timezone": {
"version": "0.5.27", "version": "0.5.28",
"resolved": "https://verdaccio.lossless.one/moment-timezone/-/moment-timezone-0.5.27.tgz", "resolved": "https://verdaccio.lossless.one/moment-timezone/-/moment-timezone-0.5.28.tgz",
"integrity": "sha512-EIKQs7h5sAsjhPCqN6ggx6cEbs94GK050254TIJySD1bzoM5JTYDwAU1IoVOeTOL6Gm27kYJ51/uuvq1kIlrbw==", "integrity": "sha512-TDJkZvAyKIVWg5EtVqRzU97w0Rb0YVbfpqyjgu6GwXCAohVRqwZjf4fOzDE6p1Ch98Sro/8hQQi65WDXW5STPw==",
"requires": { "requires": {
"moment": ">= 2.9.0" "moment": ">= 2.9.0"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "1.0.38", "version": "2.0.3",
"private": false, "private": false,
"description": "a proxy for handling high workloads of proxying", "description": "a proxy for handling high workloads of proxying",
"main": "dist/index.js", "main": "dist/index.js",
@ -16,19 +16,19 @@
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.28", "@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.2.0", "@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^13.7.0", "@types/node": "^13.7.4",
"tslint": "^6.0.0", "tslint": "^6.0.0",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.16", "@pushrocks/lik": "^3.0.19",
"@pushrocks/smartnetwork": "^1.1.18", "@pushrocks/smartnetwork": "^1.1.18",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrequest": "^1.1.47", "@pushrocks/smartrequest": "^1.1.47",
"@pushrocks/smartspawn": "^2.0.9", "@pushrocks/smartspawn": "^2.0.9",
"@pushrocks/smartstring": "^3.0.18", "@pushrocks/smartstring": "^3.0.18",
"@pushrocks/smartsystem": "^2.0.9", "@pushrocks/smartsystem": "^2.0.9",
"@tsclass/tsclass": "^3.0.3", "@tsclass/tsclass": "^3.0.10",
"@types/ws": "^7.2.1", "@types/ws": "^7.2.1",
"ws": "^7.2.1" "ws": "^7.2.1"
}, },

View File

@ -18,6 +18,10 @@ a proxy for handling high workloads of proxying
## Usage ## Usage
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
## Contribution ## Contribution

View File

@ -12,7 +12,7 @@ tap.test('should start the testproxy', async () => {
}); });
tap.test('should supply reverse proxy config', async () => { tap.test('should supply reverse proxy config', async () => {
testProxy.updateReversConfigs([ testProxy.updateReverseConfigs([
{ {
destinationIp: 'localhost', destinationIp: 'localhost',
destinationPort: '3000', destinationPort: '3000',

View File

@ -19,7 +19,7 @@ export class SmartProxy {
this.options = optionsArg; this.options = optionsArg;
} }
public async updateReversConfigs( public async updateReverseConfigs(
reverseConfigsArg: plugins.tsclass.network.IReverseProxyConfig[] reverseConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]
) { ) {
// TODO search for old hostCandidates with that target // TODO search for old hostCandidates with that target

View File

@ -2,25 +2,45 @@ import * as plugins from './smartproxy.plugins';
import { expose } from '@pushrocks/smartspawn'; import { expose } from '@pushrocks/smartspawn';
import * as net from 'net'; import * as net from 'net';
let netServer: plugins.net.Server; let netServer: plugins.net.Server;
let httpServer: plugins.http.Server;
const portProxyCalls = { const portProxyCalls = {
start: async (portArg = 8000) => { start: async (portArg = 8000) => {
httpServer = plugins.http.createServer((request, response) => {
const requestUrl = new URL(request.url, `http://${request.headers.host}`);
const completeUrlWithoutProtocol = `${requestUrl.host}${requestUrl.pathname}${requestUrl.search}`;
const redirectUrl = `https://${completeUrlWithoutProtocol}`;
console.log(`Got http request for http://${completeUrlWithoutProtocol}`);
console.log(`Redirecting to ${redirectUrl}`);
response.writeHead(302, {
Location: redirectUrl
});
response.end();
});
httpServer.listen(7999);
netServer = net netServer = net
.createServer(from => { .createServer(from => {
const to = net.createConnection({ const to = net.createConnection({
host: 'localhost', host: 'localhost',
port: 8001 port: 8001
}); });
from.pipe(to); from.pipe(to)
to.pipe(from); to.pipe(from)
from.on('error', () => { from.end(), to.end() });
to.on('error', () => { from.end(), to.end() });
from.on('close', () => {
to.end();
})
}) })
.listen(portArg); .listen(portArg);
console.log(`PortProxy -> OK: Now listening on port ${portArg}`); console.log(`PortProxy -> OK: Now listening on port ${portArg}`);
}, },
stop: async () => { stop: async () => {
const done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
netServer.close(() => { httpServer.close(() => {
done.resolve(); netServer.close(() => {
done.resolve();
});
}); });
await done.promise; await done.promise;
} }