Compare commits

...

6 Commits

Author SHA1 Message Date
0e6c09aba5 1.0.7 2019-08-20 23:21:12 +02:00
2f4916f552 fix(core): update 2019-08-20 23:21:12 +02:00
29bddf198f 1.0.6 2019-08-20 22:26:44 +02:00
a5ecf0d9c1 fix(core): update 2019-08-20 22:26:44 +02:00
1ccd53ce69 1.0.5 2019-08-20 19:02:13 +02:00
1264542410 fix(core): update 2019-08-20 19:02:13 +02:00
7 changed files with 37 additions and 9 deletions

2
package-lock.json generated
View File

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

View File

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

View File

@ -2,7 +2,8 @@ import { expect, tap } from '@pushrocks/tapbundle';
import * as smartproxy from '../ts/index';
tap.test('first test', async () => {
console.log(smartproxy);
const testProxy = new smartproxy.SmartProxy();
// await testProxy.start();
});
tap.start();

View File

@ -1,6 +1,6 @@
export interface IHostConfig {
hostName: string;
destination: string;
destinationIp: string;
destinationPort: number;
privateKey: string;
publicKey: string;

View File

@ -1,3 +1,8 @@
import * as plugins from './smartproxy.plugins';
export class SmartproxyRouter {}
export class SmartproxyRouter {
public routeReq(req: plugins.express.Request) {
return 'https://lossless.gmbh';
}
}

View File

@ -5,7 +5,7 @@ import { SmartproxyRouter } from './smartproxy.classes.router';
export class SmartProxy {
public expressInstance: plugins.express.Express;
public httpsServer: plugins.https.Server;
public httpsServer: plugins.https.Server | plugins.http.Server;
public router = new SmartproxyRouter();
public hostCandidates: interfaces.IHostConfig[] = [];
@ -20,7 +20,28 @@ export class SmartProxy {
*/
public async start() {
this.expressInstance = plugins.express();
this.httpsServer = plugins.https.createServer(this.expressInstance);
this.httpsServer = plugins.http.createServer(this.expressInstance);
for (const hostCandidate of this.hostCandidates) {
/* this.httpsServer.addContext(hostCandidate.hostName, {
cert: hostCandidate.publicKey,
key: hostCandidate.privateKey
}); */
}
// proxy middleware options
const proxyOptions: plugins.httpProxyMiddleware.Config = {
target: 'https://nullresolve.lossless.one',
changeOrigin: true, // needed for virtual hosted sites
ws: true, // proxy websockets
router: (req: plugins.express.Request) => {
return this.router.routeReq(req);
}
};
this.expressInstance.use(plugins.httpProxyMiddleware(proxyOptions));
this.httpsServer.listen(3000);
}
public async update() {

View File

@ -1,10 +1,11 @@
// node native scope
import * as http from 'http';
import * as https from 'https';
export { https };
export { http, https };
// third party scope
import express from 'express';
import * as httpProxyMiddleware from 'http-proxy-middleware';
import httpProxyMiddleware from 'http-proxy-middleware';
export { express, httpProxyMiddleware };