Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
0e6c09aba5 | |||
2f4916f552 | |||
29bddf198f | |||
a5ecf0d9c1 | |||
1ccd53ce69 | |||
1264542410 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "1.0.4",
|
"version": "1.0.7",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "1.0.4",
|
"version": "1.0.7",
|
||||||
"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",
|
||||||
|
@ -2,7 +2,8 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
|||||||
import * as smartproxy from '../ts/index';
|
import * as smartproxy from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(smartproxy);
|
const testProxy = new smartproxy.SmartProxy();
|
||||||
|
// await testProxy.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export interface IHostConfig {
|
export interface IHostConfig {
|
||||||
hostName: string;
|
hostName: string;
|
||||||
destination: string;
|
destinationIp: string;
|
||||||
destinationPort: number;
|
destinationPort: number;
|
||||||
privateKey: string;
|
privateKey: string;
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
import * as plugins from './smartproxy.plugins';
|
import * as plugins from './smartproxy.plugins';
|
||||||
|
|
||||||
export class SmartproxyRouter {}
|
export class SmartproxyRouter {
|
||||||
|
|
||||||
|
public routeReq(req: plugins.express.Request) {
|
||||||
|
return 'https://lossless.gmbh';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { SmartproxyRouter } from './smartproxy.classes.router';
|
|||||||
|
|
||||||
export class SmartProxy {
|
export class SmartProxy {
|
||||||
public expressInstance: plugins.express.Express;
|
public expressInstance: plugins.express.Express;
|
||||||
public httpsServer: plugins.https.Server;
|
public httpsServer: plugins.https.Server | plugins.http.Server;
|
||||||
public router = new SmartproxyRouter();
|
public router = new SmartproxyRouter();
|
||||||
|
|
||||||
public hostCandidates: interfaces.IHostConfig[] = [];
|
public hostCandidates: interfaces.IHostConfig[] = [];
|
||||||
@ -20,7 +20,28 @@ export class SmartProxy {
|
|||||||
*/
|
*/
|
||||||
public async start() {
|
public async start() {
|
||||||
this.expressInstance = plugins.express();
|
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() {
|
public async update() {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
// node native scope
|
// node native scope
|
||||||
|
import * as http from 'http';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
|
|
||||||
export { https };
|
export { http, https };
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import * as httpProxyMiddleware from 'http-proxy-middleware';
|
import httpProxyMiddleware from 'http-proxy-middleware';
|
||||||
|
|
||||||
export { express, httpProxyMiddleware };
|
export { express, httpProxyMiddleware };
|
||||||
|
Reference in New Issue
Block a user