Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
ef7e54be34 | |||
d800b6ed6e | |||
af42598464 | |||
93b1048cb7 | |||
29549b126e | |||
736113eb4e | |||
3b2d140836 | |||
70690f6400 | |||
ae561e3e88 | |||
8a02a0c506 |
962
package-lock.json
generated
962
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "1.0.37",
|
"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"
|
||||||
},
|
},
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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',
|
||||||
|
@ -231,7 +231,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
|||||||
console.log(`ProxyWorker -> OK: now listening for new connections on port ${this.port}`);
|
console.log(`ProxyWorker -> OK: now listening for new connections on port ${this.port}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateProxyConfigs(proxyConfigsArg: plugins.tsclass.IReverseProxyConfig[]) {
|
public async updateProxyConfigs(proxyConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]) {
|
||||||
this.proxyConfigs = proxyConfigsArg;
|
this.proxyConfigs = proxyConfigsArg;
|
||||||
this.router.setNewProxyConfigs(proxyConfigsArg);
|
this.router.setNewProxyConfigs(proxyConfigsArg);
|
||||||
for (const hostCandidate of this.proxyConfigs) {
|
for (const hostCandidate of this.proxyConfigs) {
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user