2025-05-19 17:39:35 +00:00
# SmartProxy v19.4.0 - Completed Refactoring
2025-05-19 01:59:52 +00:00
2025-05-19 17:28:05 +00:00
## Overview
2025-05-19 01:59:52 +00:00
2025-05-19 17:39:35 +00:00
SmartProxy has been successfully refactored with clearer separation of concerns between HTTP/HTTPS traffic handling and low-level connection routing. Version 19.4.0 introduces global ACME configuration and enhanced route management.
2025-05-19 17:28:05 +00:00
2025-05-19 17:39:35 +00:00
## Current Architecture (v19.4.0)
2025-05-19 17:28:05 +00:00
2025-05-19 17:39:35 +00:00
### HttpProxy (formerly NetworkProxy)
2025-05-19 17:28:05 +00:00
**Purpose**: Handle all HTTP/HTTPS traffic with TLS termination
2025-05-19 17:39:35 +00:00
**Current Responsibilities**:
2025-05-19 17:28:05 +00:00
- TLS termination for HTTPS
- HTTP/1.1 and HTTP/2 protocol handling
- HTTP request/response parsing
- HTTP to HTTPS redirects
- ACME challenge handling
- Static route handlers
- WebSocket protocol upgrades
- Connection pooling for backend servers
2025-05-19 17:39:35 +00:00
- Certificate management integration
2025-05-19 17:28:05 +00:00
### SmartProxy
2025-05-19 17:39:35 +00:00
**Purpose**: Central API for all proxy needs with route-based configuration
2025-05-19 17:28:05 +00:00
2025-05-19 17:39:35 +00:00
**Current Responsibilities**:
2025-05-19 17:28:05 +00:00
- Port management (listen on multiple ports)
- Route-based connection routing
- TLS passthrough (SNI-based routing)
- NFTables integration
2025-05-19 17:39:35 +00:00
- Certificate management via SmartCertManager
2025-05-19 17:28:05 +00:00
- Raw TCP proxying
- Connection lifecycle management
2025-05-19 17:39:35 +00:00
- Global ACME configuration (v19+)
2025-05-19 17:28:05 +00:00
2025-05-19 17:39:35 +00:00
## Completed Implementation
2025-05-19 17:28:05 +00:00
2025-05-19 17:39:35 +00:00
### Phase 1: Rename and Reorganize ✅
- NetworkProxy renamed to HttpProxy
- Directory structure reorganized
- All imports and references updated
2025-05-19 17:28:05 +00:00
2025-05-19 17:39:35 +00:00
### Phase 2: Certificate Management ✅
- Unified certificate management in SmartCertManager
- Global ACME configuration support (v19+)
- Route-level certificate overrides
- Automatic renewal system
2025-05-19 17:28:05 +00:00
- Renamed `network-proxy.ts` to `http-proxy.ts`
- Updated `NetworkProxy` class to `HttpProxy` class
- Updated all type definitions and interfaces
3. **Update exports**
- Updated exports in `ts/index.ts`
- Fixed imports across the codebase
### Phase 2: Extract HTTP Logic from SmartProxy ✅
2025-05-18 22:41:41 +00:00
2025-05-19 17:28:05 +00:00
1. **Create HTTP handler modules in HttpProxy**
- Created handlers directory with:
- `redirect-handler.ts` - HTTP redirect logic
- `static-handler.ts` - Static/ACME route handling
- `index.ts` - Module exports
2. **Move HTTP parsing from RouteConnectionHandler**
- Updated `handleRedirectAction` to delegate to `RedirectHandler`
- Updated `handleStaticAction` to delegate to `StaticHandler`
- Removed duplicated HTTP parsing logic
3. **Clean up references and naming**
- Updated all NetworkProxy references to HttpProxy
- Renamed config properties: `useNetworkProxy` → `useHttpProxy`
- Renamed config properties: `networkProxyPort` → `httpProxyPort`
- Fixed HttpProxyBridge methods and references
### Phase 3: Simplify SmartProxy
1. **Update RouteConnectionHandler**
- Remove embedded HTTP parsing
- Delegate HTTP routes to HttpProxy
- Focus on connection routing only
2. **Simplified route handling**
2025-05-18 22:41:41 +00:00
```typescript
2025-05-19 17:28:05 +00:00
// Simplified handleRedirectAction
private handleRedirectAction(socket, record, route) {
// Delegate to HttpProxy
this.httpProxy.handleRedirect(socket, route);
}
2025-05-19 01:59:52 +00:00
2025-05-19 17:28:05 +00:00
// Simplified handleStaticAction
private handleStaticAction(socket, record, route) {
// Delegate to HttpProxy
this.httpProxy.handleStatic(socket, route);
2025-05-18 22:41:41 +00:00
}
```
2025-05-19 17:28:05 +00:00
3. **Update NetworkProxyBridge**
- Rename to HttpProxyBridge
- Update integration points
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
### Phase 4: Consolidate HTTP Utilities ✅
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
1. **Move HTTP types to http-proxy**
- Created consolidated `http-types.ts` in `ts/proxies/http-proxy/models/`
- Includes HTTP status codes, error classes, and interfaces
- Added helper functions like `getStatusText()`
2. **Clean up ts/http directory**
- Kept only router functionality
- Replaced local HTTP types with re-exports from HttpProxy
- Updated imports throughout the codebase to use consolidated types
### Phase 5: Update Tests and Documentation ✅
1. **Update test files**
- Renamed NetworkProxy references to HttpProxy
- Renamed test files to match new naming
- Updated imports and references throughout tests
- Fixed certificate manager method names
2. **Update documentation**
- Updated README to reflect HttpProxy naming
- Updated architecture descriptions
- Updated usage examples
- Fixed all API documentation references
## Migration Steps
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
1. Create feature branch: `refactor/http-proxy-consolidation`
2. Phase 1: Rename NetworkProxy (1 day)
3. Phase 2: Extract HTTP logic (2 days)
4. Phase 3: Simplify SmartProxy (1 day)
5. Phase 4: Consolidate utilities (1 day)
6. Phase 5: Update tests/docs (1 day)
7. Integration testing (1 day)
8. Code review and merge
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
## Benefits
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
1. **Clear Separation** : HTTP/HTTPS handling is clearly separated from TCP routing
2. **Better Naming** : HttpProxy clearly indicates its purpose
3. **No Duplication** : HTTP parsing logic exists in one place
4. **Maintainability** : Easier to modify HTTP handling without affecting routing
5. **Testability** : Each component has a single responsibility
6. **Performance** : Optimized paths for different traffic types
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
## Future Enhancements
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
After this refactoring, we can more easily add:
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
1. HTTP/3 (QUIC) support in HttpProxy
2. Advanced HTTP features (compression, caching)
3. HTTP middleware system
4. Protocol-specific optimizations
5. Better HTTP/2 multiplexing
2025-05-19 03:40:58 +00:00
2025-05-19 17:39:35 +00:00
## Breaking Changes from v18 to v19
2025-05-19 03:40:58 +00:00
2025-05-19 17:28:05 +00:00
1. `NetworkProxy` class renamed to `HttpProxy`
2. Import paths change from `network-proxy` to `http-proxy`
2025-05-19 17:39:35 +00:00
3. Global ACME configuration now available at the top level
4. Certificate management unified under SmartCertManager
## Future Enhancements
1. HTTP/3 (QUIC) support in HttpProxy
2. Advanced HTTP features (compression, caching)
3. HTTP middleware system
4. Protocol-specific optimizations
5. Better HTTP/2 multiplexing
6. Enhanced monitoring and metrics
2025-05-19 03:40:58 +00:00
2025-05-19 17:39:35 +00:00
## Key Features in v19.4.0
2025-05-19 03:40:58 +00:00
2025-05-19 17:39:35 +00:00
1. **Global ACME Configuration** : Default settings for all routes with `certificate: 'auto'`
2. **Enhanced Route Management** : Better separation between routing and certificate management
3. **Improved Test Coverage** : Fixed test exports and port bindings
4. **Better Error Messages** : Clear guidance for ACME configuration issues
5. **Non-Privileged Port Support** : Examples for development environments