@push.rocks/smartproxy 5.0.0 → 5.1.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/package.json +1 -1
- package/readme.md +77 -27
- package/ts/00_commitinfo_data.ts +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartproxy',
|
|
6
|
-
version: '5.
|
|
6
|
+
version: '5.1.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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLG1PQUFtTztDQUNqUCxDQUFBIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartproxy",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.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",
|
package/readme.md
CHANGED
|
@@ -16,7 +16,7 @@ flowchart TB
|
|
|
16
16
|
HTTP80[HTTP Port 80\nSslRedirect]
|
|
17
17
|
HTTPS443[HTTPS Port 443\nNetworkProxy]
|
|
18
18
|
PortProxy[TCP Port Proxy\nwith SNI routing]
|
|
19
|
-
|
|
19
|
+
NfTables[NfTablesProxy]
|
|
20
20
|
Router[ProxyRouter]
|
|
21
21
|
ACME[Port80Handler\nACME/Let's Encrypt]
|
|
22
22
|
Certs[(SSL Certificates)]
|
|
@@ -40,7 +40,7 @@ flowchart TB
|
|
|
40
40
|
PortProxy -->|Direct TCP| Service2
|
|
41
41
|
PortProxy -->|Direct TCP| Service3
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
NfTables -.->|Low-level forwarding| PortProxy
|
|
44
44
|
|
|
45
45
|
HTTP80 -.->|Challenge Response| ACME
|
|
46
46
|
ACME -.->|Generate/Manage| Certs
|
|
@@ -197,7 +197,7 @@ sequenceDiagram
|
|
|
197
197
|
- **HTTP to HTTPS Redirection** - Automatically redirect HTTP requests to HTTPS
|
|
198
198
|
- **Let's Encrypt Integration** - Automatic certificate management using ACME protocol
|
|
199
199
|
- **IP Filtering** - Control access with IP allow/block lists using glob patterns
|
|
200
|
-
- **
|
|
200
|
+
- **NfTables Integration** - Direct manipulation of nftables for advanced low-level port forwarding
|
|
201
201
|
- **Basic Authentication** - Support for basic auth on proxied routes
|
|
202
202
|
- **Connection Management** - Intelligent connection tracking and cleanup with configurable timeouts
|
|
203
203
|
- **Browser Compatibility** - Optimized for modern browsers with fixes for common TLS handshake issues
|
|
@@ -315,13 +315,13 @@ const portProxy = new PortProxy({
|
|
|
315
315
|
portProxy.start();
|
|
316
316
|
```
|
|
317
317
|
|
|
318
|
-
###
|
|
318
|
+
### NfTables Port Forwarding
|
|
319
319
|
|
|
320
320
|
```typescript
|
|
321
|
-
import {
|
|
321
|
+
import { NfTablesProxy } from '@push.rocks/smartproxy';
|
|
322
322
|
|
|
323
323
|
// Basic usage - forward single port
|
|
324
|
-
const basicProxy = new
|
|
324
|
+
const basicProxy = new NfTablesProxy({
|
|
325
325
|
fromPort: 80,
|
|
326
326
|
toPort: 8080,
|
|
327
327
|
toHost: 'localhost',
|
|
@@ -330,7 +330,7 @@ const basicProxy = new IPTablesProxy({
|
|
|
330
330
|
});
|
|
331
331
|
|
|
332
332
|
// Forward port ranges
|
|
333
|
-
const rangeProxy = new
|
|
333
|
+
const rangeProxy = new NfTablesProxy({
|
|
334
334
|
fromPort: { from: 3000, to: 3010 }, // Forward ports 3000-3010
|
|
335
335
|
toPort: { from: 8000, to: 8010 }, // To ports 8000-8010
|
|
336
336
|
protocol: 'tcp', // TCP protocol (default)
|
|
@@ -339,19 +339,26 @@ const rangeProxy = new IPTablesProxy({
|
|
|
339
339
|
});
|
|
340
340
|
|
|
341
341
|
// Multiple port specifications with IP filtering
|
|
342
|
-
const advancedProxy = new
|
|
342
|
+
const advancedProxy = new NfTablesProxy({
|
|
343
343
|
fromPort: [80, 443, { from: 8000, to: 8010 }], // Multiple ports/ranges
|
|
344
344
|
toPort: [8080, 8443, { from: 18000, to: 18010 }],
|
|
345
345
|
allowedSourceIPs: ['10.0.0.0/8', '192.168.1.0/24'], // Only allow these IPs
|
|
346
346
|
bannedSourceIPs: ['192.168.1.100'], // Explicitly block these IPs
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
useIPSets: true, // Use IP sets for efficient IP management
|
|
348
|
+
forceCleanSlate: false // Clean all NfTablesProxy rules before starting
|
|
349
349
|
});
|
|
350
350
|
|
|
351
|
-
//
|
|
352
|
-
const
|
|
351
|
+
// Advanced features: QoS, connection tracking, and NetworkProxy integration
|
|
352
|
+
const advancedProxy = new NfTablesProxy({
|
|
353
353
|
fromPort: 443,
|
|
354
354
|
toPort: 8443,
|
|
355
|
+
toHost: 'localhost',
|
|
356
|
+
useAdvancedNAT: true, // Use connection tracking for stateful NAT
|
|
357
|
+
qos: {
|
|
358
|
+
enabled: true,
|
|
359
|
+
maxRate: '10mbps', // Limit bandwidth
|
|
360
|
+
priority: 1 // Set traffic priority (1-10)
|
|
361
|
+
},
|
|
355
362
|
netProxyIntegration: {
|
|
356
363
|
enabled: true,
|
|
357
364
|
redirectLocalhost: true, // Redirect localhost traffic to NetworkProxy
|
|
@@ -372,8 +379,25 @@ import { Port80Handler } from '@push.rocks/smartproxy';
|
|
|
372
379
|
const acmeHandler = new Port80Handler();
|
|
373
380
|
|
|
374
381
|
// Add domains to manage certificates for
|
|
375
|
-
acmeHandler.addDomain(
|
|
376
|
-
|
|
382
|
+
acmeHandler.addDomain({
|
|
383
|
+
domainName: 'example.com',
|
|
384
|
+
sslRedirect: true,
|
|
385
|
+
acmeMaintenance: true
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
acmeHandler.addDomain({
|
|
389
|
+
domainName: 'api.example.com',
|
|
390
|
+
sslRedirect: true,
|
|
391
|
+
acmeMaintenance: true
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
// Support for glob pattern domains for routing (certificates not issued for glob patterns)
|
|
395
|
+
acmeHandler.addDomain({
|
|
396
|
+
domainName: '*.example.com',
|
|
397
|
+
sslRedirect: true,
|
|
398
|
+
acmeMaintenance: false, // Can't issue certificates for wildcard domains via HTTP-01
|
|
399
|
+
forward: { ip: '192.168.1.10', port: 8080 } // Forward requests to this target
|
|
400
|
+
});
|
|
377
401
|
```
|
|
378
402
|
|
|
379
403
|
## Configuration Options
|
|
@@ -412,7 +436,7 @@ acmeHandler.addDomain('api.example.com');
|
|
|
412
436
|
| `enableDetailedLogging` | Enable detailed connection logging | false |
|
|
413
437
|
| `enableRandomizedTimeouts`| Randomize timeouts slightly to prevent thundering herd | true |
|
|
414
438
|
|
|
415
|
-
###
|
|
439
|
+
### NfTablesProxy Settings
|
|
416
440
|
|
|
417
441
|
| Option | Description | Default |
|
|
418
442
|
|-----------------------|---------------------------------------------------|-------------|
|
|
@@ -420,18 +444,32 @@ acmeHandler.addDomain('api.example.com');
|
|
|
420
444
|
| `toPort` | Destination port(s) or range(s) to forward to | - |
|
|
421
445
|
| `toHost` | Destination host to forward to | 'localhost' |
|
|
422
446
|
| `preserveSourceIP` | Preserve the original client IP | false |
|
|
423
|
-
| `deleteOnExit` | Remove
|
|
447
|
+
| `deleteOnExit` | Remove nftables rules when process exits | false |
|
|
424
448
|
| `protocol` | Protocol to forward ('tcp', 'udp', or 'all') | 'tcp' |
|
|
425
449
|
| `enableLogging` | Enable detailed logging | false |
|
|
426
|
-
| `
|
|
450
|
+
| `logFormat` | Format for logs ('plain' or 'json') | 'plain' |
|
|
451
|
+
| `ipv6Support` | Enable IPv6 support | false |
|
|
427
452
|
| `allowedSourceIPs` | Array of IP addresses/CIDR allowed to connect | - |
|
|
428
453
|
| `bannedSourceIPs` | Array of IP addresses/CIDR blocked from connecting | - |
|
|
429
|
-
| `
|
|
430
|
-
| `
|
|
431
|
-
| `
|
|
454
|
+
| `useIPSets` | Use nftables sets for efficient IP management | true |
|
|
455
|
+
| `forceCleanSlate` | Clear all NfTablesProxy rules before starting | false |
|
|
456
|
+
| `tableName` | Custom table name | 'portproxy' |
|
|
457
|
+
| `maxRetries` | Maximum number of retries for failed commands | 3 |
|
|
458
|
+
| `retryDelayMs` | Delay between retries in milliseconds | 1000 |
|
|
459
|
+
| `useAdvancedNAT` | Use connection tracking for stateful NAT | false |
|
|
460
|
+
| `qos` | Quality of Service options (object) | - |
|
|
432
461
|
| `netProxyIntegration` | NetworkProxy integration options (object) | - |
|
|
433
462
|
|
|
434
|
-
####
|
|
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
|
|
435
473
|
|
|
436
474
|
| Option | Description | Default |
|
|
437
475
|
|----------------------|---------------------------------------------------|---------|
|
|
@@ -490,18 +528,30 @@ The `PortProxy` class can inspect the SNI (Server Name Indication) field in TLS
|
|
|
490
528
|
- Domain-specific allowed IP ranges
|
|
491
529
|
- Protection against SNI renegotiation attacks
|
|
492
530
|
|
|
493
|
-
### Enhanced
|
|
531
|
+
### Enhanced NfTables Management
|
|
494
532
|
|
|
495
|
-
The
|
|
533
|
+
The `NfTablesProxy` class offers advanced capabilities compared to the previous IPTablesProxy:
|
|
496
534
|
|
|
497
535
|
- Support for multiple port ranges and individual ports
|
|
498
|
-
-
|
|
499
|
-
-
|
|
500
|
-
-
|
|
536
|
+
- More efficient IP filtering using nftables sets
|
|
537
|
+
- IPv6 support with full feature parity
|
|
538
|
+
- Quality of Service (QoS) features including bandwidth limiting and traffic prioritization
|
|
539
|
+
- Advanced connection tracking for stateful NAT
|
|
540
|
+
- Robust error handling with retry mechanisms
|
|
541
|
+
- Structured logging with JSON support
|
|
501
542
|
- NetworkProxy integration for SSL termination
|
|
502
|
-
- Automatic rule existence checking to prevent duplicates
|
|
503
543
|
- Comprehensive cleanup on shutdown
|
|
504
544
|
|
|
545
|
+
### Port80Handler with Glob Pattern Support
|
|
546
|
+
|
|
547
|
+
The `Port80Handler` class now includes support for glob pattern domain matching:
|
|
548
|
+
|
|
549
|
+
- Supports wildcard domains like `*.example.com` for HTTP request routing
|
|
550
|
+
- Detects glob patterns and skips certificate issuance for them
|
|
551
|
+
- Smart routing that first attempts exact matches, then tries pattern matching
|
|
552
|
+
- Supports forwarding HTTP requests to backend services
|
|
553
|
+
- Separate forwarding configuration for ACME challenges
|
|
554
|
+
|
|
505
555
|
## Troubleshooting
|
|
506
556
|
|
|
507
557
|
### Browser Certificate Errors
|
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: '5.
|
|
6
|
+
version: '5.1.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
|
}
|