Compare commits

...

4 Commits

Author SHA1 Message Date
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
5 changed files with 22 additions and 6 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "1.0.38",
"version": "2.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "1.0.38",
"version": "2.0.1",
"private": false,
"description": "a proxy for handling high workloads of proxying",
"main": "dist/index.js",

View File

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

View File

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

View File

@ -2,9 +2,23 @@ import * as plugins from './smartproxy.plugins';
import { expose } from '@pushrocks/smartspawn';
import * as net from 'net';
let netServer: plugins.net.Server;
let httpServer: plugins.http.Server;
const portProxyCalls = {
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
.createServer(from => {
const to = net.createConnection({
@ -19,8 +33,10 @@ const portProxyCalls = {
},
stop: async () => {
const done = plugins.smartpromise.defer();
netServer.close(() => {
done.resolve();
httpServer.close(() => {
netServer.close(() => {
done.resolve();
});
});
await done.promise;
}