Compare commits

...

19 Commits

Author SHA1 Message Date
23e6977d81 1.0.12 2019-08-21 15:07:47 +02:00
9f57b3b638 1.0.11 2019-08-21 13:06:14 +02:00
5df0a53efe fix(core): update 2019-08-21 13:06:13 +02:00
6d1a781b9a 1.0.10 2019-08-21 13:04:00 +02:00
81c9f3b72e fix(core): update 2019-08-21 13:04:00 +02:00
c8ac0498c8 1.0.9 2019-08-21 03:20:41 +02:00
ee0900f3c0 fix(core): update 2019-08-21 03:20:40 +02:00
7c46d16686 1.0.8 2019-08-21 03:14:42 +02:00
10cd3b3528 fix(core): update 2019-08-21 03:14:42 +02:00
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
ba55019846 1.0.4 2019-08-20 18:43:15 +02:00
6f967553d6 fix(core): update 2019-08-20 18:43:15 +02:00
64df05a868 1.0.3 2019-08-20 18:42:53 +02:00
0a8ae81fd0 fix(core): update 2019-08-20 18:42:52 +02:00
10 changed files with 142 additions and 34 deletions

View File

@ -14,4 +14,4 @@
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}
}

31
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "1.0.2",
"version": "1.0.12",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -247,14 +247,12 @@
"@pushrocks/smartpromise": {
"version": "3.0.2",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.2.tgz",
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ==",
"dev": true
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ=="
},
"@pushrocks/smartrequest": {
"version": "1.1.19",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.19.tgz",
"integrity": "sha512-puCBwk85JSOFCUU40EFxTk8yATCLEH90iaDycoWaR0ykOq1nSIWviyi49t4UUYM7lAjmTmMeTT+qOVF+508U2Q==",
"dev": true,
"version": "1.1.20",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.20.tgz",
"integrity": "sha512-3qOrxZT9+Fhr4GD/dFH+xDHYuSUTStbJl6/jNyh6W0d1L64zH2wfuG8MwlHc3CUHFXPaGauwK+4LQ91JEUx8TQ==",
"requires": {
"@pushrocks/smartpromise": "^3.0.2",
"@types/form-data": "^2.2.1",
@ -367,7 +365,6 @@
"version": "2.5.0",
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.5.0.tgz",
"integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==",
"dev": true,
"requires": {
"form-data": "*"
}
@ -465,8 +462,7 @@
"asynckit": {
"version": "0.4.0",
"resolved": "https://verdaccio.lossless.one/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"balanced-match": {
"version": "1.0.0",
@ -637,7 +633,6 @@
"version": "1.0.8",
"resolved": "https://verdaccio.lossless.one/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"requires": {
"delayed-stream": "~1.0.0"
}
@ -717,8 +712,7 @@
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"diff": {
"version": "4.0.1",
@ -811,7 +805,6 @@
"version": "2.5.0",
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.5.0.tgz",
"integrity": "sha512-WXieX3G/8side6VIqx44ablyULoGruSde5PNTxoUyo5CeyAMX6nVWUd0rgist/EuX655cjhUhTo1Fo3tRYqbcA==",
"dev": true,
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
@ -1047,14 +1040,12 @@
"mime-db": {
"version": "1.40.0",
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==",
"dev": true
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
},
"mime-types": {
"version": "2.1.24",
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"dev": true,
"requires": {
"mime-db": "1.40.0"
}
@ -1546,9 +1537,9 @@
"dev": true
},
"tslint": {
"version": "5.18.0",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.18.0.tgz",
"integrity": "sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==",
"version": "5.19.0",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.19.0.tgz",
"integrity": "sha512-1LwwtBxfRJZnUvoS9c0uj8XQtAnyhWr9KlNvDIdB+oXyT+VpsOAaEhEgKi1HrZ8rq0ki/AAnbGSv4KM6/AfVZw==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "1.0.2",
"version": "1.0.12",
"private": false,
"description": "a proxy for handling high workloads of proxying",
"main": "dist/index.js",
@ -17,8 +17,21 @@
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^12.7.2",
"tslint": "^5.11.0",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {}
"dependencies": {
"@pushrocks/smartrequest": "^1.1.20"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

26
readme.md Normal file
View 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
[![build status](https://gitlab.com/pushrocks/smartproxy/badges/master/build.svg)](https://gitlab.com/pushrocks/smartproxy/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartproxy/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartproxy/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartproxy.svg)](https://www.npmjs.com/package/@pushrocks/smartproxy)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartproxy/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartproxy)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](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)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

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

View File

@ -1,3 +1 @@
import * as plugins from './smartproxy.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
export * from './smartproxy.classes.smartproxy';

7
ts/interfaces/index.ts Normal file
View File

@ -0,0 +1,7 @@
export interface IHostConfig {
hostName: string;
destinationIp: string;
destinationPort: number;
privateKey: string;
publicKey: string;
}

View File

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

View File

@ -0,0 +1,56 @@
import * as plugins from './smartproxy.plugins';
import * as interfaces from './interfaces';
import { SmartproxyRouter } from './smartproxy.classes.router';
import { Socket } from 'net';
export class SmartProxy {
public httpsServer: plugins.https.Server | plugins.http.Server;
public router = new SmartproxyRouter();
public hostCandidates: interfaces.IHostConfig[] = [];
public addHostCandidate(hostCandidate: interfaces.IHostConfig) {
// TODO search for old hostCandidates with that target
this.hostCandidates.push(hostCandidate);
}
/**
* starts the proxyInstance
*/
public async start() {
this.httpsServer = plugins.http.createServer(async (req, res) => {
req.headers.host = this.router.routeReq(req);
const response = await plugins.smartrequest.request(`https://${req.headers.host}${req.url}`, {
method: req.method,
headers: req.headers
}, true);
res.statusCode = response.statusCode;
for (const header of Object.keys(response.headers)) {
res.setHeader(header, response.headers[header]);
}
response.on('data', data => {
res.write(data);
});
response.on('end', () => {
res.end();
});
});
for (const hostCandidate of this.hostCandidates) {
/* this.httpsServer.addContext(hostCandidate.hostName, {
cert: hostCandidate.publicKey,
key: hostCandidate.privateKey
}); */
}
this.httpsServer.on('upgrade', (req, socket: Socket) => {
})
this.httpsServer.listen(3000);
}
public async update() {
await this.start();
}
}

View File

@ -1,4 +1,12 @@
const removeme = {};
// node native scope
import * as http from 'http';
import * as https from 'https';
export { http, https };
// pushrocks scope
import * as smartrequest from '@pushrocks/smartrequest';
export {
removeme
}
smartrequest
};