@push.rocks/smartproxy 25.6.0 → 25.7.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/changelog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 2026-02-16 - 25.7.0 - feat(routes)
4
+ add protocol-based route matching and ensure terminate-and-reencrypt routes HTTP through the full HTTP proxy; update docs and tests
5
+
6
+ - Introduce a new 'protocol' match field for routes (supports 'http' and 'tcp') and preserve it through cloning/merging.
7
+ - Add Rust integration test verifying terminate-and-reencrypt decrypts TLS and routes HTTP traffic via the HTTP proxy (per-request Host/path routing) instead of raw tunneling.
8
+ - Add TypeScript unit tests covering protocol field validation, preservation, interaction with terminate-and-reencrypt, cloning, merging, and matching behavior.
9
+ - Update README with a Protocol-Specific Routing section and clarify terminate-and-reencrypt behavior (HTTP routed via HTTP proxy; non-HTTP uses raw TLS-to-TLS tunnel).
10
+ - Example config: include health check thresholds (unhealthyThreshold and healthyThreshold) in the sample healthCheck settings.
11
+
3
12
  ## 2026-02-16 - 25.6.0 - feat(rustproxy)
4
13
  add protocol-based routing and backend TLS re-encryption support
5
14
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartproxy',
6
- version: '25.6.0',
6
+ version: '25.7.0',
7
7
  description: 'A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLHFQQUFxUDtDQUNuUSxDQUFBIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartproxy",
3
- "version": "25.6.0",
3
+ "version": "25.7.0",
4
4
  "private": false,
5
5
  "description": "A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.",
6
6
  "main": "dist_ts/index.js",
package/readme.md CHANGED
@@ -27,7 +27,7 @@ Whether you're building microservices, deploying edge infrastructure, or need a
27
27
  | 🦀 **Rust-Powered Engine** | All networking handled by a high-performance Rust binary via IPC |
28
28
  | 🔀 **Unified Route-Based Config** | Clean match/action patterns for intuitive traffic routing |
29
29
  | 🔒 **Automatic SSL/TLS** | Zero-config HTTPS with Let's Encrypt ACME integration |
30
- | 🎯 **Flexible Matching** | Route by port, domain, path, client IP, TLS version, headers, or custom logic |
30
+ | 🎯 **Flexible Matching** | Route by port, domain, path, protocol, client IP, TLS version, headers, or custom logic |
31
31
  | 🚄 **High-Performance** | Choose between user-space or kernel-level (NFTables) forwarding |
32
32
  | ⚖️ **Load Balancing** | Round-robin, least-connections, IP-hash with health checks |
33
33
  | 🛡️ **Enterprise Security** | IP filtering, rate limiting, basic auth, JWT auth, connection limits |
@@ -89,7 +89,7 @@ SmartProxy uses a powerful **match/action** pattern that makes routing predictab
89
89
  ```
90
90
 
91
91
  Every route consists of:
92
- - **Match** — What traffic to capture (ports, domains, paths, IPs, headers)
92
+ - **Match** — What traffic to capture (ports, domains, paths, protocol, IPs, headers)
93
93
  - **Action** — What to do with it (`forward` or `socket-handler`)
94
94
  - **Security** (optional) — IP allow/block lists, rate limits, authentication
95
95
  - **Headers** (optional) — Request/response header manipulation with template variables
@@ -103,7 +103,7 @@ SmartProxy supports three TLS handling modes:
103
103
  |------|-------------|----------|
104
104
  | `passthrough` | Forward encrypted traffic as-is (SNI-based routing) | Backend handles TLS |
105
105
  | `terminate` | Decrypt at proxy, forward plain HTTP to backend | Standard reverse proxy |
106
- | `terminate-and-reencrypt` | Decrypt, then re-encrypt to backend | Zero-trust environments |
106
+ | `terminate-and-reencrypt` | Decrypt at proxy, re-encrypt to backend. HTTP traffic gets full per-request routing (Host header, path matching) via the HTTP proxy; non-HTTP traffic uses a raw TLS-to-TLS tunnel | Zero-trust / defense-in-depth environments |
107
107
 
108
108
  ## 💡 Common Use Cases
109
109
 
@@ -135,13 +135,13 @@ const proxy = new SmartProxy({
135
135
  ],
136
136
  {
137
137
  tls: { mode: 'terminate', certificate: 'auto' },
138
- loadBalancing: {
139
- algorithm: 'round-robin',
140
- healthCheck: {
141
- path: '/health',
142
- interval: 30000,
143
- timeout: 5000
144
- }
138
+ algorithm: 'round-robin',
139
+ healthCheck: {
140
+ path: '/health',
141
+ interval: 30000,
142
+ timeout: 5000,
143
+ unhealthyThreshold: 3,
144
+ healthyThreshold: 2
145
145
  }
146
146
  }
147
147
  )
@@ -318,6 +318,42 @@ const proxy = new SmartProxy({
318
318
 
319
319
  > **Note:** Routes with dynamic functions (host/port callbacks) are automatically relayed through the TypeScript socket handler server, since JavaScript functions can't be serialized to Rust.
320
320
 
321
+ ### 🔀 Protocol-Specific Routing
322
+
323
+ Restrict routes to specific application-layer protocols. When `protocol` is set, the Rust engine detects the protocol after connection (or after TLS termination) and only matches routes that accept that protocol:
324
+
325
+ ```typescript
326
+ // HTTP-only route (rejects raw TCP connections)
327
+ const httpOnlyRoute: IRouteConfig = {
328
+ name: 'http-api',
329
+ match: {
330
+ ports: 443,
331
+ domains: 'api.example.com',
332
+ protocol: 'http', // Only match HTTP/1.1, HTTP/2, and WebSocket upgrades
333
+ },
334
+ action: {
335
+ type: 'forward',
336
+ targets: [{ host: 'api-backend', port: 8080 }],
337
+ tls: { mode: 'terminate', certificate: 'auto' }
338
+ }
339
+ };
340
+
341
+ // Raw TCP route (rejects HTTP traffic)
342
+ const tcpOnlyRoute: IRouteConfig = {
343
+ name: 'database-proxy',
344
+ match: {
345
+ ports: 5432,
346
+ protocol: 'tcp', // Only match non-HTTP TCP streams
347
+ },
348
+ action: {
349
+ type: 'forward',
350
+ targets: [{ host: 'db-server', port: 5432 }]
351
+ }
352
+ };
353
+ ```
354
+
355
+ > **Note:** Omitting `protocol` (the default) matches any protocol. For TLS routes, protocol detection happens *after* TLS termination — during the initial SNI-based route match, `protocol` is not yet known and the route is allowed to match. The protocol restriction is enforced after the proxy peeks at the decrypted data.
356
+
321
357
  ### 🔒 Security Controls
322
358
 
323
359
  Comprehensive per-route security options:
@@ -549,6 +585,7 @@ interface IRouteMatch {
549
585
  clientIp?: string[]; // ['10.0.0.0/8', '192.168.*']
550
586
  tlsVersion?: string[]; // ['TLSv1.2', 'TLSv1.3']
551
587
  headers?: Record<string, string | RegExp>; // Match by HTTP headers
588
+ protocol?: 'http' | 'tcp'; // Match specific protocol ('http' includes h2 + WebSocket upgrades)
552
589
  }
553
590
  ```
554
591
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartproxy',
6
- version: '25.6.0',
6
+ version: '25.7.0',
7
7
  description: 'A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.'
8
8
  }