Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
0e6c09aba5 | |||
2f4916f552 | |||
29bddf198f | |||
a5ecf0d9c1 | |||
1ccd53ce69 | |||
1264542410 | |||
ba55019846 | |||
6f967553d6 |
@ -14,4 +14,4 @@
|
|||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "1.0.3",
|
"version": "1.0.7",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
15
package.json
15
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "1.0.3",
|
"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",
|
||||||
@ -25,5 +25,16 @@
|
|||||||
"@types/http-proxy-middleware": "^0.19.3",
|
"@types/http-proxy-middleware": "^0.19.3",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"http-proxy-middleware": "^0.19.1"
|
"http-proxy-middleware": "^0.19.1"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
26
readme.md
Normal file
26
readme.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# @pushrocks/smartproxy
|
||||||
|
a proxy for handling high workloads of proxying
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartproxy)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartproxy)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartproxy)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartproxy/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smartproxy/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/smartproxy/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/smartproxy)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/smartproxy)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
@ -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,7 +1,7 @@
|
|||||||
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,5 +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[] = [];
|
||||||
@ -13,14 +13,35 @@ export class SmartProxy {
|
|||||||
public addHostCandidate(hostCandidate: interfaces.IHostConfig) {
|
public addHostCandidate(hostCandidate: interfaces.IHostConfig) {
|
||||||
// TODO search for old hostCandidates with that target
|
// TODO search for old hostCandidates with that target
|
||||||
this.hostCandidates.push(hostCandidate);
|
this.hostCandidates.push(hostCandidate);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* starts the proxyInstance
|
* starts the proxyInstance
|
||||||
*/
|
*/
|
||||||
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,15 +1,11 @@
|
|||||||
// node native scope
|
// node native scope
|
||||||
|
import * as http from 'http';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
|
|
||||||
export {
|
export { http, https };
|
||||||
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 {
|
export { express, httpProxyMiddleware };
|
||||||
express,
|
|
||||||
httpProxyMiddleware
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user