27 Commits

Author SHA1 Message Date
300ab1a077 Fix connection leak in route-connection-handler by using safe socket creation
The previous fix only addressed ForwardingHandler classes but missed the critical setupDirectConnection() method in route-connection-handler.ts where SmartProxy actually handles connections. This caused active connections to rise indefinitely on ECONNREFUSED errors.

Changes:
- Import createSocketWithErrorHandler in route-connection-handler.ts
- Replace net.connect() with createSocketWithErrorHandler() in setupDirectConnection()
- Properly clean up connection records when server connection fails
- Add connectionFailed flag to prevent setup of failed connections

This ensures connection records are cleaned up immediately when backend connections fail, preventing memory leaks.
2025-06-01 13:42:46 +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
bed1a76537 refactor(socket-utils): replace direct socket cleanup with centralized cleanupSocket utility across connection management 2025-06-01 08:02:32 +00:00
eb2e67fecc feat(socket-utils): implement socket cleanup utilities and enhance socket handling in forwarding handlers 2025-06-01 07:51:20 +00:00
e6b3ae395c update 2025-05-29 14:06:47 +00:00
af13d3af10 update 2025-05-29 13:24:27 +00:00
ab1ea95070 update 2025-05-29 12:15:53 +00:00
d8d1bdcd41 update 2025-05-29 01:00:20 +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
c9abdea556 fix(logger): Replace raw console logging calls with structured logger usage across certificate management, connection handling, and route processing for improved observability. 2025-05-19 23:37:11 +00:00
91018173b0 fix(certificate-manager, smart-proxy): Fix race condition in ACME certificate provisioning and refactor certificate manager initialization to defer provisioning until after port listeners are active 2025-05-19 22:07:08 +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
3bf4e97e71 fix(smartproxy): Improve error handling in forwarding connection handler and refine domain matching logic 2025-05-19 18:29:56 +00:00
33732c2361 fix(smartproxy): Correct NFTables forwarding handling to avoid premature connection termination and add comprehensive tests 2025-05-19 17:56:48 +00:00
465148d553 fix(strcuture): refactor responsibilities 2025-05-19 17:28:05 +00:00
6d3e72c948 fix(SmartCertManager): Preserve certificate manager update callback during route updates 2025-05-19 13:23:16 +00:00
02e77655ad update 2025-05-19 12:04:26 +00:00
01b4a79e1a fix(certificates): simplify approach 2025-05-18 15:38:07 +00:00
a2e3e38025 feat(nftables):add nftables support for nftables 2025-05-15 14:35:01 +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
340823296a fix(smartproxy): Update dynamic port mapping to support 2025-05-14 18:35:06 +00:00
fcc8cf9caa fix(routing): unify route based architecture 2025-05-13 12:48:41 +00:00
b4a0e4be6b feat(smartproxy): Update documentation and route helper functions; add createPortRange, createSecurityConfig, createStaticFileRoute, and createTestRoute helpers to the readme and tests. Refactor test examples to use the new helper API and remove legacy connection handling files (including the old connection handler and PortRangeManager) to fully embrace the unified route‐based configuration. 2025-05-10 07:34:35 +00:00
529857220d fix 2025-05-10 00:49:39 +00:00
8dd222443d fix: Make SmartProxy work with pure route-based configuration 2025-05-10 00:28:35 +00:00
28022ebe87 change to route based approach 2025-05-10 00:01:02 +00:00