@push.rocks/smartproxy 3.25.3 → 3.26.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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.portproxy.d.ts +6 -18
- package/dist_ts/classes.portproxy.js +291 -271
- package/package.json +1 -1
- package/readme.md +108 -18
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.portproxy.ts +327 -308
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartproxy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.26.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, and dynamic routing with authentication options.",
|
|
6
6
|
"main": "dist_ts/index.js",
|
package/readme.md
CHANGED
|
@@ -193,12 +193,14 @@ sequenceDiagram
|
|
|
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
195
|
- **TCP Port Forwarding** - Advanced port forwarding with SNI inspection and domain-based routing
|
|
196
|
+
- **Enhanced TLS Handling** - Robust TLS handshake processing with improved certificate error handling
|
|
196
197
|
- **HTTP to HTTPS Redirection** - Automatically redirect HTTP requests to HTTPS
|
|
197
198
|
- **Let's Encrypt Integration** - Automatic certificate management using ACME protocol
|
|
198
199
|
- **IP Filtering** - Control access with IP allow/block lists using glob patterns
|
|
199
200
|
- **IPTables Integration** - Direct manipulation of iptables for low-level port forwarding
|
|
200
201
|
- **Basic Authentication** - Support for basic auth on proxied routes
|
|
201
|
-
- **Connection Management** - Intelligent connection tracking and cleanup
|
|
202
|
+
- **Connection Management** - Intelligent connection tracking and cleanup with configurable timeouts
|
|
203
|
+
- **Browser Compatibility** - Optimized for modern browsers with fixes for common TLS handshake issues
|
|
202
204
|
|
|
203
205
|
## Installation
|
|
204
206
|
|
|
@@ -275,18 +277,38 @@ const portProxy = new PortProxy({
|
|
|
275
277
|
toPort: 8443,
|
|
276
278
|
targetIP: 'localhost', // Default target host
|
|
277
279
|
sniEnabled: true, // Enable SNI inspection
|
|
280
|
+
|
|
281
|
+
// Enhanced reliability settings
|
|
282
|
+
initialDataTimeout: 60000, // 60 seconds for initial TLS handshake
|
|
283
|
+
socketTimeout: 3600000, // 1 hour socket timeout
|
|
284
|
+
maxConnectionLifetime: 3600000, // 1 hour connection lifetime
|
|
285
|
+
inactivityTimeout: 3600000, // 1 hour inactivity timeout
|
|
286
|
+
maxPendingDataSize: 10 * 1024 * 1024, // 10MB buffer for large TLS handshakes
|
|
287
|
+
|
|
288
|
+
// Browser compatibility enhancement
|
|
289
|
+
enableTlsDebugLogging: false, // Enable for troubleshooting TLS issues
|
|
290
|
+
|
|
291
|
+
// Port and IP configuration
|
|
278
292
|
globalPortRanges: [{ from: 443, to: 443 }],
|
|
279
293
|
defaultAllowedIPs: ['*'], // Allow all IPs by default
|
|
294
|
+
|
|
295
|
+
// Socket optimizations for better connection stability
|
|
296
|
+
noDelay: true, // Disable Nagle's algorithm
|
|
297
|
+
keepAlive: true, // Enable TCP keepalive
|
|
298
|
+
enableKeepAliveProbes: true, // Enhanced keepalive for stability
|
|
299
|
+
|
|
300
|
+
// Domain-specific routing configuration
|
|
280
301
|
domainConfigs: [
|
|
281
302
|
{
|
|
282
303
|
domains: ['example.com', '*.example.com'], // Glob patterns for matching domains
|
|
283
304
|
allowedIPs: ['192.168.1.*'], // Restrict access by IP
|
|
284
305
|
blockedIPs: ['192.168.1.100'], // Block specific IPs
|
|
285
306
|
targetIPs: ['10.0.0.1', '10.0.0.2'], // Round-robin between multiple targets
|
|
286
|
-
portRanges: [{ from: 443, to: 443 }]
|
|
307
|
+
portRanges: [{ from: 443, to: 443 }],
|
|
308
|
+
connectionTimeout: 7200000 // Domain-specific timeout (2 hours)
|
|
287
309
|
}
|
|
288
310
|
],
|
|
289
|
-
|
|
311
|
+
|
|
290
312
|
preserveSourceIP: true
|
|
291
313
|
});
|
|
292
314
|
|
|
@@ -333,19 +355,31 @@ acmeHandler.addDomain('api.example.com');
|
|
|
333
355
|
|
|
334
356
|
### PortProxy Settings
|
|
335
357
|
|
|
336
|
-
| Option
|
|
337
|
-
|
|
338
|
-
| `fromPort`
|
|
339
|
-
| `toPort`
|
|
340
|
-
| `targetIP`
|
|
341
|
-
| `sniEnabled`
|
|
342
|
-
| `defaultAllowedIPs`
|
|
343
|
-
| `defaultBlockedIPs`
|
|
344
|
-
| `preserveSourceIP`
|
|
345
|
-
| `maxConnectionLifetime`
|
|
346
|
-
| `
|
|
347
|
-
| `
|
|
348
|
-
| `
|
|
358
|
+
| Option | Description | Default |
|
|
359
|
+
|---------------------------|--------------------------------------------------------|-------------|
|
|
360
|
+
| `fromPort` | Port to listen on | - |
|
|
361
|
+
| `toPort` | Destination port to forward to | - |
|
|
362
|
+
| `targetIP` | Default destination IP if not specified in domainConfig | 'localhost' |
|
|
363
|
+
| `sniEnabled` | Enable SNI inspection for TLS connections | false |
|
|
364
|
+
| `defaultAllowedIPs` | IP patterns allowed by default | - |
|
|
365
|
+
| `defaultBlockedIPs` | IP patterns blocked by default | - |
|
|
366
|
+
| `preserveSourceIP` | Preserve the original client IP | false |
|
|
367
|
+
| `maxConnectionLifetime` | Maximum time in ms to keep a connection open | 3600000 |
|
|
368
|
+
| `initialDataTimeout` | Timeout for initial data/handshake in ms | 60000 |
|
|
369
|
+
| `socketTimeout` | Socket inactivity timeout in ms | 3600000 |
|
|
370
|
+
| `inactivityTimeout` | Connection inactivity check timeout in ms | 3600000 |
|
|
371
|
+
| `inactivityCheckInterval` | How often to check for inactive connections in ms | 60000 |
|
|
372
|
+
| `maxPendingDataSize` | Maximum bytes to buffer during connection setup | 10485760 |
|
|
373
|
+
| `globalPortRanges` | Array of port ranges to listen on | - |
|
|
374
|
+
| `forwardAllGlobalRanges` | Forward all global range connections to targetIP | false |
|
|
375
|
+
| `gracefulShutdownTimeout` | Time in ms to wait during shutdown | 30000 |
|
|
376
|
+
| `noDelay` | Disable Nagle's algorithm | true |
|
|
377
|
+
| `keepAlive` | Enable TCP keepalive | true |
|
|
378
|
+
| `keepAliveInitialDelay` | Initial delay before sending keepalive probes in ms | 30000 |
|
|
379
|
+
| `enableKeepAliveProbes` | Enable enhanced TCP keep-alive probes | false |
|
|
380
|
+
| `enableTlsDebugLogging` | Enable detailed TLS handshake debugging | false |
|
|
381
|
+
| `enableDetailedLogging` | Enable detailed connection logging | false |
|
|
382
|
+
| `enableRandomizedTimeouts`| Randomize timeouts slightly to prevent thundering herd | true |
|
|
349
383
|
|
|
350
384
|
### IPTablesProxy Settings
|
|
351
385
|
|
|
@@ -359,14 +393,37 @@ acmeHandler.addDomain('api.example.com');
|
|
|
359
393
|
|
|
360
394
|
## Advanced Features
|
|
361
395
|
|
|
396
|
+
### TLS Handshake Optimization
|
|
397
|
+
|
|
398
|
+
The enhanced `PortProxy` implementation includes significant improvements for TLS handshake handling:
|
|
399
|
+
|
|
400
|
+
- Robust SNI extraction with improved error handling
|
|
401
|
+
- Increased buffer size for complex TLS handshakes (10MB)
|
|
402
|
+
- Longer initial handshake timeout (60 seconds)
|
|
403
|
+
- Detection and tracking of TLS connection states
|
|
404
|
+
- Optional detailed TLS debug logging for troubleshooting
|
|
405
|
+
- Browser compatibility fixes for Chrome certificate errors
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
// Example configuration to solve Chrome certificate errors
|
|
409
|
+
const portProxy = new PortProxy({
|
|
410
|
+
// ... other settings
|
|
411
|
+
initialDataTimeout: 60000, // Give browser more time for handshake
|
|
412
|
+
maxPendingDataSize: 10 * 1024 * 1024, // Larger buffer for complex handshakes
|
|
413
|
+
enableTlsDebugLogging: true, // Enable when troubleshooting
|
|
414
|
+
});
|
|
415
|
+
```
|
|
416
|
+
|
|
362
417
|
### Connection Management and Monitoring
|
|
363
418
|
|
|
364
419
|
The `PortProxy` class includes built-in connection tracking and monitoring:
|
|
365
420
|
|
|
366
|
-
- Automatic cleanup of idle connections
|
|
421
|
+
- Automatic cleanup of idle connections with configurable timeouts
|
|
367
422
|
- Timeouts for connections that exceed maximum lifetime
|
|
368
423
|
- Detailed logging of connection states
|
|
369
424
|
- Termination statistics
|
|
425
|
+
- Randomized timeouts to prevent "thundering herd" problems
|
|
426
|
+
- Per-domain timeout configuration
|
|
370
427
|
|
|
371
428
|
### WebSocket Support
|
|
372
429
|
|
|
@@ -385,6 +442,39 @@ The `PortProxy` class can inspect the SNI (Server Name Indication) field in TLS
|
|
|
385
442
|
- Domain-specific allowed IP ranges
|
|
386
443
|
- Protection against SNI renegotiation attacks
|
|
387
444
|
|
|
445
|
+
## Troubleshooting
|
|
446
|
+
|
|
447
|
+
### Browser Certificate Errors
|
|
448
|
+
|
|
449
|
+
If you experience certificate errors in browsers, especially in Chrome, try these solutions:
|
|
450
|
+
|
|
451
|
+
1. **Increase Initial Data Timeout**: Set `initialDataTimeout` to 60 seconds or higher
|
|
452
|
+
2. **Increase Buffer Size**: Set `maxPendingDataSize` to 10MB or higher
|
|
453
|
+
3. **Enable TLS Debug Logging**: Set `enableTlsDebugLogging: true` to troubleshoot handshake issues
|
|
454
|
+
4. **Enable Keep-Alive Probes**: Set `enableKeepAliveProbes: true` for better connection stability
|
|
455
|
+
5. **Check Certificate Chain**: Ensure your certificate chain is complete and in the correct order
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
// Configuration to fix Chrome certificate errors
|
|
459
|
+
const portProxy = new PortProxy({
|
|
460
|
+
// ... other settings
|
|
461
|
+
initialDataTimeout: 60000,
|
|
462
|
+
maxPendingDataSize: 10 * 1024 * 1024,
|
|
463
|
+
enableTlsDebugLogging: true,
|
|
464
|
+
enableKeepAliveProbes: true
|
|
465
|
+
});
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Connection Stability
|
|
469
|
+
|
|
470
|
+
For improved connection stability in high-traffic environments:
|
|
471
|
+
|
|
472
|
+
1. **Set Appropriate Timeouts**: Use longer timeouts for long-lived connections
|
|
473
|
+
2. **Use Domain-Specific Timeouts**: Configure per-domain timeouts for different types of services
|
|
474
|
+
3. **Enable TCP Keep-Alive**: Ensure `keepAlive` is set to `true`
|
|
475
|
+
4. **Monitor Connection Statistics**: Enable detailed logging to track termination reasons
|
|
476
|
+
5. **Fine-tune Inactivity Checks**: Adjust `inactivityCheckInterval` based on your traffic patterns
|
|
477
|
+
|
|
388
478
|
## License and Legal Information
|
|
389
479
|
|
|
390
480
|
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.
|
|
@@ -402,4 +492,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
|
|
|
402
492
|
|
|
403
493
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
404
494
|
|
|
405
|
-
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.
|
|
495
|
+
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
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartproxy',
|
|
6
|
-
version: '3.
|
|
6
|
+
version: '3.26.0',
|
|
7
7
|
description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, and dynamic routing with authentication options.'
|
|
8
8
|
}
|