From fb2354146e1989bb3d219a178b59f355aedaa309 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 9 May 2025 16:06:20 +0000 Subject: [PATCH] update plan --- readme.plan.md | 170 ++++++++++++++++++++++++------------------------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/readme.plan.md b/readme.plan.md index 9765e08..355a756 100644 --- a/readme.plan.md +++ b/readme.plan.md @@ -26,9 +26,9 @@ The codebase employs several strong design patterns: ## Target Directory Structure ``` -/src +/ts ├── /core # Core functionality -│ ├── /models # Data models and interfaces +│ ├── /models # Data models and interfaces │ ├── /utils # Shared utilities (IP validation, logging, etc.) │ └── /events # Common event definitions ├── /certificate # Certificate management @@ -69,15 +69,15 @@ The codebase employs several strong design patterns: ### Phase 1: Project Setup & Core Structure (Week 1) - [ ] Create new directory structure - - [ ] Create `src` directory and core subdirectories + - [ ] Create core subdirectories within `ts` directory - [ ] Set up barrel files (`index.ts`) in each directory - [ ] Migrate core utilities - - [ ] Move `ts/plugins.ts` → `src/core/utils/plugins.ts` - - [ ] Move `ts/common/types.ts` → `src/core/models/common-types.ts` - - [ ] Move `ts/common/eventUtils.ts` → `src/core/utils/event-utils.ts` - - [ ] Extract `ValidationUtils` → `src/core/utils/validation-utils.ts` - - [ ] Extract `IpUtils` → `src/core/utils/ip-utils.ts` + - [ ] Move `ts/plugins.ts` → `ts/core/utils/plugins.ts` + - [ ] Move `ts/common/types.ts` → `ts/core/models/common-types.ts` + - [ ] Move `ts/common/eventUtils.ts` → `ts/core/utils/event-utils.ts` + - [ ] Extract `ValidationUtils` → `ts/core/utils/validation-utils.ts` + - [ ] Extract `IpUtils` → `ts/core/utils/ip-utils.ts` - [ ] Update build and test scripts - [ ] Modify `package.json` build script for new structure @@ -88,85 +88,85 @@ The codebase employs several strong design patterns: This component has the cleanest design, so we'll start migration here: - [ ] Migrate forwarding types and interfaces - - [ ] Move `ts/smartproxy/types/forwarding.types.ts` → `src/forwarding/config/forwarding-types.ts` + - [ ] Move `ts/smartproxy/types/forwarding.types.ts` → `ts/forwarding/config/forwarding-types.ts` - [ ] Normalize interface names (remove 'I' prefix where appropriate) - [ ] Migrate domain configuration - - [ ] Move `ts/smartproxy/forwarding/domain-config.ts` → `src/forwarding/config/domain-config.ts` - - [ ] Move `ts/smartproxy/forwarding/domain-manager.ts` → `src/forwarding/config/domain-manager.ts` + - [ ] Move `ts/smartproxy/forwarding/domain-config.ts` → `ts/forwarding/config/domain-config.ts` + - [ ] Move `ts/smartproxy/forwarding/domain-manager.ts` → `ts/forwarding/config/domain-manager.ts` - [ ] Migrate handler implementations - - [ ] Move base handler: `forwarding.handler.ts` → `src/forwarding/handlers/base-handler.ts` - - [ ] Move HTTP handler: `http.handler.ts` → `src/forwarding/handlers/http-handler.ts` - - [ ] Move passthrough handler: `https-passthrough.handler.ts` → `src/forwarding/handlers/https-passthrough-handler.ts` - - [ ] Move TLS termination handlers to respective files in `src/forwarding/handlers/` - - [ ] Move factory: `forwarding.factory.ts` → `src/forwarding/factory/forwarding-factory.ts` + - [ ] Move base handler: `forwarding.handler.ts` → `ts/forwarding/handlers/base-handler.ts` + - [ ] Move HTTP handler: `http.handler.ts` → `ts/forwarding/handlers/http-handler.ts` + - [ ] Move passthrough handler: `https-passthrough.handler.ts` → `ts/forwarding/handlers/https-passthrough-handler.ts` + - [ ] Move TLS termination handlers to respective files in `ts/forwarding/handlers/` + - [ ] Move factory: `forwarding.factory.ts` → `ts/forwarding/factory/forwarding-factory.ts` - [ ] Create proper forwarding system exports - [ ] Update all imports in forwarding components using relative paths - - [ ] Create comprehensive barrel file in `src/forwarding/index.ts` + - [ ] Create comprehensive barrel file in `ts/forwarding/index.ts` - [ ] Test forwarding system in isolation ### Phase 3: Certificate Management Migration (Week 2) - [ ] Create certificate management structure - - [ ] Create `src/certificate/models/certificate-types.ts` for interfaces - - [ ] Extract certificate events to `src/certificate/events/` + - [ ] Create `ts/certificate/models/certificate-types.ts` for interfaces + - [ ] Extract certificate events to `ts/certificate/events/` - [ ] Migrate certificate providers - - [ ] Move `ts/classes.pp.certprovisioner.ts` → `src/certificate/providers/cert-provisioner.ts` - - [ ] Move `ts/common/acmeFactory.ts` → `src/certificate/acme/acme-factory.ts` - - [ ] Extract ACME challenge handling to `src/certificate/acme/challenge-handler.ts` + - [ ] Move `ts/classes.pp.certprovisioner.ts` → `ts/certificate/providers/cert-provisioner.ts` + - [ ] Move `ts/common/acmeFactory.ts` → `ts/certificate/acme/acme-factory.ts` + - [ ] Extract ACME challenge handling to `ts/certificate/acme/challenge-handler.ts` - [ ] Update certificate utilities - - [ ] Move `ts/helpers.certificates.ts` → `src/certificate/utils/certificate-helpers.ts` - - [ ] Create proper exports in `src/certificate/index.ts` + - [ ] Move `ts/helpers.certificates.ts` → `ts/certificate/utils/certificate-helpers.ts` + - [ ] Create proper exports in `ts/certificate/index.ts` ### Phase 4: TLS & SNI Handling Migration (Week 2-3) - [ ] Migrate TLS alert system - - [ ] Move `ts/smartproxy/classes.pp.tlsalert.ts` → `src/tls/alerts/tls-alert.ts` - - [ ] Extract common TLS utilities to `src/tls/utils/tls-utils.ts` + - [ ] Move `ts/smartproxy/classes.pp.tlsalert.ts` → `ts/tls/alerts/tls-alert.ts` + - [ ] Extract common TLS utilities to `ts/tls/utils/tls-utils.ts` - [ ] Migrate SNI handling - - [ ] Move `ts/smartproxy/classes.pp.snihandler.ts` → `src/tls/sni/sni-handler.ts` - - [ ] Extract SNI extraction to `src/tls/sni/sni-extraction.ts` - - [ ] Extract ClientHello parsing to `src/tls/sni/client-hello-parser.ts` + - [ ] Move `ts/smartproxy/classes.pp.snihandler.ts` → `ts/tls/sni/sni-handler.ts` + - [ ] Extract SNI extraction to `ts/tls/sni/sni-extraction.ts` + - [ ] Extract ClientHello parsing to `ts/tls/sni/client-hello-parser.ts` ### Phase 5: HTTP Component Migration (Week 3) - [ ] Migrate Port80Handler - - [ ] Move `ts/port80handler/classes.port80handler.ts` → `src/http/port80/port80-handler.ts` - - [ ] Extract ACME challenge handling to `src/http/port80/challenge-responder.ts` + - [ ] Move `ts/port80handler/classes.port80handler.ts` → `ts/http/port80/port80-handler.ts` + - [ ] Extract ACME challenge handling to `ts/http/port80/challenge-responder.ts` - [ ] Migrate redirect handlers - - [ ] Move `ts/redirect/classes.redirect.ts` → `src/http/redirects/redirect-handler.ts` - - [ ] Create `src/http/redirects/ssl-redirect.ts` for specialized redirects + - [ ] Move `ts/redirect/classes.redirect.ts` → `ts/http/redirects/redirect-handler.ts` + - [ ] Create `ts/http/redirects/ssl-redirect.ts` for specialized redirects - [ ] Migrate router components - - [ ] Move `ts/classes.router.ts` → `src/http/router/proxy-router.ts` - - [ ] Extract route matching to `src/http/router/route-matcher.ts` + - [ ] Move `ts/classes.router.ts` → `ts/http/router/proxy-router.ts` + - [ ] Extract route matching to `ts/http/router/route-matcher.ts` ### Phase 6: Proxy Implementation Migration (Weeks 3-4) - [ ] Migrate SmartProxy components - - [ ] First, migrate interfaces to `src/proxies/smart-proxy/models/` - - [ ] Move core class: `ts/smartproxy/classes.smartproxy.ts` → `src/proxies/smart-proxy/smart-proxy.ts` + - [ ] First, migrate interfaces to `ts/proxies/smart-proxy/models/` + - [ ] Move core class: `ts/smartproxy/classes.smartproxy.ts` → `ts/proxies/smart-proxy/smart-proxy.ts` - [ ] Move supporting classes using consistent naming - [ ] Normalize interface names (SmartProxyOptions instead of IPortProxySettings) - [ ] Migrate NetworkProxy components - - [ ] First, migrate interfaces to `src/proxies/network-proxy/models/` - - [ ] Move core class: `ts/networkproxy/classes.np.networkproxy.ts` → `src/proxies/network-proxy/network-proxy.ts` + - [ ] First, migrate interfaces to `ts/proxies/network-proxy/models/` + - [ ] Move core class: `ts/networkproxy/classes.np.networkproxy.ts` → `ts/proxies/network-proxy/network-proxy.ts` - [ ] Move supporting classes using consistent naming - [ ] Migrate NfTablesProxy - - [ ] Move `ts/nfttablesproxy/classes.nftablesproxy.ts` → `src/proxies/nftables-proxy/nftables-proxy.ts` + - [ ] Move `ts/nfttablesproxy/classes.nftablesproxy.ts` → `ts/proxies/nftables-proxy/nftables-proxy.ts` ### Phase 7: Integration & Main Module (Week 4-5) - [ ] Create main entry points - - [ ] Create `src/index.ts` with all public exports + - [ ] Update `ts/index.ts` with all public exports - [ ] Ensure backward compatibility with type aliases - [ ] Implement proper namespace exports @@ -234,54 +234,54 @@ This component has the cleanest design, so we'll start migration here: | Current File | New File | Status | |--------------|----------|--------| | **Core/Common Files** | | | -| ts/common/types.ts | src/core/models/common-types.ts | ❌ | -| ts/common/eventUtils.ts | src/core/utils/event-utils.ts | ❌ | -| ts/common/acmeFactory.ts | src/certificate/acme/acme-factory.ts | ❌ | -| ts/plugins.ts | src/core/utils/plugins.ts | ❌ | -| ts/00_commitinfo_data.ts | src/core/utils/commit-info.ts | ❌ | +| ts/common/types.ts | ts/core/models/common-types.ts | ❌ | +| ts/common/eventUtils.ts | ts/core/utils/event-utils.ts | ❌ | +| ts/common/acmeFactory.ts | ts/certificate/acme/acme-factory.ts | ❌ | +| ts/plugins.ts | ts/core/utils/plugins.ts | ❌ | +| ts/00_commitinfo_data.ts | ts/core/utils/commit-info.ts | ❌ | | **Certificate Management** | | | -| ts/helpers.certificates.ts | src/certificate/utils/certificate-helpers.ts | ❌ | -| ts/classes.pp.certprovisioner.ts | src/certificate/providers/cert-provisioner.ts | ❌ | +| ts/helpers.certificates.ts | ts/certificate/utils/certificate-helpers.ts | ❌ | +| ts/classes.pp.certprovisioner.ts | ts/certificate/providers/cert-provisioner.ts | ❌ | | **TLS and SNI Handling** | | | -| ts/smartproxy/classes.pp.tlsalert.ts | src/tls/alerts/tls-alert.ts | ❌ | -| ts/smartproxy/classes.pp.snihandler.ts | src/tls/sni/sni-handler.ts | ❌ | +| ts/smartproxy/classes.pp.tlsalert.ts | ts/tls/alerts/tls-alert.ts | ❌ | +| ts/smartproxy/classes.pp.snihandler.ts | ts/tls/sni/sni-handler.ts | ❌ | | **HTTP Components** | | | -| ts/port80handler/classes.port80handler.ts | src/http/port80/port80-handler.ts | ❌ | -| ts/redirect/classes.redirect.ts | src/http/redirects/redirect-handler.ts | ❌ | -| ts/classes.router.ts | src/http/router/proxy-router.ts | ❌ | +| ts/port80handler/classes.port80handler.ts | ts/http/port80/port80-handler.ts | ❌ | +| ts/redirect/classes.redirect.ts | ts/http/redirects/redirect-handler.ts | ❌ | +| ts/classes.router.ts | ts/http/router/proxy-router.ts | ❌ | | **SmartProxy Components** | | | -| ts/smartproxy/classes.smartproxy.ts | src/proxies/smart-proxy/smart-proxy.ts | ❌ | -| ts/smartproxy/classes.pp.interfaces.ts | src/proxies/smart-proxy/models/interfaces.ts | ❌ | -| ts/smartproxy/classes.pp.connectionhandler.ts | src/proxies/smart-proxy/connection-handler.ts | ❌ | -| ts/smartproxy/classes.pp.connectionmanager.ts | src/proxies/smart-proxy/connection-manager.ts | ❌ | -| ts/smartproxy/classes.pp.domainconfigmanager.ts | src/proxies/smart-proxy/domain-config-manager.ts | ❌ | -| ts/smartproxy/classes.pp.portrangemanager.ts | src/proxies/smart-proxy/port-range-manager.ts | ❌ | -| ts/smartproxy/classes.pp.securitymanager.ts | src/proxies/smart-proxy/security-manager.ts | ❌ | -| ts/smartproxy/classes.pp.timeoutmanager.ts | src/proxies/smart-proxy/timeout-manager.ts | ❌ | -| ts/smartproxy/classes.pp.networkproxybridge.ts | src/proxies/smart-proxy/network-proxy-bridge.ts | ❌ | +| ts/smartproxy/classes.smartproxy.ts | ts/proxies/smart-proxy/smart-proxy.ts | ❌ | +| ts/smartproxy/classes.pp.interfaces.ts | ts/proxies/smart-proxy/models/interfaces.ts | ❌ | +| ts/smartproxy/classes.pp.connectionhandler.ts | ts/proxies/smart-proxy/connection-handler.ts | ❌ | +| ts/smartproxy/classes.pp.connectionmanager.ts | ts/proxies/smart-proxy/connection-manager.ts | ❌ | +| ts/smartproxy/classes.pp.domainconfigmanager.ts | ts/proxies/smart-proxy/domain-config-manager.ts | ❌ | +| ts/smartproxy/classes.pp.portrangemanager.ts | ts/proxies/smart-proxy/port-range-manager.ts | ❌ | +| ts/smartproxy/classes.pp.securitymanager.ts | ts/proxies/smart-proxy/security-manager.ts | ❌ | +| ts/smartproxy/classes.pp.timeoutmanager.ts | ts/proxies/smart-proxy/timeout-manager.ts | ❌ | +| ts/smartproxy/classes.pp.networkproxybridge.ts | ts/proxies/smart-proxy/network-proxy-bridge.ts | ❌ | | **NetworkProxy Components** | | | -| ts/networkproxy/classes.np.networkproxy.ts | src/proxies/network-proxy/network-proxy.ts | ❌ | -| ts/networkproxy/classes.np.certificatemanager.ts | src/proxies/network-proxy/certificate-manager.ts | ❌ | -| ts/networkproxy/classes.np.connectionpool.ts | src/proxies/network-proxy/connection-pool.ts | ❌ | -| ts/networkproxy/classes.np.requesthandler.ts | src/proxies/network-proxy/request-handler.ts | ❌ | -| ts/networkproxy/classes.np.websockethandler.ts | src/proxies/network-proxy/websocket-handler.ts | ❌ | -| ts/networkproxy/classes.np.types.ts | src/proxies/network-proxy/models/types.ts | ❌ | +| ts/networkproxy/classes.np.networkproxy.ts | ts/proxies/network-proxy/network-proxy.ts | ❌ | +| ts/networkproxy/classes.np.certificatemanager.ts | ts/proxies/network-proxy/certificate-manager.ts | ❌ | +| ts/networkproxy/classes.np.connectionpool.ts | ts/proxies/network-proxy/connection-pool.ts | ❌ | +| ts/networkproxy/classes.np.requesthandler.ts | ts/proxies/network-proxy/request-handler.ts | ❌ | +| ts/networkproxy/classes.np.websockethandler.ts | ts/proxies/network-proxy/websocket-handler.ts | ❌ | +| ts/networkproxy/classes.np.types.ts | ts/proxies/network-proxy/models/types.ts | ❌ | | **NFTablesProxy Components** | | | -| ts/nfttablesproxy/classes.nftablesproxy.ts | src/proxies/nftables-proxy/nftables-proxy.ts | ❌ | +| ts/nfttablesproxy/classes.nftablesproxy.ts | ts/proxies/nftables-proxy/nftables-proxy.ts | ❌ | | **Forwarding System** | | | -| ts/smartproxy/types/forwarding.types.ts | src/forwarding/config/forwarding-types.ts | ❌ | -| ts/smartproxy/forwarding/domain-config.ts | src/forwarding/config/domain-config.ts | ❌ | -| ts/smartproxy/forwarding/domain-manager.ts | src/forwarding/config/domain-manager.ts | ❌ | -| ts/smartproxy/forwarding/forwarding.handler.ts | src/forwarding/handlers/base-handler.ts | ❌ | -| ts/smartproxy/forwarding/http.handler.ts | src/forwarding/handlers/http-handler.ts | ❌ | -| ts/smartproxy/forwarding/https-passthrough.handler.ts | src/forwarding/handlers/https-passthrough-handler.ts | ❌ | -| ts/smartproxy/forwarding/https-terminate-to-http.handler.ts | src/forwarding/handlers/https-terminate-to-http-handler.ts | ❌ | -| ts/smartproxy/forwarding/https-terminate-to-https.handler.ts | src/forwarding/handlers/https-terminate-to-https-handler.ts | ❌ | -| ts/smartproxy/forwarding/forwarding.factory.ts | src/forwarding/factory/forwarding-factory.ts | ❌ | -| ts/smartproxy/forwarding/index.ts | src/forwarding/index.ts | ❌ | +| ts/smartproxy/types/forwarding.types.ts | ts/forwarding/config/forwarding-types.ts | ❌ | +| ts/smartproxy/forwarding/domain-config.ts | ts/forwarding/config/domain-config.ts | ❌ | +| ts/smartproxy/forwarding/domain-manager.ts | ts/forwarding/config/domain-manager.ts | ❌ | +| ts/smartproxy/forwarding/forwarding.handler.ts | ts/forwarding/handlers/base-handler.ts | ❌ | +| ts/smartproxy/forwarding/http.handler.ts | ts/forwarding/handlers/http-handler.ts | ❌ | +| ts/smartproxy/forwarding/https-passthrough.handler.ts | ts/forwarding/handlers/https-passthrough-handler.ts | ❌ | +| ts/smartproxy/forwarding/https-terminate-to-http.handler.ts | ts/forwarding/handlers/https-terminate-to-http-handler.ts | ❌ | +| ts/smartproxy/forwarding/https-terminate-to-https.handler.ts | ts/forwarding/handlers/https-terminate-to-https-handler.ts | ❌ | +| ts/smartproxy/forwarding/forwarding.factory.ts | ts/forwarding/factory/forwarding-factory.ts | ❌ | +| ts/smartproxy/forwarding/index.ts | ts/forwarding/index.ts | ❌ | | **Examples and Entry Points** | | | -| ts/examples/forwarding-example.ts | src/examples/forwarding-example.ts | ❌ | -| ts/index.ts | src/index.ts | ❌ | +| ts/examples/forwarding-example.ts | ts/examples/forwarding-example.ts | ❌ | +| ts/index.ts | ts/index.ts (updated) | ❌ | ## Import Strategy @@ -290,17 +290,17 @@ Since path aliases will not be used, we'll maintain standard relative imports th 1. **Import Strategy for Deeply Nested Files** ```typescript // Example: Importing from another component in a nested directory - // From src/forwarding/handlers/http-handler.ts to src/core/utils/validation-utils.ts + // From ts/forwarding/handlers/http-handler.ts to ts/core/utils/validation-utils.ts import { validateConfig } from '../../../core/utils/validation-utils.js'; ``` 2. **Barrel Files for Convenience** ```typescript - // src/forwarding/index.ts + // ts/forwarding/index.ts export * from './config/forwarding-types.js'; export * from './handlers/base-handler.js'; // ... other exports - + // Then in consuming code: import { ForwardingHandler, httpOnly } from '../../forwarding/index.js'; ``` @@ -308,7 +308,7 @@ Since path aliases will not be used, we'll maintain standard relative imports th 3. **Flattened Imports Where Sensible** ```typescript // Avoid excessive nesting with targeted exports - // src/index.ts will export key components for external use + // ts/index.ts will export key components for external use import { SmartProxy, NetworkProxy } from '../index.js'; ```