@push.rocks/smartproxy 6.0.0 → 6.0.1

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: '5.1.0',
6
+ version: '6.0.1',
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLG1PQUFtTztDQUNqUCxDQUFBIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartproxy",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
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",
package/readme.md CHANGED
@@ -15,7 +15,7 @@ flowchart TB
15
15
  direction TB
16
16
  HTTP80[HTTP Port 80\nSslRedirect]
17
17
  HTTPS443[HTTPS Port 443\nNetworkProxy]
18
- PortProxy[TCP Port Proxy\nwith SNI routing]
18
+ SmartProxy[SmartProxy\nwith SNI routing]
19
19
  NfTables[NfTablesProxy]
20
20
  Router[ProxyRouter]
21
21
  ACME[Port80Handler\nACME/Let's Encrypt]
@@ -31,16 +31,16 @@ flowchart TB
31
31
  Client -->|HTTP Request| HTTP80
32
32
  HTTP80 -->|Redirect| Client
33
33
  Client -->|HTTPS Request| HTTPS443
34
- Client -->|TLS/TCP| PortProxy
34
+ Client -->|TLS/TCP| SmartProxy
35
35
 
36
36
  HTTPS443 -->|Route Request| Router
37
37
  Router -->|Proxy Request| Service1
38
38
  Router -->|Proxy Request| Service2
39
39
 
40
- PortProxy -->|Direct TCP| Service2
41
- PortProxy -->|Direct TCP| Service3
40
+ SmartProxy -->|Direct TCP| Service2
41
+ SmartProxy -->|Direct TCP| Service3
42
42
 
43
- NfTables -.->|Low-level forwarding| PortProxy
43
+ NfTables -.->|Low-level forwarding| SmartProxy
44
44
 
45
45
  HTTP80 -.->|Challenge Response| ACME
46
46
  ACME -.->|Generate/Manage| Certs
@@ -51,7 +51,7 @@ flowchart TB
51
51
  classDef client fill:#dfd,stroke:#333,stroke-width:2px;
52
52
 
53
53
  class Client client;
54
- class HTTP80,HTTPS443,PortProxy,IPTables,Router,ACME component;
54
+ class HTTP80,HTTPS443,SmartProxy,NfTables,Router,ACME component;
55
55
  class Service1,Service2,Service3 backend;
56
56
  ```
57
57
 
@@ -98,49 +98,49 @@ sequenceDiagram
98
98
  end
99
99
  ```
100
100
 
101
- ### Port Proxy with SNI-based Routing
101
+ ### SNI-based Connection Handling
102
102
  This diagram illustrates how TCP connections with SNI (Server Name Indication) are processed and forwarded:
103
103
 
104
104
  ```mermaid
105
105
  sequenceDiagram
106
106
  participant Client
107
- participant PortProxy
107
+ participant SmartProxy
108
108
  participant Backend
109
109
 
110
- Client->>PortProxy: TLS Connection
110
+ Client->>SmartProxy: TLS Connection
111
111
 
112
112
  alt SNI Enabled
113
- PortProxy->>Client: Accept Connection
114
- Client->>PortProxy: TLS ClientHello with SNI
115
- PortProxy->>PortProxy: Extract SNI Hostname
116
- PortProxy->>PortProxy: Match Domain Config
117
- PortProxy->>PortProxy: Validate Client IP
113
+ SmartProxy->>Client: Accept Connection
114
+ Client->>SmartProxy: TLS ClientHello with SNI
115
+ SmartProxy->>SmartProxy: Extract SNI Hostname
116
+ SmartProxy->>SmartProxy: Match Domain Config
117
+ SmartProxy->>SmartProxy: Validate Client IP
118
118
 
119
119
  alt IP Allowed
120
- PortProxy->>Backend: Forward Connection
121
- Note over PortProxy,Backend: Bidirectional Data Flow
120
+ SmartProxy->>Backend: Forward Connection
121
+ Note over SmartProxy,Backend: Bidirectional Data Flow
122
122
  else IP Rejected
123
- PortProxy->>Client: Close Connection
123
+ SmartProxy->>Client: Close Connection
124
124
  end
125
125
  else Port-based Routing
126
- PortProxy->>PortProxy: Match Port Range
127
- PortProxy->>PortProxy: Find Domain Config
128
- PortProxy->>PortProxy: Validate Client IP
126
+ SmartProxy->>SmartProxy: Match Port Range
127
+ SmartProxy->>SmartProxy: Find Domain Config
128
+ SmartProxy->>SmartProxy: Validate Client IP
129
129
 
130
130
  alt IP Allowed
131
- PortProxy->>Backend: Forward Connection
132
- Note over PortProxy,Backend: Bidirectional Data Flow
131
+ SmartProxy->>Backend: Forward Connection
132
+ Note over SmartProxy,Backend: Bidirectional Data Flow
133
133
  else IP Rejected
134
- PortProxy->>Client: Close Connection
134
+ SmartProxy->>Client: Close Connection
135
135
  end
136
136
  end
137
137
 
138
138
  loop Connection Active
139
- PortProxy-->>PortProxy: Monitor Activity
140
- PortProxy-->>PortProxy: Check Max Lifetime
139
+ SmartProxy-->>SmartProxy: Monitor Activity
140
+ SmartProxy-->>SmartProxy: Check Max Lifetime
141
141
  alt Inactivity or Max Lifetime Exceeded
142
- PortProxy->>Client: Close Connection
143
- PortProxy->>Backend: Close Connection
142
+ SmartProxy->>Client: Close Connection
143
+ SmartProxy->>Backend: Close Connection
144
144
  end
145
145
  end
146
146
  ```
@@ -192,7 +192,7 @@ sequenceDiagram
192
192
 
193
193
  - **HTTPS Reverse Proxy** - Route traffic to backend services based on hostname with TLS termination
194
194
  - **WebSocket Support** - Full WebSocket proxying with heartbeat monitoring
195
- - **TCP Port Forwarding** - Advanced port forwarding with SNI inspection and domain-based routing
195
+ - **TCP Connection Handling** - Advanced connection handling with SNI inspection and domain-based routing
196
196
  - **Enhanced TLS Handling** - Robust TLS handshake processing with improved certificate error handling
197
197
  - **HTTP to HTTPS Redirection** - Automatically redirect HTTP requests to HTTPS
198
198
  - **Let's Encrypt Integration** - Automatic certificate management using ACME protocol
@@ -224,15 +224,16 @@ const proxy = new NetworkProxy({
224
224
  const proxyConfigs = [
225
225
  {
226
226
  hostName: 'example.com',
227
- destinationIp: '127.0.0.1',
228
- destinationPort: 3000,
227
+ destinationIps: ['127.0.0.1'],
228
+ destinationPorts: [3000],
229
229
  publicKey: 'your-cert-content',
230
- privateKey: 'your-key-content'
230
+ privateKey: 'your-key-content',
231
+ rewriteHostHeader: true
231
232
  },
232
233
  {
233
234
  hostName: 'api.example.com',
234
- destinationIp: '127.0.0.1',
235
- destinationPort: 4000,
235
+ destinationIps: ['127.0.0.1'],
236
+ destinationPorts: [4000],
236
237
  publicKey: 'your-cert-content',
237
238
  privateKey: 'your-key-content',
238
239
  // Optional basic auth
@@ -266,13 +267,13 @@ const redirector = new SslRedirect(80);
266
267
  redirector.start();
267
268
  ```
268
269
 
269
- ### TCP Port Forwarding with Domain-based Routing
270
+ ### TCP Connection Handling with Domain-based Routing
270
271
 
271
272
  ```typescript
272
- import { PortProxy } from '@push.rocks/smartproxy';
273
+ import { SmartProxy } from '@push.rocks/smartproxy';
273
274
 
274
- // Configure port proxy with domain-based routing
275
- const portProxy = new PortProxy({
275
+ // Configure SmartProxy with domain-based routing
276
+ const smartProxy = new SmartProxy({
276
277
  fromPort: 443,
277
278
  toPort: 8443,
278
279
  targetIP: 'localhost', // Default target host
@@ -312,7 +313,7 @@ const portProxy = new PortProxy({
312
313
  preserveSourceIP: true
313
314
  });
314
315
 
315
- portProxy.start();
316
+ smartProxy.start();
316
317
  ```
317
318
 
318
319
  ### NfTables Port Forwarding
@@ -376,7 +377,13 @@ await basicProxy.start();
376
377
  import { Port80Handler } from '@push.rocks/smartproxy';
377
378
 
378
379
  // Create an ACME handler for Let's Encrypt
379
- const acmeHandler = new Port80Handler();
380
+ const acmeHandler = new Port80Handler({
381
+ port: 80,
382
+ contactEmail: 'admin@example.com',
383
+ useProduction: true, // Use Let's Encrypt production servers (default is staging)
384
+ renewThresholdDays: 30, // Renew certificates 30 days before expiry
385
+ httpsRedirectPort: 443 // Redirect HTTP to HTTPS on this port
386
+ });
380
387
 
381
388
  // Add domains to manage certificates for
382
389
  acmeHandler.addDomain({
@@ -407,8 +414,14 @@ acmeHandler.addDomain({
407
414
  | Option | Description | Default |
408
415
  |----------------|---------------------------------------------------|---------|
409
416
  | `port` | Port to listen on for HTTPS connections | - |
417
+ | `maxConnections` | Maximum concurrent connections | 10000 |
418
+ | `keepAliveTimeout` | Keep-alive timeout in milliseconds | 60000 |
419
+ | `headersTimeout` | Headers timeout in milliseconds | 60000 |
420
+ | `logLevel` | Logging level ('error', 'warn', 'info', 'debug') | 'info' |
421
+ | `cors` | CORS configuration object | - |
422
+ | `rewriteHostHeader` | Whether to rewrite the Host header | false |
410
423
 
411
- ### PortProxy Settings
424
+ ### SmartProxy Settings
412
425
 
413
426
  | Option | Description | Default |
414
427
  |---------------------------|--------------------------------------------------------|-------------|
@@ -460,28 +473,11 @@ acmeHandler.addDomain({
460
473
  | `qos` | Quality of Service options (object) | - |
461
474
  | `netProxyIntegration` | NetworkProxy integration options (object) | - |
462
475
 
463
- #### NfTablesProxy QoS Options
464
-
465
- | Option | Description | Default |
466
- |----------------------|---------------------------------------------------|---------|
467
- | `enabled` | Enable Quality of Service features | false |
468
- | `maxRate` | Maximum bandwidth rate (e.g. "10mbps") | - |
469
- | `priority` | Traffic priority (1-10, 1 is highest) | - |
470
- | `markConnections` | Mark connections for easier management | false |
471
-
472
- #### NfTablesProxy NetworkProxy Integration Options
473
-
474
- | Option | Description | Default |
475
- |----------------------|---------------------------------------------------|---------|
476
- | `enabled` | Enable NetworkProxy integration | false |
477
- | `redirectLocalhost` | Redirect localhost traffic to NetworkProxy | false |
478
- | `sslTerminationPort` | Port where NetworkProxy handles SSL termination | - |
479
-
480
476
  ## Advanced Features
481
477
 
482
478
  ### TLS Handshake Optimization
483
479
 
484
- The enhanced `PortProxy` implementation includes significant improvements for TLS handshake handling:
480
+ The enhanced `SmartProxy` implementation includes significant improvements for TLS handshake handling:
485
481
 
486
482
  - Robust SNI extraction with improved error handling
487
483
  - Increased buffer size for complex TLS handshakes (10MB)
@@ -492,7 +488,7 @@ The enhanced `PortProxy` implementation includes significant improvements for TL
492
488
 
493
489
  ```typescript
494
490
  // Example configuration to solve Chrome certificate errors
495
- const portProxy = new PortProxy({
491
+ const portProxy = new SmartProxy({
496
492
  // ... other settings
497
493
  initialDataTimeout: 60000, // Give browser more time for handshake
498
494
  maxPendingDataSize: 10 * 1024 * 1024, // Larger buffer for complex handshakes
@@ -502,7 +498,7 @@ const portProxy = new PortProxy({
502
498
 
503
499
  ### Connection Management and Monitoring
504
500
 
505
- The `PortProxy` class includes built-in connection tracking and monitoring:
501
+ The `SmartProxy` class includes built-in connection tracking and monitoring:
506
502
 
507
503
  - Automatic cleanup of idle connections with configurable timeouts
508
504
  - Timeouts for connections that exceed maximum lifetime
@@ -521,7 +517,7 @@ The `NetworkProxy` class provides WebSocket support with:
521
517
 
522
518
  ### SNI-based Routing
523
519
 
524
- The `PortProxy` class can inspect the SNI (Server Name Indication) field in TLS handshakes to route connections based on the requested domain:
520
+ The `SmartProxy` class can inspect the SNI (Server Name Indication) field in TLS handshakes to route connections based on the requested domain:
525
521
 
526
522
  - Multiple backend targets per domain
527
523
  - Round-robin load balancing
@@ -530,7 +526,7 @@ The `PortProxy` class can inspect the SNI (Server Name Indication) field in TLS
530
526
 
531
527
  ### Enhanced NfTables Management
532
528
 
533
- The `NfTablesProxy` class offers advanced capabilities compared to the previous IPTablesProxy:
529
+ The `NfTablesProxy` class offers advanced capabilities:
534
530
 
535
531
  - Support for multiple port ranges and individual ports
536
532
  - More efficient IP filtering using nftables sets
@@ -544,7 +540,7 @@ The `NfTablesProxy` class offers advanced capabilities compared to the previous
544
540
 
545
541
  ### Port80Handler with Glob Pattern Support
546
542
 
547
- The `Port80Handler` class now includes support for glob pattern domain matching:
543
+ The `Port80Handler` class includes support for glob pattern domain matching:
548
544
 
549
545
  - Supports wildcard domains like `*.example.com` for HTTP request routing
550
546
  - Detects glob patterns and skips certificate issuance for them
@@ -566,7 +562,7 @@ If you experience certificate errors in browsers, especially in Chrome, try thes
566
562
 
567
563
  ```typescript
568
564
  // Configuration to fix Chrome certificate errors
569
- const portProxy = new PortProxy({
565
+ const smartProxy = new SmartProxy({
570
566
  // ... other settings
571
567
  initialDataTimeout: 60000,
572
568
  maxPendingDataSize: 10 * 1024 * 1024,
@@ -585,14 +581,14 @@ For improved connection stability in high-traffic environments:
585
581
  4. **Monitor Connection Statistics**: Enable detailed logging to track termination reasons
586
582
  5. **Fine-tune Inactivity Checks**: Adjust `inactivityCheckInterval` based on your traffic patterns
587
583
 
588
- ### IPTables Troubleshooting
584
+ ### NfTables Troubleshooting
589
585
 
590
- If you're experiencing issues with IPTablesProxy:
586
+ If you're experiencing issues with NfTablesProxy:
591
587
 
592
588
  1. **Enable Detailed Logging**: Set `enableLogging: true` to see all rule operations
593
589
  2. **Force Clean Slate**: Use `forceCleanSlate: true` to remove any lingering rules
594
- 3. **Use Custom Chains**: Enable `addJumpRule: true` for cleaner rule management
595
- 4. **Check Permissions**: Ensure your process has sufficient permissions to modify iptables
590
+ 3. **Use IP Sets**: Enable `useIPSets: true` for cleaner rule management
591
+ 4. **Check Permissions**: Ensure your process has sufficient permissions to modify nftables
596
592
  5. **Verify IPv6 Support**: If using `ipv6Support: true`, ensure ip6tables is available
597
593
 
598
594
  ## License and Legal Information
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartproxy',
6
- version: '5.1.0',
6
+ version: '6.0.1',
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
  }