54 Commits

Author SHA1 Message Date
d45485985a Fix socket error handling to prevent server crashes on ECONNREFUSED
This commit addresses critical issues where unhandled socket connection errors (ECONNREFUSED) would crash the server and cause memory leaks with rising connection counts.

Changes:
- Add createSocketWithErrorHandler() utility that attaches error handlers immediately upon socket creation
- Update https-passthrough-handler to use safe socket creation and clean up client sockets on server connection failure
- Update https-terminate-to-http-handler to use safe socket creation
- Ensure proper connection cleanup when server connections fail
- Document the fix in readme.hints.md and create implementation plan in readme.plan.md

The fix prevents race conditions where sockets could emit errors before handlers were attached, and ensures failed connections are properly cleaned up to prevent memory leaks.
2025-06-01 13:30:06 +00:00
9fdc2d5069 Refactor socket handling plan to address server crashes, memory leaks, and race conditions 2025-06-01 13:01:24 +00:00
ad80798210 Enhance socket cleanup and management for improved connection handling
- Refactor cleanupSocket function to support options for immediate destruction, allowing drain, and grace periods.
- Introduce createIndependentSocketHandlers for better management of half-open connections between client and server sockets.
- Update various handlers (HTTP, HTTPS passthrough, HTTPS terminate) to utilize new cleanup and socket management functions.
- Implement custom timeout handling in socket setup to prevent immediate closure during keep-alive connections.
- Add tests for long-lived connections and half-open connection scenarios to ensure stability and reliability.
- Adjust connection manager to handle socket cleanup based on activity status, improving resource management.
2025-06-01 12:27:15 +00:00
829ae0d6a3 fix(refactor): remove deprecated Port80Handler and related utilities
- Deleted event-utils.ts which contained deprecated Port80Handler and its subscribers.
- Updated index.ts to remove the export of event-utils.
- Refactored ConnectionManager to extend LifecycleComponent for better resource management.
- Added BinaryHeap implementation for efficient priority queue operations.
- Introduced EnhancedConnectionPool for managing pooled connections with lifecycle management.
- Implemented LifecycleComponent to manage timers and event listeners automatically.
- Added comprehensive tests for BinaryHeap and LifecycleComponent to ensure functionality.
2025-05-31 18:01:09 +00:00
7b81186bb3 feat(performance): Add async utility functions and filesystem utilities
- Implemented async utilities including delay, retryWithBackoff, withTimeout, parallelLimit, debounceAsync, AsyncMutex, and CircuitBreaker.
- Created tests for async utilities to ensure functionality and reliability.
- Developed AsyncFileSystem class with methods for file and directory operations, including ensureDir, readFile, writeFile, remove, and more.
- Added tests for filesystem utilities to validate file operations and error handling.
2025-05-31 17:45:40 +00:00
02603c3b07 fix(performance): start with planning performance optimizations 2025-05-31 17:14:15 +00:00
e4aade4a9a fix(socket-handler): Fix socket handler race condition by differentiating between async and sync handlers. Now, async socket handlers complete their setup before initial data is emitted, ensuring that no data is lost. Documentation and tests have been updated to reflect this change. 2025-05-29 00:24:57 +00:00
f81baee1d2 feat(socket-handler): Add socket-handler support for custom socket handling in SmartProxy 2025-05-28 23:33:02 +00:00
742adc2bd9 fix(smartproxy): Improve port binding intelligence and ACME challenge route management; update route configuration tests and dependency versions. 2025-05-28 19:58:28 +00:00
6512551f02 update 2025-05-20 16:01:32 +00:00
669cc2809c fix(port-manager, certificate-manager): Improve port binding and ACME challenge route integration in SmartProxy 2025-05-20 15:32:19 +00:00
42fe1e5d15 fix(route-connection-handler): Forward non-TLS connections on HttpProxy ports to fix ACME HTTP-01 challenge handling 2025-05-19 19:59:22 +00:00
4b381915e1 fix(docs, tests, acme): fix: update changelog, documentation, examples and tests for v19.4.0 release. Adjust global ACME configuration to use ssl@bleu.de and add non-privileged port examples. 2025-05-19 17:39:35 +00:00
465148d553 fix(strcuture): refactor responsibilities 2025-05-19 17:28:05 +00:00
3fcdce611c fix(acme): Fix port 80 ACME management and challenge route concurrency issues by deduplicating port listeners, preserving challenge route state across certificate manager recreations, and adding mutex locks to route updates. 2025-05-19 03:40:58 +00:00
094edfafd1 fix(acme): Refactor ACME challenge route lifecycle to prevent port 80 EADDRINUSE errors 2025-05-19 01:59:52 +00:00
8fd861c9a3 fix(certificate-management): Fix loss of route update callback during dynamic route updates in certificate manager 2025-05-18 23:07:31 +00:00
ba1569ee21 new plan 2025-05-18 22:41:41 +00:00
68738137a0 feat(acme): Improve certificate management by adding global ACME configuration support and allowing route-level overrides. Enhanced error messages help identify missing ACME email and misconfigurations (e.g. wildcard domains). Documentation has been updated and new tests added to verify SmartCertManager behavior, ensuring a clearer migration path from legacy implementations. 2025-05-18 18:29:59 +00:00
455b08b36c BREAKING CHANGE(certificates): Remove legacy certificate modules and Port80Handler; update documentation and route configurations to use SmartCertManager for certificate management. 2025-05-18 16:30:23 +00:00
8dc6b5d849 add new plan 2025-05-18 15:12:36 +00:00
4e78dade64 new plan 2025-05-18 15:03:11 +00:00
a2e3e38025 feat(nftables):add nftables support for nftables 2025-05-15 14:35:01 +00:00
94e9eafa25 fix(smartproxy): Consolidate duplicate IRouteSecurity interfaces to use standardized property names (ipAllowList and ipBlockList), fix port preservation logic for preserve mode in forward actions, and update dependency versions in package.json. 2025-05-15 09:56:32 +00:00
35d7dfcedf BREAKING CHANGE(IRouteSecurity): Consolidate duplicated IRouteSecurity interfaces by unifying property names 2025-05-15 09:34:01 +00:00
ac3a888453 BREAKING CHANGE(smartproxy): Remove legacy migration utilities and deprecated forwarding helpers; consolidate route utilities, streamline interface definitions, and normalize IPv6-mapped IPv4 addresses 2025-05-15 08:56:27 +00:00
bb54ea8192 fix(network-proxy, route-utils, route-manager): Normalize IPv6-mapped IPv4 addresses in IP matching functions and remove deprecated legacy configuration methods in NetworkProxy. Update route-utils and route-manager to compare both canonical and IPv6-mapped IP forms, adjust tests accordingly, and clean up legacy exports. 2025-05-14 12:26:43 +00:00
fcc8cf9caa fix(routing): unify route based architecture 2025-05-13 12:48:41 +00:00
f85698c06a update 2025-05-10 15:09:58 +00:00
ffc8b22533 update 2025-05-10 13:59:34 +00:00
a2eb0741e9 BREAKING CHANGE(smartproxy/configuration): Migrate SmartProxy to a fully unified route‐based configuration by removing legacy domain-based settings and conversion code. CertProvisioner, NetworkProxyBridge, and RouteManager now use IRouteConfig exclusively, and related legacy interfaces and files have been removed. 2025-05-10 07:56:21 +00:00
28022ebe87 change to route based approach 2025-05-10 00:01:02 +00:00
552f4c246b new plan 2025-05-09 23:13:48 +00:00
6b910587ab feat(docs): Update README to reflect new modular architecture and expanded core utilities: add Project Architecture Overview, update export paths and API references, and mark plan tasks as completed 2025-05-09 22:11:56 +00:00
88c75d9cc2 BREAKING CHANGE(project-structure): Refactor project structure by updating import paths, removing legacy files, and adjusting test configurations 2025-05-09 21:52:46 +00:00
b214e58a26 update 2025-05-09 21:21:28 +00:00
4ac1df059f feat(acme): Add ACME interfaces for Port80Handler and refactor ChallengeResponder to use new acme-interfaces, enhancing event subscription and certificate workflows. 2025-05-09 17:28:27 +00:00
5a3bf2cae6 feat(smartproxy): Migrate internal module paths and update HTTP/ACME components for SmartProxy 2025-05-09 17:10:19 +00:00
f1c0b8bfb7 update structure 2025-05-09 17:00:27 +00:00
88b4df18b8 update plan 2025-05-09 16:15:57 +00:00
fb2354146e update plan 2025-05-09 16:06:20 +00:00
ec88e9a5b2 new plan 2025-05-09 16:04:02 +00:00
bef68e59c9 create plan for easier configuration 2025-05-09 11:51:56 +00:00
0f356c9bbf feat(CertificateManager): Implement on-demand certificate retrieval for missing SNI certificates. When no certificate is found for a TLS ClientHello, the system now automatically registers the domain with the Port80Handler to trigger ACME issuance and immediately falls back to using the default certificate to complete the handshake. Additionally, HTTP requests on port 80 for unrecognized domains now return a 503 indicating that certificate issuance is in progress. 2025-05-05 17:03:22 +00:00
9c05f71cd6 feat(smartproxy): Implement fallback to NetworkProxy on missing SNI and rename certProvider to certProvisionFunction in CertProvisioner 2025-05-05 15:42:48 +00:00
05c9156458 fix(port80handler): refactor ACME challenge handling to use dedicated Http01MemoryHandler, remove obsolete readme.plan.md, and update version to 10.0.12 2025-05-05 15:16:26 +00:00
8291f1f33a fix(tlsalert): Centralize plugin imports in TlsAlert and update plan checklist 2025-05-03 19:02:26 +00:00
0e634c46a6 BREAKING CHANGE(smartproxy): Update documentation and refactor core proxy components; remove legacy performRenewals method from SmartProxy; update router type imports and adjust test suites for improved coverage 2025-05-03 13:19:23 +00:00
878e76ab23 BREAKING CHANGE(acme): Refactor ACME configuration and certificate provisioning by replacing legacy port80HandlerConfig with unified acme options and updating CertProvisioner event subscriptions 2025-05-02 14:58:33 +00:00
8a396a04fa BREAKING CHANGE(certProvisioner): Refactor: Introduce unified CertProvisioner to centralize certificate provisioning and renewal; remove legacy ACME config from Port80Handler and update SmartProxy to delegate certificate lifecycle management. 2025-05-02 11:19:14 +00:00