Compare commits

...

27 Commits

Author SHA1 Message Date
3238ea5cfd 1.0.16 2019-08-21 23:55:46 +02:00
20dc9238e4 fix(core): update 2019-08-21 23:55:45 +02:00
2b9b7cf691 1.0.15 2019-08-21 23:54:56 +02:00
0b7f5c4701 fix(core): update 2019-08-21 23:54:55 +02:00
23fa6a6511 1.0.14 2019-08-21 23:41:06 +02:00
ff8e185ec3 fix(core): update 2019-08-21 23:41:06 +02:00
c32a56d921 1.0.13 2019-08-21 15:09:33 +02:00
69233e8a3b fix(core): update 2019-08-21 15:09:32 +02:00
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
11 changed files with 238 additions and 36 deletions

View File

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

60
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "1.0.2",
"version": "1.0.16",
"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",
@ -320,6 +318,11 @@
"smartchai": "^2.0.1"
}
},
"@tsclass/tsclass": {
"version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-2.0.3.tgz",
"integrity": "sha512-13bn6eLaNN2gM5+ycZjulacEzpruOVOCcEMn1+2CZ8UAZf6yhghq+hXEUxqmuf1ZVR1CF+k9HsArxFBSh1cnUQ=="
},
"@types/chai": {
"version": "4.2.0",
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.0.tgz",
@ -367,7 +370,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": "*"
}
@ -396,8 +398,7 @@
"@types/node": {
"version": "12.7.2",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.2.tgz",
"integrity": "sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg==",
"dev": true
"integrity": "sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg=="
},
"@types/vinyl": {
"version": "2.0.3",
@ -414,6 +415,14 @@
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ==",
"dev": true
},
"@types/ws": {
"version": "6.0.2",
"resolved": "https://verdaccio.lossless.one/@types%2fws/-/ws-6.0.2.tgz",
"integrity": "sha512-22XiR1ox9LftTaAtn/c5JCninwc7moaqbkJfaDUb7PkaUitcf5vbTZHdq9dxSMviCm9C3W85rzB8e6yNR70apQ==",
"requires": {
"@types/node": "*"
}
},
"@types/yargs": {
"version": "12.0.12",
"resolved": "https://verdaccio.lossless.one/@types%2fyargs/-/yargs-12.0.12.tgz",
@ -462,11 +471,15 @@
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
"dev": true
},
"async-limiter": {
"version": "1.0.1",
"resolved": "https://verdaccio.lossless.one/async-limiter/-/async-limiter-1.0.1.tgz",
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
},
"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 +650,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 +729,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 +822,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 +1057,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 +1554,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",
@ -1717,6 +1725,14 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"ws": {
"version": "7.1.2",
"resolved": "https://verdaccio.lossless.one/ws/-/ws-7.1.2.tgz",
"integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==",
"requires": {
"async-limiter": "^1.0.0"
}
},
"y18n": {
"version": "4.0.0",
"resolved": "https://verdaccio.lossless.one/y18n/-/y18n-4.0.0.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "1.0.2",
"version": "1.0.16",
"private": false,
"description": "a proxy for handling high workloads of proxying",
"main": "dist/index.js",
@ -17,8 +17,25 @@
"@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/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.20",
"@tsclass/tsclass": "^2.0.3",
"@types/ws": "^6.0.2",
"ws": "^7.1.2"
},
"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,18 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartproxy from '../ts/index'
import * as smartproxy from '../ts/index';
let testProxy: smartproxy.SmartProxy;
tap.test('first test', async () => {
console.log(smartproxy.standardExport)
})
testProxy = new smartproxy.SmartProxy();
});
tap.start()
tap.test('should start the testproxy', async () => {
await testProxy.start();
});
tap.test('should close the testproxy', async () => {
await testProxy.stop();
});
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,80 @@
import * as plugins from './smartproxy.plugins';
import * as interfaces from './interfaces';
import { SmartproxyRouter } from './smartproxy.classes.router';
export class ProxyWorker {
public httpsServer: plugins.https.Server | plugins.http.Server;
public router = new SmartproxyRouter();
/**
* 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
}); */
}
// Enable websockets
const wss = new plugins.ws.Server({ server: this.httpsServer });
wss.on('connection', function connection(ws) {
const wscConnected = plugins.smartpromise.defer();
const wsc = new plugins.ws(`${ws.url}`);
wsc.on('open', () => {
wscConnected.resolve();
});
ws.on('message', async (message) => {
await wscConnected.promise;
wsc.emit('message', message);
});
wsc.on('message', (message) => {
ws.emit('message', message);
});
// handle closing
ws.on('close', (message) => {
wsc.close();
});
wsc.on('close', (message) => {
ws.close();
});
});
this.httpsServer.listen(3000);
}
public async update() {
await this.start();
}
public async stop() {
const done = plugins.smartpromise.defer();
this.httpsServer.close(() => {
done.resolve();
});
}
}

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,22 @@
import * as plugins from './smartproxy.plugins';
import * as interfaces from './interfaces';
export class SmartProxy {
public hostCandidates: interfaces.IHostConfig[] = [];
public addHostCandidate(hostCandidate: interfaces.IHostConfig) {
// TODO search for old hostCandidates with that target
this.hostCandidates.push(hostCandidate);
}
async start () {
}
async stop () {
}
}

View File

@ -1,4 +1,22 @@
const removeme = {};
// node native scope
import crypto from 'crypto';
import http from 'http';
import https from 'https';
export { crypto, http, https };
// pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
export {
removeme
}
smartrequest,
smartpromise
};
// third party scope
import ws from 'ws';
export {
ws
};