@push.rocks/smartproxy 11.0.0 → 12.0.0

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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartproxy',
6
- version: '11.0.0',
6
+ version: '12.0.0',
7
7
  description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLG1PQUFtTztDQUNqUCxDQUFBIn0=
@@ -12,5 +12,5 @@ export declare const helpers: {
12
12
  httpOnly: (partialConfig: Partial<import("../types/forwarding.types.js").IForwardConfig> & Pick<import("../types/forwarding.types.js").IForwardConfig, "target">) => import("../types/forwarding.types.js").IForwardConfig;
13
13
  tlsTerminateToHttp: (partialConfig: Partial<import("../types/forwarding.types.js").IForwardConfig> & Pick<import("../types/forwarding.types.js").IForwardConfig, "target">) => import("../types/forwarding.types.js").IForwardConfig;
14
14
  tlsTerminateToHttps: (partialConfig: Partial<import("../types/forwarding.types.js").IForwardConfig> & Pick<import("../types/forwarding.types.js").IForwardConfig, "target">) => import("../types/forwarding.types.js").IForwardConfig;
15
- sniPassthrough: (partialConfig: Partial<import("../types/forwarding.types.js").IForwardConfig> & Pick<import("../types/forwarding.types.js").IForwardConfig, "target">) => import("../types/forwarding.types.js").IForwardConfig;
15
+ httpsPassthrough: (partialConfig: Partial<import("../types/forwarding.types.js").IForwardConfig> & Pick<import("../types/forwarding.types.js").IForwardConfig, "target">) => import("../types/forwarding.types.js").IForwardConfig;
16
16
  };
@@ -18,6 +18,6 @@ export const helpers = {
18
18
  httpOnly,
19
19
  tlsTerminateToHttp,
20
20
  tlsTerminateToHttps,
21
- sniPassthrough: httpsPassthrough // Alias for backward compatibility
21
+ httpsPassthrough
22
22
  };
23
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi90cy9zbWFydHByb3h5L2ZvcndhcmRpbmcvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBYUEsZ0JBQWdCO0FBQ2hCLE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsUUFBUSxFQUNSLGtCQUFrQixFQUNsQixtQkFBbUIsRUFDbkIsZ0JBQWdCLEVBQ2pCLE1BQU0sOEJBQThCLENBQUM7QUFFdEMsOEJBQThCO0FBQzlCLGNBQWMsb0JBQW9CLENBQUM7QUFFbkMsa0JBQWtCO0FBQ2xCLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzVELE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQzFELE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pFLE9BQU8sRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBQ25GLE9BQU8sRUFBRSw0QkFBNEIsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBRXJGLGlCQUFpQjtBQUNqQixPQUFPLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVuRSxp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xNQUFNLHVDQUF1QyxDQUFDO0FBRXJGLGlCQUFpQjtBQUNqQixPQUFPLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVuRSxpQkFBaUI7QUFDakIsT0FBTyxFQUFFLGFBQWEsRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRXpFLDJDQUEyQztBQUMzQyxPQUFPLEVBQ0wsUUFBUSxFQUNSLGtCQUFrQixFQUNsQixtQkFBbUIsRUFDbkIsZ0JBQWdCLEVBQ2pCLE1BQU0sOEJBQThCLENBQUM7QUFFdEMsTUFBTSxDQUFDLE1BQU0sT0FBTyxHQUFHO0lBQ3JCLFFBQVE7SUFDUixrQkFBa0I7SUFDbEIsbUJBQW1CO0lBQ25CLGdCQUFnQjtDQUNqQixDQUFDIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartproxy",
3
- "version": "11.0.0",
3
+ "version": "12.0.0",
4
4
  "private": false,
5
5
  "description": "A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.",
6
6
  "main": "dist_ts/index.js",
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartproxy',
6
- version: '11.0.0',
6
+ version: '12.0.0',
7
7
  description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.'
8
8
  }
@@ -48,5 +48,5 @@ export const helpers = {
48
48
  httpOnly,
49
49
  tlsTerminateToHttp,
50
50
  tlsTerminateToHttps,
51
- sniPassthrough: httpsPassthrough // Alias for backward compatibility
51
+ httpsPassthrough
52
52
  };
