Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
c8ac0498c8 | |||
ee0900f3c0 | |||
7c46d16686 | |||
10cd3b3528 | |||
0e6c09aba5 | |||
2f4916f552 | |||
29bddf198f | |||
a5ecf0d9c1 | |||
1ccd53ce69 | |||
1264542410 | |||
ba55019846 | |||
6f967553d6 | |||
64df05a868 | |||
0a8ae81fd0 |
@ -14,4 +14,4 @@
|
|||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
19
package-lock.json
generated
19
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "1.0.2",
|
"version": "1.0.9",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -247,14 +247,12 @@
|
|||||||
"@pushrocks/smartpromise": {
|
"@pushrocks/smartpromise": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.2.tgz",
|
||||||
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ==",
|
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@pushrocks/smartrequest": {
|
"@pushrocks/smartrequest": {
|
||||||
"version": "1.1.19",
|
"version": "1.1.19",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.19.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.19.tgz",
|
||||||
"integrity": "sha512-puCBwk85JSOFCUU40EFxTk8yATCLEH90iaDycoWaR0ykOq1nSIWviyi49t4UUYM7lAjmTmMeTT+qOVF+508U2Q==",
|
"integrity": "sha512-puCBwk85JSOFCUU40EFxTk8yATCLEH90iaDycoWaR0ykOq1nSIWviyi49t4UUYM7lAjmTmMeTT+qOVF+508U2Q==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@types/form-data": "^2.2.1",
|
"@types/form-data": "^2.2.1",
|
||||||
@ -367,7 +365,6 @@
|
|||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.5.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.5.0.tgz",
|
||||||
"integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==",
|
"integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"form-data": "*"
|
"form-data": "*"
|
||||||
}
|
}
|
||||||
@ -465,8 +462,7 @@
|
|||||||
"asynckit": {
|
"asynckit": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/asynckit/-/asynckit-0.4.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/asynckit/-/asynckit-0.4.0.tgz",
|
||||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
|
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@ -637,7 +633,6 @@
|
|||||||
"version": "1.0.8",
|
"version": "1.0.8",
|
||||||
"resolved": "https://verdaccio.lossless.one/combined-stream/-/combined-stream-1.0.8.tgz",
|
"resolved": "https://verdaccio.lossless.one/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"delayed-stream": "~1.0.0"
|
"delayed-stream": "~1.0.0"
|
||||||
}
|
}
|
||||||
@ -717,8 +712,7 @@
|
|||||||
"delayed-stream": {
|
"delayed-stream": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"diff": {
|
"diff": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
@ -811,7 +805,6 @@
|
|||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.5.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.5.0.tgz",
|
||||||
"integrity": "sha512-WXieX3G/8side6VIqx44ablyULoGruSde5PNTxoUyo5CeyAMX6nVWUd0rgist/EuX655cjhUhTo1Fo3tRYqbcA==",
|
"integrity": "sha512-WXieX3G/8side6VIqx44ablyULoGruSde5PNTxoUyo5CeyAMX6nVWUd0rgist/EuX655cjhUhTo1Fo3tRYqbcA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"asynckit": "^0.4.0",
|
"asynckit": "^0.4.0",
|
||||||
"combined-stream": "^1.0.6",
|
"combined-stream": "^1.0.6",
|
||||||
@ -1047,14 +1040,12 @@
|
|||||||
"mime-db": {
|
"mime-db": {
|
||||||
"version": "1.40.0",
|
"version": "1.40.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz",
|
||||||
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==",
|
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"mime-types": {
|
"mime-types": {
|
||||||
"version": "2.1.24",
|
"version": "2.1.24",
|
||||||
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz",
|
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz",
|
||||||
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
|
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"mime-db": "1.40.0"
|
"mime-db": "1.40.0"
|
||||||
}
|
}
|
||||||
|
17
package.json
17
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "1.0.2",
|
"version": "1.0.9",
|
||||||
"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",
|
||||||
@ -20,5 +20,18 @@
|
|||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {
|
||||||
|
"@pushrocks/smartrequest": "^1.1.19"
|
||||||
|
},
|
||||||
|
"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)
|
@ -1,8 +1,9 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
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.standardExport)
|
const testProxy = new smartproxy.SmartProxy();
|
||||||
})
|
// await testProxy.start();
|
||||||
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
@ -1,3 +1 @@
|
|||||||
import * as plugins from './smartproxy.plugins';
|
export * from './smartproxy.classes.smartproxy';
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
|
||||||
|
7
ts/interfaces/index.ts
Normal file
7
ts/interfaces/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export interface IHostConfig {
|
||||||
|
hostName: string;
|
||||||
|
destinationIp: string;
|
||||||
|
destinationPort: number;
|
||||||
|
privateKey: string;
|
||||||
|
publicKey: string;
|
||||||
|
}
|
8
ts/smartproxy.classes.router.ts
Normal file
8
ts/smartproxy.classes.router.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import * as plugins from './smartproxy.plugins';
|
||||||
|
|
||||||
|
export class SmartproxyRouter {
|
||||||
|
|
||||||
|
public routeReq(req: plugins.http.IncomingMessage) {
|
||||||
|
return 'lossless.gmbh';
|
||||||
|
}
|
||||||
|
}
|
55
ts/smartproxy.classes.smartproxy.ts
Normal file
55
ts/smartproxy.classes.smartproxy.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import * as plugins from './smartproxy.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
|
import { SmartproxyRouter } from './smartproxy.classes.router';
|
||||||
|
|
||||||
|
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) => {
|
||||||
|
|
||||||
|
})
|
||||||
|
this.httpsServer.listen(3000);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update() {
|
||||||
|
await this.start();
|
||||||
|
}
|
||||||
|
}
|
@ -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 {
|
export {
|
||||||
removeme
|
smartrequest
|
||||||
}
|
};
|
||||||
|
Reference in New Issue
Block a user