update structure

This commit is contained in:
2025-05-09 17:00:27 +00:00
parent 4a72d9f3bf
commit f1c0b8bfb7
60 changed files with 4919 additions and 1400 deletions

View File

@ -68,70 +68,73 @@ The codebase employs several strong design patterns:
### Phase 1: Project Setup & Core Structure (Week 1)
- [ ] Create new directory structure
- [ ] Create core subdirectories within `ts` directory
- [ ] Set up barrel files (`index.ts`) in each directory
- [x] Create new directory structure
- [x] Create core subdirectories within `ts` directory
- [x] Set up barrel files (`index.ts`) in each directory
- [ ] Migrate core utilities
- [ ] Keep `ts/plugins.ts` in its current location per project requirements
- [ ] 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`
- [x] Migrate core utilities
- [x] Keep `ts/plugins.ts` in its current location per project requirements
- [x] Move `ts/common/types.ts``ts/core/models/common-types.ts`
- [x] Move `ts/common/eventUtils.ts``ts/core/utils/event-utils.ts`
- [x] Extract `ValidationUtils``ts/core/utils/validation-utils.ts`
- [x] Extract `IpUtils``ts/core/utils/ip-utils.ts`
- [ ] Update build and test scripts
- [ ] Modify `package.json` build script for new structure
- [ ] Create parallel test structure
- [x] Update build and test scripts
- [x] Modify `package.json` build script for new structure
- [x] Create parallel test structure
### Phase 2: Forwarding System Migration (Weeks 1-2)
### Phase 2: Forwarding System Migration (Weeks 1-2)
This component has the cleanest design, so we'll start migration here:
- [ ] Migrate forwarding types and interfaces
- [ ] Move `ts/smartproxy/types/forwarding.types.ts``ts/forwarding/config/forwarding-types.ts`
- [ ] Normalize interface names (remove 'I' prefix where appropriate)
- [x] Migrate forwarding types and interfaces
- [x] Move `ts/smartproxy/types/forwarding.types.ts``ts/forwarding/config/forwarding-types.ts`
- [x] Normalize interface names (remove 'I' prefix where appropriate)
- [ ] Migrate domain configuration
- [ ] 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`
- [x] Migrate domain configuration
- [x] Move `ts/smartproxy/forwarding/domain-config.ts``ts/forwarding/config/domain-config.ts`
- [x] Move `ts/smartproxy/forwarding/domain-manager.ts``ts/forwarding/config/domain-manager.ts`
- [ ] Migrate handler implementations
- [ ] 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`
- [x] Move base handler: `forwarding.handler.ts``ts/forwarding/handlers/base-handler.ts`
- [x] Move HTTP handler: `http.handler.ts``ts/forwarding/handlers/http-handler.ts`
- [x] Move passthrough handler: `https-passthrough.handler.ts``ts/forwarding/handlers/https-passthrough-handler.ts`
- [x] Move TLS termination handlers to respective files in `ts/forwarding/handlers/`
- [x] Move `https-terminate-to-http.handler.ts``ts/forwarding/handlers/https-terminate-to-http-handler.ts`
- [x] Move `https-terminate-to-https.handler.ts``ts/forwarding/handlers/https-terminate-to-https-handler.ts`
- [x] 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 `ts/forwarding/index.ts`
- [ ] Test forwarding system in isolation
- [x] Create proper forwarding system exports
- [x] Update all imports in forwarding components using relative paths
- [x] Create comprehensive barrel file in `ts/forwarding/index.ts`
- [x] Test forwarding system in isolation
### Phase 3: Certificate Management Migration (Week 2)
### Phase 3: Certificate Management Migration (Week 2)
- [ ] Create certificate management structure
- [ ] Create `ts/certificate/models/certificate-types.ts` for interfaces
- [ ] Extract certificate events to `ts/certificate/events/`
- [x] Create certificate management structure
- [x] Create `ts/certificate/models/certificate-types.ts` for interfaces
- [x] Extract certificate events to `ts/certificate/events/certificate-events.ts`
- [ ] Migrate certificate providers
- [ ] 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`
- [x] Migrate certificate providers
- [x] Move `ts/smartproxy/classes.pp.certprovisioner.ts``ts/certificate/providers/cert-provisioner.ts`
- [x] Move `ts/common/acmeFactory.ts``ts/certificate/acme/acme-factory.ts`
- [x] Extract ACME challenge handling to `ts/certificate/acme/challenge-handler.ts`
- [ ] Update certificate utilities
- [ ] Move `ts/helpers.certificates.ts``ts/certificate/utils/certificate-helpers.ts`
- [ ] Create proper exports in `ts/certificate/index.ts`
- [x] Update certificate utilities
- [x] Move `ts/helpers.certificates.ts``ts/certificate/utils/certificate-helpers.ts`
- [x] Create certificate storage in `ts/certificate/storage/file-storage.ts`
- [x] Create proper exports in `ts/certificate/index.ts`
### Phase 4: TLS & SNI Handling Migration (Week 2-3)
### Phase 4: TLS & SNI Handling Migration (Week 2-3)
- [ ] Migrate TLS alert system
- [ ] Move `ts/smartproxy/classes.pp.tlsalert.ts``ts/tls/alerts/tls-alert.ts`
- [ ] Extract common TLS utilities to `ts/tls/utils/tls-utils.ts`
- [x] Migrate TLS alert system
- [x] Move `ts/smartproxy/classes.pp.tlsalert.ts``ts/tls/alerts/tls-alert.ts`
- [x] Extract common TLS utilities to `ts/tls/utils/tls-utils.ts`
- [ ] Migrate SNI handling
- [ ] 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`
- [x] Migrate SNI handling
- [x] Move `ts/smartproxy/classes.pp.snihandler.ts``ts/tls/sni/sni-handler.ts`
- [x] Extract SNI extraction to `ts/tls/sni/sni-extraction.ts`
- [x] Extract ClientHello parsing to `ts/tls/sni/client-hello-parser.ts`
### Phase 5: HTTP Component Migration (Week 3)
@ -234,17 +237,27 @@ This component has the cleanest design, so we'll start migration here:
| Current File | New File | Status |
|--------------|----------|--------|
| **Core/Common Files** | | |
| ts/common/types.ts | ts/core/models/common-types.ts | |
| ts/common/eventUtils.ts | ts/core/utils/event-utils.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/plugins.ts (stays in original location) | |
| ts/00_commitinfo_data.ts | ts/00_commitinfo_data.ts (stays in original location) | |
| ts/plugins.ts | ts/plugins.ts (stays in original location) | |
| ts/00_commitinfo_data.ts | ts/00_commitinfo_data.ts (stays in original location) | |
| (new) | ts/core/utils/validation-utils.ts | ✅ |
| (new) | ts/core/utils/ip-utils.ts | ✅ |
| **Certificate Management** | | |
| ts/helpers.certificates.ts | ts/certificate/utils/certificate-helpers.ts | |
| ts/classes.pp.certprovisioner.ts | ts/certificate/providers/cert-provisioner.ts | |
| ts/helpers.certificates.ts | ts/certificate/utils/certificate-helpers.ts | |
| ts/smartproxy/classes.pp.certprovisioner.ts | ts/certificate/providers/cert-provisioner.ts | |
| ts/common/acmeFactory.ts | ts/certificate/acme/acme-factory.ts | ✅ |
| (new) | ts/certificate/acme/challenge-handler.ts | ✅ |
| (new) | ts/certificate/models/certificate-types.ts | ✅ |
| (new) | ts/certificate/events/certificate-events.ts | ✅ |
| (new) | ts/certificate/storage/file-storage.ts | ✅ |
| **TLS and SNI Handling** | | |
| ts/smartproxy/classes.pp.tlsalert.ts | ts/tls/alerts/tls-alert.ts | |
| ts/smartproxy/classes.pp.snihandler.ts | ts/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 | |
| (new) | ts/tls/utils/tls-utils.ts | ✅ |
| (new) | ts/tls/sni/sni-extraction.ts | ✅ |
| (new) | ts/tls/sni/client-hello-parser.ts | ✅ |
| **HTTP Components** | | |
| ts/port80handler/classes.port80handler.ts | ts/http/port80/port80-handler.ts | ❌ |
| ts/redirect/classes.redirect.ts | ts/http/redirects/redirect-handler.ts | ❌ |
@ -269,19 +282,19 @@ This component has the cleanest design, so we'll start migration here:
| **NFTablesProxy Components** | | |
| ts/nfttablesproxy/classes.nftablesproxy.ts | ts/proxies/nftables-proxy/nftables-proxy.ts | ❌ |
| **Forwarding System** | | |
| 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 | |
| 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 | ts/examples/forwarding-example.ts | ❌ |
| ts/index.ts | ts/index.ts (updated) | |
| ts/index.ts | ts/index.ts (updated) | |
## Import Strategy