Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
23e6977d81 | |||
9f57b3b638 | |||
5df0a53efe | |||
6d1a781b9a | |||
81c9f3b72e | |||
c8ac0498c8 | |||
ee0900f3c0 | |||
7c46d16686 | |||
10cd3b3528 | |||
0e6c09aba5 | |||
2f4916f552 | |||
29bddf198f | |||
a5ecf0d9c1 | |||
1ccd53ce69 | |||
1264542410 | |||
ba55019846 | |||
6f967553d6 | |||
64df05a868 | |||
0a8ae81fd0 |
@ -14,4 +14,4 @@
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
}
|
||||
}
|
||||
}
|
31
package-lock.json
generated
31
package-lock.json
generated
@ -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",
|
||||
|
19
package.json
19
package.json
@ -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
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 * 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();
|
||||
|
@ -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
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';
|
||||
}
|
||||
}
|
56
ts/smartproxy.classes.smartproxy.ts
Normal file
56
ts/smartproxy.classes.smartproxy.ts
Normal 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
|
Reference in New Issue
Block a user