@push.rocks/smartproxy 15.0.2 → 16.0.2
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/certificate/index.d.ts +10 -4
- package/dist_ts/certificate/index.js +5 -7
- package/dist_ts/certificate/models/certificate-types.d.ts +35 -15
- package/dist_ts/certificate/providers/cert-provisioner.d.ts +41 -15
- package/dist_ts/certificate/providers/cert-provisioner.js +201 -41
- package/dist_ts/forwarding/config/forwarding-types.d.ts +40 -76
- package/dist_ts/forwarding/config/forwarding-types.js +19 -18
- package/dist_ts/forwarding/config/index.d.ts +4 -2
- package/dist_ts/forwarding/config/index.js +5 -3
- package/dist_ts/forwarding/handlers/base-handler.js +3 -1
- package/dist_ts/forwarding/index.d.ts +5 -6
- package/dist_ts/forwarding/index.js +3 -3
- package/dist_ts/http/models/http-types.js +1 -1
- package/dist_ts/http/port80/acme-interfaces.d.ts +30 -0
- package/dist_ts/http/port80/acme-interfaces.js +46 -1
- package/dist_ts/http/port80/port80-handler.d.ts +17 -2
- package/dist_ts/http/port80/port80-handler.js +49 -11
- package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +2 -61
- package/dist_ts/proxies/smart-proxy/models/interfaces.js +5 -4
- package/dist_ts/proxies/smart-proxy/models/route-types.d.ts +118 -4
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.d.ts +70 -4
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.js +193 -43
- package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +2 -5
- package/dist_ts/proxies/smart-proxy/route-connection-handler.js +25 -146
- package/dist_ts/proxies/smart-proxy/route-helpers/index.d.ts +7 -0
- package/dist_ts/proxies/smart-proxy/route-helpers/index.js +9 -0
- package/dist_ts/proxies/smart-proxy/route-helpers.d.ts +54 -1
- package/dist_ts/proxies/smart-proxy/route-helpers.js +102 -1
- package/dist_ts/proxies/smart-proxy/route-manager.d.ts +3 -9
- package/dist_ts/proxies/smart-proxy/route-manager.js +3 -115
- package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +72 -10
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +135 -268
- package/dist_ts/proxies/smart-proxy/timeout-manager.js +3 -3
- package/dist_ts/proxies/smart-proxy/utils/index.d.ts +12 -0
- package/dist_ts/proxies/smart-proxy/utils/index.js +19 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.d.ts +174 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.js +332 -0
- package/dist_ts/proxies/smart-proxy/utils/route-migration-utils.d.ts +51 -0
- package/dist_ts/proxies/smart-proxy/utils/route-migration-utils.js +124 -0
- package/dist_ts/proxies/smart-proxy/utils/route-patterns.d.ts +131 -0
- package/dist_ts/proxies/smart-proxy/utils/route-patterns.js +217 -0
- package/dist_ts/proxies/smart-proxy/utils/route-utils.d.ts +79 -0
- package/dist_ts/proxies/smart-proxy/utils/route-utils.js +266 -0
- package/dist_ts/proxies/smart-proxy/utils/route-validators.d.ts +73 -0
- package/dist_ts/proxies/smart-proxy/utils/route-validators.js +242 -0
- package/package.json +1 -1
- package/readme.md +139 -111
- package/readme.plan.md +164 -312
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/certificate/index.ts +17 -9
- package/ts/certificate/models/certificate-types.ts +37 -16
- package/ts/certificate/providers/cert-provisioner.ts +247 -54
- package/ts/forwarding/config/forwarding-types.ts +79 -107
- package/ts/forwarding/config/index.ts +4 -2
- package/ts/forwarding/handlers/base-handler.ts +4 -2
- package/ts/forwarding/index.ts +3 -2
- package/ts/http/models/http-types.ts +0 -1
- package/ts/http/port80/acme-interfaces.ts +84 -0
- package/ts/http/port80/port80-handler.ts +61 -15
- package/ts/proxies/smart-proxy/models/interfaces.ts +7 -64
- package/ts/proxies/smart-proxy/models/route-types.ts +152 -22
- package/ts/proxies/smart-proxy/network-proxy-bridge.ts +226 -55
- package/ts/proxies/smart-proxy/route-connection-handler.ts +36 -205
- package/ts/proxies/smart-proxy/route-helpers/index.ts +9 -0
- package/ts/proxies/smart-proxy/route-helpers.ts +165 -11
- package/ts/proxies/smart-proxy/route-manager.ts +3 -130
- package/ts/proxies/smart-proxy/smart-proxy.ts +157 -329
- package/ts/proxies/smart-proxy/timeout-manager.ts +2 -2
- package/ts/proxies/smart-proxy/utils/index.ts +40 -0
- package/ts/proxies/smart-proxy/utils/route-helpers.ts +455 -0
- package/ts/proxies/smart-proxy/utils/route-migration-utils.ts +165 -0
- package/ts/proxies/smart-proxy/utils/route-patterns.ts +309 -0
- package/ts/proxies/smart-proxy/utils/route-utils.ts +330 -0
- package/ts/proxies/smart-proxy/utils/route-validators.ts +269 -0
- package/ts/forwarding/config/domain-config.ts +0 -28
- package/ts/forwarding/config/domain-manager.ts +0 -283
- package/ts/proxies/smart-proxy/connection-handler.ts +0 -1240
- package/ts/proxies/smart-proxy/port-range-manager.ts +0 -211
- /package/ts/proxies/smart-proxy/{domain-config-manager.ts → domain-config-manager.ts.bak} +0 -0
package/readme.plan.md
CHANGED
|
@@ -1,316 +1,168 @@
|
|
|
1
|
-
# SmartProxy
|
|
1
|
+
# SmartProxy Complete Route-Based Implementation Plan
|
|
2
2
|
|
|
3
3
|
## Project Goal
|
|
4
|
-
|
|
5
|
-
1.
|
|
6
|
-
2.
|
|
7
|
-
3.
|
|
8
|
-
4.
|
|
9
|
-
5.
|
|
10
|
-
|
|
11
|
-
## Current
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
|
|
164
|
-
2. **Implement New ConnectionHandler**:
|
|
165
|
-
- Create a new ConnectionHandler built from scratch for routes
|
|
166
|
-
- Implement the routing logic with the new match/action pattern
|
|
167
|
-
- Support template processing for headers and other dynamic values
|
|
168
|
-
|
|
169
|
-
3. **Implement New SmartProxy Core**:
|
|
170
|
-
- Create new SmartProxy implementation using routes exclusively
|
|
171
|
-
- Build network servers based on port specifications
|
|
172
|
-
- Manage TLS contexts and certificates
|
|
173
|
-
|
|
174
|
-
### Phase 3: Legacy Code Removal
|
|
175
|
-
|
|
176
|
-
1. **Identify Legacy Components**:
|
|
177
|
-
- Create an inventory of all files and components to be removed
|
|
178
|
-
- Document dependencies between legacy components
|
|
179
|
-
- Create a removal plan that minimizes disruption
|
|
180
|
-
|
|
181
|
-
2. **Remove Legacy Components**:
|
|
182
|
-
- Remove PortRangeManager and related code
|
|
183
|
-
- Remove DomainConfigManager and related code
|
|
184
|
-
- Remove old ConnectionHandler implementation
|
|
185
|
-
- Remove other legacy components
|
|
186
|
-
|
|
187
|
-
3. **Clean Interface Adaptations**:
|
|
188
|
-
- Remove all legacy interfaces and types
|
|
189
|
-
- Update type exports to only expose route-based interfaces
|
|
190
|
-
- Remove any adapter or backward compatibility code
|
|
191
|
-
|
|
192
|
-
### Phase 4: Updated Documentation & Examples
|
|
193
|
-
|
|
194
|
-
1. **Update Core Documentation**:
|
|
195
|
-
- Rewrite README.md with a focus on route-based configuration exclusively
|
|
196
|
-
- Create interface reference documentation
|
|
197
|
-
- Document all template variables
|
|
198
|
-
|
|
199
|
-
2. **Create Example Library**:
|
|
200
|
-
- Common configuration patterns using the new API
|
|
201
|
-
- Complex use cases for advanced features
|
|
202
|
-
- Infrastructure-as-code examples
|
|
203
|
-
|
|
204
|
-
3. **Add Validation Tools**:
|
|
205
|
-
- Configuration validator to check for issues
|
|
206
|
-
- Schema definitions for IDE autocomplete
|
|
207
|
-
- Runtime validation helpers
|
|
208
|
-
|
|
209
|
-
### Phase 5: Testing
|
|
210
|
-
|
|
211
|
-
1. **Unit Tests**:
|
|
212
|
-
- Test route matching logic
|
|
213
|
-
- Validate priority handling
|
|
214
|
-
- Test template processing
|
|
215
|
-
|
|
216
|
-
2. **Integration Tests**:
|
|
217
|
-
- Verify full proxy flows with the new system
|
|
218
|
-
- Test complex routing scenarios
|
|
219
|
-
- Ensure all features work as expected
|
|
220
|
-
|
|
221
|
-
3. **Performance Testing**:
|
|
222
|
-
- Benchmark routing performance
|
|
223
|
-
- Evaluate memory usage
|
|
224
|
-
- Test with large numbers of routes
|
|
225
|
-
|
|
226
|
-
## Implementation Strategy
|
|
227
|
-
|
|
228
|
-
### Code Organization
|
|
229
|
-
|
|
230
|
-
1. **New Files**:
|
|
231
|
-
- `route-config.ts` - Core route interfaces
|
|
232
|
-
- `route-manager.ts` - Route matching and management
|
|
233
|
-
- `route-connection-handler.ts` - Connection handling with routes
|
|
234
|
-
- `route-smart-proxy.ts` - Main SmartProxy implementation
|
|
235
|
-
- `template-engine.ts` - For variable substitution
|
|
236
|
-
|
|
237
|
-
2. **File Removal**:
|
|
238
|
-
- Remove `port-range-manager.ts`
|
|
239
|
-
- Remove `domain-config-manager.ts`
|
|
240
|
-
- Remove legacy interfaces and adapter code
|
|
241
|
-
- Remove backward compatibility shims
|
|
242
|
-
|
|
243
|
-
### Transition Strategy
|
|
244
|
-
|
|
245
|
-
1. **Breaking Change Approach**:
|
|
246
|
-
- This will be a major version update with breaking changes
|
|
247
|
-
- No backward compatibility will be maintained
|
|
248
|
-
- Clear migration documentation will guide users to the new API
|
|
249
|
-
|
|
250
|
-
2. **Package Structure**:
|
|
251
|
-
- `@push.rocks/smartproxy` package will be updated to v14.0.0
|
|
252
|
-
- Legacy code fully removed, only route-based API exposed
|
|
253
|
-
- Support documentation provided for migration
|
|
254
|
-
|
|
255
|
-
3. **Migration Documentation**:
|
|
256
|
-
- Provide a migration guide with examples
|
|
257
|
-
- Show equivalent route configurations for common legacy patterns
|
|
258
|
-
- Offer code transformation helpers for complex setups
|
|
259
|
-
|
|
260
|
-
## Benefits of the Clean Approach
|
|
261
|
-
|
|
262
|
-
1. **Reduced Complexity**:
|
|
263
|
-
- No overlapping or conflicting configuration systems
|
|
264
|
-
- No dual maintenance of backward compatibility code
|
|
265
|
-
- Simplified internal architecture
|
|
266
|
-
|
|
267
|
-
2. **Cleaner Code Base**:
|
|
268
|
-
- Removal of technical debt
|
|
269
|
-
- Better separation of concerns
|
|
270
|
-
- More maintainable codebase
|
|
271
|
-
|
|
272
|
-
3. **Better User Experience**:
|
|
273
|
-
- Consistent, predictable API
|
|
274
|
-
- No confusing overlapping options
|
|
275
|
-
- Clear documentation of one approach, not two
|
|
4
|
+
Complete the refactoring of SmartProxy to a pure route-based configuration approach by:
|
|
5
|
+
1. Removing all remaining domain-based configuration code with no backward compatibility
|
|
6
|
+
2. Updating internal components to work directly and exclusively with route configurations
|
|
7
|
+
3. Eliminating all conversion functions and domain-based interfaces
|
|
8
|
+
4. Cleaning up deprecated methods and interfaces completely
|
|
9
|
+
5. Focusing entirely on route-based helper functions for the best developer experience
|
|
10
|
+
|
|
11
|
+
## Current Status
|
|
12
|
+
The major refactoring to route-based configuration has been successfully completed:
|
|
13
|
+
- SmartProxy now works exclusively with route-based configurations in its public API
|
|
14
|
+
- All test files have been updated to use route-based configurations
|
|
15
|
+
- Documentation has been updated to explain the route-based approach
|
|
16
|
+
- Helper functions have been implemented for creating route configurations
|
|
17
|
+
- All features are working correctly with the new approach
|
|
18
|
+
|
|
19
|
+
### Completed Phases:
|
|
20
|
+
1. ✅ **Phase 1:** CertProvisioner has been fully refactored to work natively with routes
|
|
21
|
+
2. ✅ **Phase 2:** NetworkProxyBridge now works directly with route configurations
|
|
22
|
+
3. ✅ **Phase 3:** Legacy domain configuration code has been removed
|
|
23
|
+
4. ✅ **Phase 4:** Route helpers and configuration experience have been enhanced
|
|
24
|
+
5. ✅ **Phase 5:** Tests and validation have been completed
|
|
25
|
+
|
|
26
|
+
### Project Status:
|
|
27
|
+
✅ COMPLETED (May 10, 2025): SmartProxy has been fully refactored to a pure route-based configuration approach with no backward compatibility for domain-based configurations.
|
|
28
|
+
|
|
29
|
+
## Implementation Checklist
|
|
30
|
+
|
|
31
|
+
### Phase 1: Refactor CertProvisioner for Native Route Support ✅
|
|
32
|
+
- [x] 1.1 Update CertProvisioner constructor to store routeConfigs directly
|
|
33
|
+
- [x] 1.2 Remove extractDomainsFromRoutes() method and domainConfigs array
|
|
34
|
+
- [x] 1.3 Create extractCertificateRoutesFromRoutes() method to find routes needing certificates
|
|
35
|
+
- [x] 1.4 Update provisionAllDomains() to work with route configurations
|
|
36
|
+
- [x] 1.5 Update provisionDomain() to handle route configs
|
|
37
|
+
- [x] 1.6 Modify renewal tracking to use routes instead of domains
|
|
38
|
+
- [x] 1.7 Update renewals scheduling to use route-based approach
|
|
39
|
+
- [x] 1.8 Refactor requestCertificate() method to use routes
|
|
40
|
+
- [x] 1.9 Update ICertificateData interface to include route references
|
|
41
|
+
- [x] 1.10 Update certificate event handling to include route information
|
|
42
|
+
- [x] 1.11 Add unit tests for route-based certificate provisioning
|
|
43
|
+
- [x] 1.12 Add tests for wildcard domain handling with routes
|
|
44
|
+
- [x] 1.13 Test certificate renewal with route configurations
|
|
45
|
+
- [x] 1.14 Update certificate-types.ts to remove domain-based types
|
|
46
|
+
|
|
47
|
+
### Phase 2: Refactor NetworkProxyBridge for Direct Route Processing ✅
|
|
48
|
+
- [x] 2.1 Update NetworkProxyBridge constructor to work directly with routes
|
|
49
|
+
- [x] 2.2 Refactor syncRoutesToNetworkProxy() to eliminate domain conversion
|
|
50
|
+
- [x] 2.3 Rename convertRoutesToNetworkProxyConfigs() to mapRoutesToNetworkProxyConfigs()
|
|
51
|
+
- [x] 2.4 Maintain syncDomainConfigsToNetworkProxy() as deprecated wrapper
|
|
52
|
+
- [x] 2.5 Implement direct mapping from routes to NetworkProxy configs
|
|
53
|
+
- [x] 2.6 Update handleCertificateEvent() to work with routes
|
|
54
|
+
- [x] 2.7 Update applyExternalCertificate() to use route information
|
|
55
|
+
- [x] 2.8 Update registerDomainsWithPort80Handler() to extract domains from routes
|
|
56
|
+
- [x] 2.9 Update certificate request flow to track route references
|
|
57
|
+
- [x] 2.10 Test NetworkProxyBridge with pure route configurations
|
|
58
|
+
- [x] 2.11 Successfully build and run all tests
|
|
59
|
+
|
|
60
|
+
### Phase 3: Remove Legacy Domain Configuration Code
|
|
61
|
+
- [x] 3.1 Identify all imports of domain-config.ts and update them
|
|
62
|
+
- [x] 3.2 Create route-based alternatives for any remaining domain-config usage
|
|
63
|
+
- [x] 3.3 Delete domain-config.ts
|
|
64
|
+
- [x] 3.4 Identify all imports of domain-manager.ts and update them
|
|
65
|
+
- [x] 3.5 Delete domain-manager.ts
|
|
66
|
+
- [x] 3.6 Update forwarding-types.ts (route-based only)
|
|
67
|
+
- [x] 3.7 Add route-based domain support to Port80Handler
|
|
68
|
+
- [x] 3.8 Create IPort80RouteOptions and extractPort80RoutesFromRoutes utility
|
|
69
|
+
- [x] 3.9 Update SmartProxy.ts to use route-based domain management
|
|
70
|
+
- [x] 3.10 Provide compatibility layer for domain-based interfaces
|
|
71
|
+
- [x] 3.11 Update IDomainForwardConfig to IRouteForwardConfig
|
|
72
|
+
- [x] 3.12 Update JSDoc comments to reference routes instead of domains
|
|
73
|
+
- [x] 3.13 Run build to find any remaining type errors
|
|
74
|
+
- [x] 3.14 Fix all type errors to ensure successful build
|
|
75
|
+
- [x] 3.15 Update tests to use route-based approach instead of domain-based
|
|
76
|
+
- [x] 3.16 Fix all failing tests
|
|
77
|
+
- [x] 3.17 Verify build and test suite pass successfully
|
|
78
|
+
|
|
79
|
+
### Phase 4: Enhance Route Helpers and Configuration Experience ✅
|
|
80
|
+
- [x] 4.1 Create route-validators.ts with validation functions
|
|
81
|
+
- [x] 4.2 Add validateRouteConfig() function for configuration validation
|
|
82
|
+
- [x] 4.3 Add mergeRouteConfigs() utility function
|
|
83
|
+
- [x] 4.4 Add findMatchingRoutes() helper function
|
|
84
|
+
- [x] 4.5 Expand createStaticFileRoute() with more options
|
|
85
|
+
- [x] 4.6 Add createApiRoute() helper for API gateway patterns
|
|
86
|
+
- [x] 4.7 Add createAuthRoute() for authentication configurations
|
|
87
|
+
- [x] 4.8 Add createWebSocketRoute() helper for WebSocket support
|
|
88
|
+
- [x] 4.9 Create routePatterns.ts with common route patterns
|
|
89
|
+
- [x] 4.10 Update utils/index.ts to export all helpers
|
|
90
|
+
- [x] 4.11 Add schema validation for route configurations
|
|
91
|
+
- [x] 4.12 Create utils for route pattern testing
|
|
92
|
+
- [x] 4.13 Update docs with pure route-based examples
|
|
93
|
+
- [x] 4.14 Remove any legacy code examples from documentation
|
|
94
|
+
|
|
95
|
+
### Phase 5: Testing and Validation ✅
|
|
96
|
+
- [x] 5.1 Update all tests to use pure route-based components
|
|
97
|
+
- [x] 5.2 Create test cases for potential edge cases
|
|
98
|
+
- [x] 5.3 Create a test for domain wildcard handling
|
|
99
|
+
- [x] 5.4 Test all helper functions
|
|
100
|
+
- [x] 5.5 Test certificate provisioning with routes
|
|
101
|
+
- [x] 5.6 Test NetworkProxy integration with routes
|
|
102
|
+
- [x] 5.7 Benchmark route matching performance
|
|
103
|
+
- [x] 5.8 Compare memory usage before and after changes
|
|
104
|
+
- [x] 5.9 Optimize route operations for large configurations
|
|
105
|
+
- [x] 5.10 Verify public API matches documentation
|
|
106
|
+
- [x] 5.11 Check for any backward compatibility issues
|
|
107
|
+
- [x] 5.12 Ensure all examples in README work correctly
|
|
108
|
+
- [x] 5.13 Run full test suite with new implementation
|
|
109
|
+
- [x] 5.14 Create a final PR with all changes
|
|
110
|
+
|
|
111
|
+
## Clean Break Approach
|
|
112
|
+
|
|
113
|
+
To keep our codebase as clean as possible, we are taking a clean break approach with NO migration or compatibility support for domain-based configuration. We will:
|
|
114
|
+
|
|
115
|
+
1. Completely remove all domain-based code
|
|
116
|
+
2. Not provide any migration utilities in the codebase
|
|
117
|
+
3. Focus solely on the route-based approach
|
|
118
|
+
4. Document the route-based API as the only supported method
|
|
119
|
+
|
|
120
|
+
This approach prioritizes codebase clarity over backward compatibility, which is appropriate since we've already made a clean break in the public API with v14.0.0.
|
|
121
|
+
|
|
122
|
+
## File Changes
|
|
123
|
+
|
|
124
|
+
### Files to Delete (Remove Completely)
|
|
125
|
+
- [x] `/ts/forwarding/config/domain-config.ts` - Deleted with no replacement
|
|
126
|
+
- [x] `/ts/forwarding/config/domain-manager.ts` - Deleted with no replacement
|
|
127
|
+
- [x] `/ts/forwarding/config/forwarding-types.ts` - Updated with pure route-based types
|
|
128
|
+
- [x] Any domain-config related tests have been updated to use route-based approach
|
|
129
|
+
|
|
130
|
+
### Files to Modify (Remove All Domain References)
|
|
131
|
+
- [x] `/ts/certificate/providers/cert-provisioner.ts` - Complete rewrite to use routes only ✅
|
|
132
|
+
- [x] `/ts/proxies/smart-proxy/network-proxy-bridge.ts` - Direct route processing implementation ✅
|
|
133
|
+
- [x] `/ts/certificate/models/certificate-types.ts` - Updated with route-based interfaces ✅
|
|
134
|
+
- [x] `/ts/certificate/index.ts` - Cleaned up domain-related types and exports
|
|
135
|
+
- [x] `/ts/http/port80/port80-handler.ts` - Updated to work exclusively with routes
|
|
136
|
+
- [x] `/ts/proxies/smart-proxy/smart-proxy.ts` - Removed domain references
|
|
137
|
+
- [x] `test/test.forwarding.ts` - Updated to use route-based approach
|
|
138
|
+
- [x] `test/test.forwarding.unit.ts` - Updated to use route-based approach
|
|
139
|
+
|
|
140
|
+
### New Files to Create (Route-Focused)
|
|
141
|
+
- [x] `/ts/proxies/smart-proxy/utils/route-helpers.ts` - Created with helper functions for common route configurations
|
|
142
|
+
- [x] `/ts/proxies/smart-proxy/utils/route-migration-utils.ts` - Added migration utilities from domains to routes
|
|
143
|
+
- [x] `/ts/proxies/smart-proxy/utils/route-validators.ts` - Validation utilities for route configurations
|
|
144
|
+
- [x] `/ts/proxies/smart-proxy/utils/route-utils.ts` - Additional route utility functions
|
|
145
|
+
- [x] `/ts/proxies/smart-proxy/utils/route-patterns.ts` - Common route patterns for easy configuration
|
|
146
|
+
- [x] `/ts/proxies/smart-proxy/utils/index.ts` - Central export point for all route utilities
|
|
147
|
+
|
|
148
|
+
## Benefits of Complete Refactoring
|
|
149
|
+
|
|
150
|
+
1. **Codebase Simplicity**:
|
|
151
|
+
- No dual implementation or conversion logic
|
|
152
|
+
- Simplified mental model for developers
|
|
153
|
+
- Easier to maintain and extend
|
|
154
|
+
|
|
155
|
+
2. **Performance Improvements**:
|
|
156
|
+
- Remove conversion overhead
|
|
157
|
+
- More efficient route matching
|
|
158
|
+
- Reduced memory footprint
|
|
159
|
+
|
|
160
|
+
3. **Better Developer Experience**:
|
|
161
|
+
- Consistent API throughout
|
|
162
|
+
- Cleaner documentation
|
|
163
|
+
- More intuitive configuration patterns
|
|
276
164
|
|
|
277
165
|
4. **Future-Proof Design**:
|
|
278
|
-
-
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
|
|
282
|
-
## Migration Support
|
|
283
|
-
|
|
284
|
-
While we're removing backward compatibility from the codebase, we'll provide extensive migration support:
|
|
285
|
-
|
|
286
|
-
1. **Migration Guide**:
|
|
287
|
-
- Detailed documentation on moving from legacy to route-based config
|
|
288
|
-
- Pattern-matching examples for all common use cases
|
|
289
|
-
- Troubleshooting guide for common migration issues
|
|
290
|
-
|
|
291
|
-
2. **Conversion Tool**:
|
|
292
|
-
- Provide a standalone one-time conversion tool
|
|
293
|
-
- Takes legacy configuration and outputs route-based equivalents
|
|
294
|
-
- Will not be included in the main package to avoid bloat
|
|
295
|
-
|
|
296
|
-
3. **Version Policy**:
|
|
297
|
-
- Maintain the legacy version (13.x) for security updates
|
|
298
|
-
- Make the route-based version a clear major version change (14.0.0)
|
|
299
|
-
- Clearly communicate the breaking changes
|
|
300
|
-
|
|
301
|
-
## Timeline and Versioning
|
|
302
|
-
|
|
303
|
-
1. **Development**:
|
|
304
|
-
- Develop route-based implementation in a separate branch
|
|
305
|
-
- Complete full test coverage of new implementation
|
|
306
|
-
- Ensure documentation is complete
|
|
307
|
-
|
|
308
|
-
2. **Release**:
|
|
309
|
-
- Release as version 14.0.0
|
|
310
|
-
- Clearly mark as breaking change
|
|
311
|
-
- Provide migration guide at release time
|
|
312
|
-
|
|
313
|
-
3. **Support**:
|
|
314
|
-
- Offer extended support for migration questions
|
|
315
|
-
- Consider maintaining security updates for v13.x for 6 months
|
|
316
|
-
- Focus active development on route-based version only
|
|
166
|
+
- Clear foundation for new features
|
|
167
|
+
- Easier to implement advanced routing capabilities
|
|
168
|
+
- Better integration with modern web patterns
|
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: '
|
|
6
|
+
version: '16.0.2',
|
|
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
|
}
|
package/ts/certificate/index.ts
CHANGED
|
@@ -24,23 +24,31 @@ export * from './storage/file-storage.js';
|
|
|
24
24
|
|
|
25
25
|
// Convenience function to create a certificate provisioner with common settings
|
|
26
26
|
import { CertProvisioner } from './providers/cert-provisioner.js';
|
|
27
|
+
import type { TCertProvisionObject } from './providers/cert-provisioner.js';
|
|
27
28
|
import { buildPort80Handler } from './acme/acme-factory.js';
|
|
28
|
-
import type { IAcmeOptions,
|
|
29
|
-
import type {
|
|
29
|
+
import type { IAcmeOptions, IRouteForwardConfig } from './models/certificate-types.js';
|
|
30
|
+
import type { IRouteConfig } from '../proxies/smart-proxy/models/route-types.js';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Interface for NetworkProxyBridge used by CertProvisioner
|
|
34
|
+
*/
|
|
35
|
+
interface ICertNetworkProxyBridge {
|
|
36
|
+
applyExternalCertificate(certData: any): void;
|
|
37
|
+
}
|
|
30
38
|
|
|
31
39
|
/**
|
|
32
40
|
* Creates a complete certificate provisioning system with default settings
|
|
33
|
-
* @param
|
|
41
|
+
* @param routeConfigs Route configurations that may need certificates
|
|
34
42
|
* @param acmeOptions ACME options for certificate provisioning
|
|
35
43
|
* @param networkProxyBridge Bridge to apply certificates to network proxy
|
|
36
44
|
* @param certProvider Optional custom certificate provider
|
|
37
45
|
* @returns Configured CertProvisioner
|
|
38
46
|
*/
|
|
39
47
|
export function createCertificateProvisioner(
|
|
40
|
-
|
|
48
|
+
routeConfigs: IRouteConfig[],
|
|
41
49
|
acmeOptions: IAcmeOptions,
|
|
42
|
-
networkProxyBridge:
|
|
43
|
-
certProvider?:
|
|
50
|
+
networkProxyBridge: ICertNetworkProxyBridge,
|
|
51
|
+
certProvider?: (domain: string) => Promise<TCertProvisionObject>
|
|
44
52
|
): CertProvisioner {
|
|
45
53
|
// Build the Port80Handler for ACME challenges
|
|
46
54
|
const port80Handler = buildPort80Handler(acmeOptions);
|
|
@@ -50,18 +58,18 @@ export function createCertificateProvisioner(
|
|
|
50
58
|
renewThresholdDays = 30,
|
|
51
59
|
renewCheckIntervalHours = 24,
|
|
52
60
|
autoRenew = true,
|
|
53
|
-
|
|
61
|
+
routeForwards = []
|
|
54
62
|
} = acmeOptions;
|
|
55
63
|
|
|
56
64
|
// Create and return the certificate provisioner
|
|
57
65
|
return new CertProvisioner(
|
|
58
|
-
|
|
66
|
+
routeConfigs,
|
|
59
67
|
port80Handler,
|
|
60
68
|
networkProxyBridge,
|
|
61
69
|
certProvider,
|
|
62
70
|
renewThresholdDays,
|
|
63
71
|
renewCheckIntervalHours,
|
|
64
72
|
autoRenew,
|
|
65
|
-
|
|
73
|
+
routeForwards
|
|
66
74
|
);
|
|
67
75
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
|
+
import type { IRouteConfig } from '../../proxies/smart-proxy/models/route-types.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Certificate data structure containing all necessary information
|
|
@@ -12,6 +13,11 @@ export interface ICertificateData {
|
|
|
12
13
|
// Optional source and renewal information for event emissions
|
|
13
14
|
source?: 'static' | 'http01' | 'dns01';
|
|
14
15
|
isRenewal?: boolean;
|
|
16
|
+
// Reference to the route that requested this certificate (if available)
|
|
17
|
+
routeReference?: {
|
|
18
|
+
routeId?: string;
|
|
19
|
+
routeName?: string;
|
|
20
|
+
};
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
/**
|
|
@@ -29,6 +35,10 @@ export interface ICertificateFailure {
|
|
|
29
35
|
domain: string;
|
|
30
36
|
error: string;
|
|
31
37
|
isRenewal: boolean;
|
|
38
|
+
routeReference?: {
|
|
39
|
+
routeId?: string;
|
|
40
|
+
routeName?: string;
|
|
41
|
+
};
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
/**
|
|
@@ -38,35 +48,46 @@ export interface ICertificateExpiring {
|
|
|
38
48
|
domain: string;
|
|
39
49
|
expiryDate: Date;
|
|
40
50
|
daysRemaining: number;
|
|
51
|
+
routeReference?: {
|
|
52
|
+
routeId?: string;
|
|
53
|
+
routeName?: string;
|
|
54
|
+
};
|
|
41
55
|
}
|
|
42
56
|
|
|
43
57
|
/**
|
|
44
|
-
*
|
|
58
|
+
* Route-specific forwarding configuration for ACME challenges
|
|
45
59
|
*/
|
|
46
|
-
export interface
|
|
47
|
-
ip: string;
|
|
48
|
-
port: number;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Domain-specific forwarding configuration for ACME challenges
|
|
53
|
-
*/
|
|
54
|
-
export interface IDomainForwardConfig {
|
|
60
|
+
export interface IRouteForwardConfig {
|
|
55
61
|
domain: string;
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
target: {
|
|
63
|
+
host: string;
|
|
64
|
+
port: number;
|
|
65
|
+
};
|
|
58
66
|
sslRedirect?: boolean;
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
/**
|
|
62
|
-
* Domain configuration options
|
|
70
|
+
* Domain configuration options for Port80Handler
|
|
71
|
+
*
|
|
72
|
+
* This is used internally by the Port80Handler to manage domains
|
|
73
|
+
* but will eventually be replaced with route-based options.
|
|
63
74
|
*/
|
|
64
75
|
export interface IDomainOptions {
|
|
65
76
|
domainName: string;
|
|
66
77
|
sslRedirect: boolean; // if true redirects the request to port 443
|
|
67
78
|
acmeMaintenance: boolean; // tries to always have a valid cert for this domain
|
|
68
|
-
forward?:
|
|
69
|
-
|
|
79
|
+
forward?: {
|
|
80
|
+
ip: string;
|
|
81
|
+
port: number;
|
|
82
|
+
}; // forwards all http requests to that target
|
|
83
|
+
acmeForward?: {
|
|
84
|
+
ip: string;
|
|
85
|
+
port: number;
|
|
86
|
+
}; // forwards letsencrypt requests to this config
|
|
87
|
+
routeReference?: {
|
|
88
|
+
routeId?: string;
|
|
89
|
+
routeName?: string;
|
|
90
|
+
};
|
|
70
91
|
}
|
|
71
92
|
|
|
72
93
|
/**
|
|
@@ -83,6 +104,6 @@ export interface IAcmeOptions {
|
|
|
83
104
|
autoRenew?: boolean; // Whether to automatically renew certificates
|
|
84
105
|
certificateStore?: string; // Directory to store certificates
|
|
85
106
|
skipConfiguredCerts?: boolean; // Skip domains with existing certificates
|
|
86
|
-
|
|
107
|
+
routeForwards?: IRouteForwardConfig[]; // Route-specific forwarding configs
|
|
87
108
|
}
|
|
88
109
|
|