@push.rocks/smartproxy 3.0.58 → 3.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/smartproxy.classes.proxyworker.d.ts +23 -0
- package/dist/smartproxy.classes.proxyworker.js +262 -0
- package/dist/smartproxy.classes.router.d.ts +16 -0
- package/dist/smartproxy.classes.router.js +41 -0
- package/dist/smartproxy.classes.smartproxy.d.ts +17 -0
- package/dist/smartproxy.classes.smartproxy.js +43 -0
- package/dist/smartproxy.plugins.d.ts +17 -0
- package/dist/smartproxy.plugins.js +43 -0
- package/dist/smartproxy.portproxy.d.ts +6 -0
- package/dist/smartproxy.portproxy.js +38 -0
- package/dist_ts/00_commitinfo_data.d.ts +1 -1
- package/dist_ts/00_commitinfo_data.js +4 -4
- package/dist_ts/index.js +1 -1
- package/dist_ts/smartproxy.classes.networkproxy.js +81 -63
- package/dist_ts/smartproxy.classes.proxyworker.d.ts +33 -0
- package/dist_ts/smartproxy.classes.proxyworker.js +303 -0
- package/dist_ts/smartproxy.classes.router.js +2 -2
- package/dist_ts/smartproxy.classes.smartproxy.d.ts +20 -0
- package/dist_ts/smartproxy.classes.smartproxy.js +38 -0
- package/dist_ts/smartproxy.plugins.d.ts +5 -5
- package/dist_ts/smartproxy.plugins.js +6 -6
- package/npmextra.json +20 -4
- package/package.json +39 -21
- package/readme.hints.md +1 -0
- package/readme.md +109 -32
- package/ts/00_commitinfo_data.ts +3 -3
- package/ts/index.ts +1 -1
- package/ts/smartproxy.classes.networkproxy.ts +131 -101
- package/ts/smartproxy.classes.sslredirect.ts +1 -1
- package/ts/smartproxy.plugins.ts +5 -5
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as plugins from './smartproxy.plugins.js';
|
|
2
|
+
import './smartproxy.classes.proxyworker.js';
|
|
3
|
+
import './smartproxy.portproxy.js';
|
|
4
|
+
export class SmartProxy {
|
|
5
|
+
constructor(optionsArg = {}) {
|
|
6
|
+
this.smartsystem = new plugins.smartsystem.Smartsystem();
|
|
7
|
+
this.reverseConfigs = [];
|
|
8
|
+
this.options = optionsArg;
|
|
9
|
+
}
|
|
10
|
+
async updateReverseConfigs(reverseConfigsArg) {
|
|
11
|
+
// TODO search for old hostCandidates with that target
|
|
12
|
+
this.reverseConfigs = reverseConfigsArg;
|
|
13
|
+
if (this.proxyWorkerFunctions) {
|
|
14
|
+
await this.proxyWorkerFunctions.updateReverseConfigs(this.reverseConfigs);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async start() {
|
|
18
|
+
this.proxyWorkerFunctions = await plugins.smartspawn.spawn(new plugins.smartspawn.Worker('./smartproxy.classes.proxyworker'));
|
|
19
|
+
this.proxyWorkerFunctions.updateReverseConfigs(this.reverseConfigs);
|
|
20
|
+
this.portProxyFunctions = await plugins.smartspawn.spawn(new plugins.smartspawn.Worker('./smartproxy.portproxy'));
|
|
21
|
+
await this.portProxyFunctions.start(this.options.port);
|
|
22
|
+
await this.proxyWorkerFunctions.start();
|
|
23
|
+
console.log('successfully spawned portproxy and proxyworkers!');
|
|
24
|
+
}
|
|
25
|
+
async updateDefaultHeaders(defaultHeadersArg) {
|
|
26
|
+
await this.proxyWorkerFunctions.addDefaultHeaders(defaultHeadersArg);
|
|
27
|
+
}
|
|
28
|
+
async stop() {
|
|
29
|
+
await this.proxyWorkerFunctions.stop();
|
|
30
|
+
await plugins.smartspawn.Thread.terminate(this.proxyWorkerFunctions);
|
|
31
|
+
console.log('proxy worker stopped');
|
|
32
|
+
await this.portProxyFunctions.stop();
|
|
33
|
+
await plugins.smartspawn.Thread.terminate(this.portProxyFunctions);
|
|
34
|
+
console.log('portproxy stopped');
|
|
35
|
+
console.log('Terminated all childs!');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRwcm94eS5jbGFzc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ixDQUFDLENBQUM7SUFDeEMsQ0FBQztDQUNGIn0=
|
|
@@ -5,11 +5,11 @@ import * as url from 'url';
|
|
|
5
5
|
export { http, https, net, url };
|
|
6
6
|
import * as tsclass from '@tsclass/tsclass';
|
|
7
7
|
export { tsclass };
|
|
8
|
-
import * as lik from '@
|
|
9
|
-
import * as smartdelay from '@
|
|
10
|
-
import * as smartpromise from '@
|
|
11
|
-
import * as smartrequest from '@
|
|
12
|
-
import * as smartstring from '@
|
|
8
|
+
import * as lik from '@push.rocks/lik';
|
|
9
|
+
import * as smartdelay from '@push.rocks/smartdelay';
|
|
10
|
+
import * as smartpromise from '@push.rocks/smartpromise';
|
|
11
|
+
import * as smartrequest from '@push.rocks/smartrequest';
|
|
12
|
+
import * as smartstring from '@push.rocks/smartstring';
|
|
13
13
|
export { lik, smartdelay, smartrequest, smartpromise, smartstring };
|
|
14
14
|
import * as ws from 'ws';
|
|
15
15
|
import wsDefault from 'ws';
|
|
@@ -8,14 +8,14 @@ export { http, https, net, url };
|
|
|
8
8
|
import * as tsclass from '@tsclass/tsclass';
|
|
9
9
|
export { tsclass };
|
|
10
10
|
// pushrocks scope
|
|
11
|
-
import * as lik from '@
|
|
12
|
-
import * as smartdelay from '@
|
|
13
|
-
import * as smartpromise from '@
|
|
14
|
-
import * as smartrequest from '@
|
|
15
|
-
import * as smartstring from '@
|
|
11
|
+
import * as lik from '@push.rocks/lik';
|
|
12
|
+
import * as smartdelay from '@push.rocks/smartdelay';
|
|
13
|
+
import * as smartpromise from '@push.rocks/smartpromise';
|
|
14
|
+
import * as smartrequest from '@push.rocks/smartrequest';
|
|
15
|
+
import * as smartstring from '@push.rocks/smartstring';
|
|
16
16
|
export { lik, smartdelay, smartrequest, smartpromise, smartstring };
|
|
17
17
|
// third party scope
|
|
18
18
|
import * as ws from 'ws';
|
|
19
19
|
import wsDefault from 'ws';
|
|
20
20
|
export { wsDefault, ws };
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
21
|
+
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0FBRTNCLE9BQU8sRUFBRSxTQUFTLEVBQUUsRUFBRSxFQUFFLENBQUMifQ==
|
package/npmextra.json
CHANGED
|
@@ -2,17 +2,33 @@
|
|
|
2
2
|
"gitzone": {
|
|
3
3
|
"projectType": "npm",
|
|
4
4
|
"module": {
|
|
5
|
-
"githost": "
|
|
6
|
-
"gitscope": "
|
|
5
|
+
"githost": "code.foss.global",
|
|
6
|
+
"gitscope": "push.rocks",
|
|
7
7
|
"gitrepo": "smartproxy",
|
|
8
8
|
"description": "a proxy for handling high workloads of proxying",
|
|
9
|
-
"npmPackagename": "@
|
|
9
|
+
"npmPackagename": "@push.rocks/smartproxy",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"projectDomain": "push.rocks"
|
|
11
|
+
"projectDomain": "push.rocks",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"proxy",
|
|
14
|
+
"network traffic",
|
|
15
|
+
"high workload",
|
|
16
|
+
"http",
|
|
17
|
+
"https",
|
|
18
|
+
"websocket",
|
|
19
|
+
"network routing",
|
|
20
|
+
"ssl redirect",
|
|
21
|
+
"port mapping",
|
|
22
|
+
"reverse proxy",
|
|
23
|
+
"authentication"
|
|
24
|
+
]
|
|
12
25
|
}
|
|
13
26
|
},
|
|
14
27
|
"npmci": {
|
|
15
28
|
"npmGlobalTools": [],
|
|
16
29
|
"npmAccessLevel": "public"
|
|
30
|
+
},
|
|
31
|
+
"tsdoc": {
|
|
32
|
+
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
|
17
33
|
}
|
|
18
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartproxy",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.61",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "a proxy for handling high workloads of proxying",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
@@ -8,28 +8,22 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"author": "Lossless GmbH",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "(tstest test/)",
|
|
13
|
-
"build": "(tsbuild --web --allowimplicitany)",
|
|
14
|
-
"format": "(gitzone format)",
|
|
15
|
-
"buildDocs": "tsdoc"
|
|
16
|
-
},
|
|
17
11
|
"devDependencies": {
|
|
18
|
-
"@gitzone/tsbuild": "^2.1.
|
|
19
|
-
"@gitzone/tsrun": "^1.2.
|
|
20
|
-
"@gitzone/tstest": "^1.0.
|
|
21
|
-
"@
|
|
22
|
-
"@types/node": "^
|
|
12
|
+
"@gitzone/tsbuild": "^2.1.66",
|
|
13
|
+
"@gitzone/tsrun": "^1.2.44",
|
|
14
|
+
"@gitzone/tstest": "^1.0.77",
|
|
15
|
+
"@push.rocks/tapbundle": "^5.0.12",
|
|
16
|
+
"@types/node": "^20.4.5"
|
|
23
17
|
},
|
|
24
18
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@tsclass/tsclass": "^4.0.
|
|
31
|
-
"@types/ws": "^8.5.
|
|
32
|
-
"ws": "^8.
|
|
19
|
+
"@push.rocks/lik": "^6.0.3",
|
|
20
|
+
"@push.rocks/smartdelay": "^3.0.5",
|
|
21
|
+
"@push.rocks/smartpromise": "^4.0.3",
|
|
22
|
+
"@push.rocks/smartrequest": "^2.0.18",
|
|
23
|
+
"@push.rocks/smartstring": "^4.0.7",
|
|
24
|
+
"@tsclass/tsclass": "^4.0.42",
|
|
25
|
+
"@types/ws": "^8.5.5",
|
|
26
|
+
"ws": "^8.13.0"
|
|
33
27
|
},
|
|
34
28
|
"files": [
|
|
35
29
|
"ts/**/*",
|
|
@@ -45,5 +39,29 @@
|
|
|
45
39
|
],
|
|
46
40
|
"browserslist": [
|
|
47
41
|
"last 1 chrome versions"
|
|
48
|
-
]
|
|
42
|
+
],
|
|
43
|
+
"keywords": [
|
|
44
|
+
"proxy",
|
|
45
|
+
"network traffic",
|
|
46
|
+
"high workload",
|
|
47
|
+
"http",
|
|
48
|
+
"https",
|
|
49
|
+
"websocket",
|
|
50
|
+
"network routing",
|
|
51
|
+
"ssl redirect",
|
|
52
|
+
"port mapping",
|
|
53
|
+
"reverse proxy",
|
|
54
|
+
"authentication"
|
|
55
|
+
],
|
|
56
|
+
"homepage": "https://code.foss.global/push.rocks/smartproxy",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "https://code.foss.global/push.rocks/smartproxy.git"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"test": "(tstest test/)",
|
|
63
|
+
"build": "(tsbuild --web --allowimplicitany)",
|
|
64
|
+
"format": "(gitzone format)",
|
|
65
|
+
"buildDocs": "tsdoc"
|
|
66
|
+
}
|
|
49
67
|
}
|
package/readme.hints.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/readme.md
CHANGED
|
@@ -1,41 +1,118 @@
|
|
|
1
|
-
# @
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Status Category | Status Badge
|
|
13
|
-
-- | --
|
|
14
|
-
GitLab Pipelines | [](https://lossless.cloud)
|
|
15
|
-
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
16
|
-
npm | [](https://lossless.cloud)
|
|
17
|
-
Snyk | [](https://lossless.cloud)
|
|
18
|
-
TypeScript Support | [](https://lossless.cloud)
|
|
19
|
-
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
20
|
-
Code Style | [](https://lossless.cloud)
|
|
21
|
-
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
22
|
-
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
23
|
-
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
24
|
-
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
1
|
+
# @push.rocks/smartproxy
|
|
2
|
+
A proxy for handling high workloads of proxying.
|
|
3
|
+
|
|
4
|
+
## Install
|
|
5
|
+
To install `@push.rocks/smartproxy`, run the following command in your project's root directory:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @push.rocks/smartproxy --save
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This will add `@push.rocks/smartproxy` to your project's dependencies.
|
|
25
12
|
|
|
26
13
|
## Usage
|
|
27
14
|
|
|
28
|
-
|
|
15
|
+
`@push.rocks/smartproxy` is a versatile package for setting up and handling proxies with various capabilities such as SSL redirection, port proxying, and creating network proxies with complex routing rules. Below is a comprehensive guide on using its features.
|
|
16
|
+
|
|
17
|
+
### Setting Up a Network Proxy
|
|
18
|
+
|
|
19
|
+
Create a network proxy to route incoming HTTPS requests to different local servers based on the hostname.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { NetworkProxy } from '@push.rocks/smartproxy';
|
|
23
|
+
|
|
24
|
+
// Instantiate the NetworkProxy with desired options
|
|
25
|
+
const myNetworkProxy = new NetworkProxy({ port: 443 });
|
|
26
|
+
|
|
27
|
+
// Define your reverse proxy configurations
|
|
28
|
+
const proxyConfigs = [
|
|
29
|
+
{
|
|
30
|
+
destinationIp: '127.0.0.1',
|
|
31
|
+
destinationPort: '3000',
|
|
32
|
+
hostName: 'example.com',
|
|
33
|
+
privateKey: `-----BEGIN PRIVATE KEY-----
|
|
34
|
+
PRIVATE_KEY_CONTENT
|
|
35
|
+
-----END PRIVATE KEY-----`,
|
|
36
|
+
publicKey: `-----BEGIN CERTIFICATE-----
|
|
37
|
+
CERTIFICATE_CONTENT
|
|
38
|
+
-----END CERTIFICATE-----`,
|
|
39
|
+
},
|
|
40
|
+
// Add more reverse proxy configurations here
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// Start the network proxy
|
|
44
|
+
await myNetworkProxy.start();
|
|
45
|
+
|
|
46
|
+
// Update proxy configurations dynamically
|
|
47
|
+
await myNetworkProxy.updateProxyConfigs(proxyConfigs);
|
|
48
|
+
|
|
49
|
+
// Optionally, add default headers to all responses
|
|
50
|
+
await myNetworkProxy.addDefaultHeaders({
|
|
51
|
+
'X-Powered-By': 'smartproxy',
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Port Proxying
|
|
56
|
+
|
|
57
|
+
You can also set up a port proxy to forward traffic from one port to another, which is useful for dynamic port forwarding scenarios.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { PortProxy } from '@push.rocks/smartproxy';
|
|
61
|
+
|
|
62
|
+
// Create a PortProxy to forward traffic from port 5000 to port 3000
|
|
63
|
+
const myPortProxy = new PortProxy(5000, 3000);
|
|
64
|
+
|
|
65
|
+
// Start the port proxy
|
|
66
|
+
await myPortProxy.start();
|
|
67
|
+
|
|
68
|
+
// To stop the port proxy, simply call
|
|
69
|
+
await myPortProxy.stop();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Enabling SSL Redirection
|
|
73
|
+
|
|
74
|
+
Easily redirect HTTP traffic to HTTPS using the `SslRedirect` class. This is particularly useful when ensuring all traffic uses encryption.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { SslRedirect } from '@push.rocks/smartproxy';
|
|
78
|
+
|
|
79
|
+
// Instantiate the SslRedirect on port 80 (HTTP)
|
|
80
|
+
const mySslRedirect = new SslRedirect(80);
|
|
81
|
+
|
|
82
|
+
// Start listening and redirecting to HTTPS
|
|
83
|
+
await mySslRedirect.start();
|
|
84
|
+
|
|
85
|
+
// To stop the redirection, use
|
|
86
|
+
await mySslRedirect.stop();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Advanced Usage
|
|
90
|
+
|
|
91
|
+
The package integrates seamlessly with TypeScript, allowing for advanced use cases, such as implementing custom routing logic, authentication mechanisms, and handling WebSocket connections through the network proxy.
|
|
92
|
+
|
|
93
|
+
For a more advanced setup involving WebSocket proxying and dynamic configuration reloading, refer to the network proxy example provided above. The WebSocket support demonstrates how seamless it is to work with real-time applications.
|
|
94
|
+
|
|
95
|
+
Remember, when dealing with certificates and private keys for HTTPS configurations, always secure your keys and store them appropriately.
|
|
96
|
+
|
|
97
|
+
`@push.rocks/smartproxy` provides a solid foundation for handling high workloads and complex proxying requirements with ease, whether you're implementing SSL redirections, port forwarding, or extensive routing and WebSocket support in your network.
|
|
98
|
+
|
|
99
|
+
For more information on how to use the features, refer to the in-depth documentation available in the package's repository or the npm package description.
|
|
100
|
+
|
|
101
|
+
## License and Legal Information
|
|
102
|
+
|
|
103
|
+
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
|
104
|
+
|
|
105
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
29
106
|
|
|
30
|
-
|
|
107
|
+
### Trademarks
|
|
31
108
|
|
|
32
|
-
|
|
109
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
|
33
110
|
|
|
34
|
-
|
|
111
|
+
### Company Information
|
|
35
112
|
|
|
36
|
-
|
|
113
|
+
Task Venture Capital GmbH
|
|
114
|
+
Registered at District court Bremen HRB 35230 HB, Germany
|
|
37
115
|
|
|
38
|
-
|
|
39
|
-
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
116
|
+
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
40
117
|
|
|
41
|
-
|
|
118
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* autocreated commitinfo by @
|
|
2
|
+
* autocreated commitinfo by @push.rocks/commitinfo
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
|
-
name: '@
|
|
6
|
-
version: '3.0.
|
|
5
|
+
name: '@push.rocks/smartproxy',
|
|
6
|
+
version: '3.0.61',
|
|
7
7
|
description: 'a proxy for handling high workloads of proxying'
|
|
8
8
|
}
|
package/ts/index.ts
CHANGED