@@ -1,128 +0,0 @@
1
- import * as plugins from '../plugins.js';
2
- import { createServer } from 'http';
3
- import { Socket } from 'net';
4
- import {
5
- DomainManager,
6
- DomainManagerEvents,
7
- createDomainConfig,
8
- helpers
9
- } from '../smartproxy/forwarding/index.js';
10
-
11
- /**
12
- * Example showing how to use the unified forwarding system
13
- */
14
- async function main() {
15
- console.log('Initializing forwarding example...');
16
-
17
- // Create the domain manager
18
- const domainManager = new DomainManager();
19
-
20
- // Set up event listeners
21
- domainManager.on(DomainManagerEvents.DOMAIN_ADDED, (data) => {
22
- console.log(`Domain added: ${data.domains.join(', ')} (${data.forwardingType})`);
23
- });
24
-
25
- domainManager.on(DomainManagerEvents.DOMAIN_MATCHED, (data) => {
26
- console.log(`Domain matched: ${data.domain} (${data.handlerType})`);
27
- });
28
-
29
- domainManager.on(DomainManagerEvents.DOMAIN_MATCH_FAILED, (data) => {
30
- console.log(`Domain match failed: ${data.domain}`);
31
- });
32
-
33
- domainManager.on(DomainManagerEvents.ERROR, (data) => {
34
- console.error(`Error:`, data);
35
- });
36
-
37
- // Add example domains with different forwarding types
38
-
39
- // Example 1: HTTP-only forwarding
40
- await domainManager.addDomainConfig(
41
- createDomainConfig('example.com', helpers.httpOnly({
42
- target: { host: 'localhost', port: 3000 }
43
- }))
44
- );
45
-
46
- // Example 2: HTTPS termination with HTTP backend
47
- await domainManager.addDomainConfig(
48
- createDomainConfig('secure.example.com', helpers.tlsTerminateToHttp({
49
- target: { host: 'localhost', port: 3000 }
50
- }))
51
- );
52
-
53
- // Example 3: HTTPS termination with HTTPS backend
54
- await domainManager.addDomainConfig(
55
- createDomainConfig('api.example.com', helpers.tlsTerminateToHttps({
56
- target: { host: 'localhost', port: 8443 }
57
- }))
58
- );
59
-
60
- // Example 4: SNI passthrough
61
- await domainManager.addDomainConfig(
62
- createDomainConfig('passthrough.example.com', helpers.sniPassthrough({
63
- target: { host: '10.0.0.5', port: 443 }
64
- }))
65
- );
66
-
67
- // Example 5: Custom configuration for a more complex setup
68
- await domainManager.addDomainConfig(
69
- createDomainConfig(['*.example.com', '*.example.org'], {
70
- type: 'https-terminate-to-http',
71
- target: {
72
- host: ['10.0.0.10', '10.0.0.11'], // Round-robin load balancing
73
- port: 8080
74
- },
75
- http: {
76
- enabled: true,
77
- redirectToHttps: false // Allow both HTTP and HTTPS
78
- },
79
- acme: {
80
- enabled: true,
81
- maintenance: true,
82
- production: false, // Use staging for testing
83
- forwardChallenges: {
84
- host: '192.168.1.100',
85
- port: 8080
86
- }
87
- },
88
- security: {
89
- allowedIps: ['10.0.0.*', '192.168.1.*'],
90
- maxConnections: 100
91
- },
92
- advanced: {
93
- headers: {
94
- 'X-Forwarded-For': '{clientIp}',
95
- 'X-Forwarded-Host': '{sni}'
96
- }
97
- }
98
- })
99
- );
100
-
101
- // Create a simple HTTP server to demonstrate HTTP handler
102
- const httpServer = createServer((req, res) => {
103
- // Extract the domain from the Host header
104
- const domain = req.headers.host?.split(':')[0] || 'unknown';
105
-
106
- // Forward the request to the appropriate handler
107
- if (!domainManager.handleHttpRequest(domain, req, res)) {
108
- // No handler found, send a default response
109
- res.statusCode = 404;
110
- res.end(`No handler found for domain: ${domain}`);
111
- }
112
- });
113
-
114
- // Listen on HTTP port
115
- httpServer.listen(80, () => {
116
- console.log('HTTP server listening on port 80');
117
- });
118
-
119
- // For HTTPS and SNI, we would need to set up a TLS server
120
- // This is a simplified example that just shows how the domain manager works
121
-
122
- console.log('Forwarding example initialized successfully');
123
- }
124
-
125
- // Run the example
126
- main().catch(error => {
127
- console.error('Error running example:', error);
128
- });