394 Commits

Author SHA1 Message Date
01e1153fb8 feat(proxy): Start implementing PROXY protocol support and WrappedSocket class for enhanced client IP handling 2025-06-01 21:30:37 +00:00
c5efee3bfe fix(smartproxy): Fix connection handling and improve route matching edge cases 2025-06-01 15:45:03 +00:00
47508eb1eb Refactor socket handling in forwarding handlers to use centralized utilities and remove deprecated functions 2025-06-01 15:35:45 +00:00
07f5ceddc4 Implement proxy chain connection accumulation fix and add comprehensive tests
- Updated socket handling to prevent connection accumulation in chained proxies.
- Introduced centralized bidirectional forwarding for consistent socket management.
- Enhanced cleanup logic to ensure immediate closure of sockets when one closes.
- Added tests to verify connection behavior under various scenarios, including backend failures and rapid reconnections.
2025-06-01 15:10:36 +00:00
5b40e82c41 Add tests for connect-disconnect and error handling in SmartProxy 2025-06-01 14:41:19 +00:00
250eafd36c Enhance connection cleanup and error handling in RouteConnectionHandler
- Implement immediate cleanup for connection failures to prevent leaks
- Add NFTables cleanup on socket close to manage memory usage
- Fix connection limit bypass by checking record after creation
- Introduce tests for rapid connection retries and routing failures
2025-06-01 14:22:06 +00:00
2d240671ab Improve error handling and logging for outgoing connections in RouteConnectionHandler 2025-06-01 13:58:20 +00:00
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
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
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
726d40b9a5 feat(lifecycle-component): enhance lifecycle management with unref support for timers and event listeners
fix(lifecycle-component): store actual event handler for proper cleanup
chore(meta): update certificate dates in meta.json
2025-06-01 08:09:29 +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
e0f3e8a0ec fix(lifecycle-component): support 'once' option for event listeners 2025-05-31 22:18:34 +00:00
96c4de0f8a fix(connection-manager): set default maxConnections to 10000 if not specified 2025-05-31 18:12:19 +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
32583f784f fix(smartproxy): Fix route security configuration location and improve ACME timing tests and socket mock implementations 2025-05-29 14:34:00 +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
b0beeae19e update 2025-05-29 11:30:42 +00:00
fdb45cbb91 fix(test): Fix ACME challenge route creation and HTTP request parsing in tests 2025-05-29 10:23:19 +00:00
6a08bbc558 update 2025-05-29 10:13:41 +00:00
200a735876 update 2025-05-29 01:07:39 +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
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
d448a9f20f fix(dependencies): Update dependency versions: upgrade @types/node to ^22.15.20 and @push.rocks/smartlog to ^3.1.7 in package.json 2025-05-20 19:36:12 +00:00
a9ac57617e fix(smartproxy): Bump @push.rocks/smartlog to ^3.1.3 and improve ACME port binding behavior in SmartProxy 2025-05-20 19:20:24 +00:00
6512551f02 update 2025-05-20 16:01:32 +00:00
4f3359b348 update 2025-05-20 15:44:48 +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
018a49dbc2 fix(tests): Update test mocks to include provisionAllCertificates methods in certificate manager stubs and related objects. 2025-05-19 23:57:16 +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
e61766959f update 2025-05-19 22:47:13 +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
da061292ae fix(certificate-manager): Preserve certificate manager update callback in updateRoutes 2025-05-19 19:17:48 +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
1b4d215cd4 fix(tests): test 2025-05-19 17:59:12 +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
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
a31c68b03f fix(core): No changes detected – project structure and documentation remain unchanged. 2025-05-19 17:28:54 +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
4134d2842c fix(certificates): Update static-route certificate metadata for ACME challenges 2025-05-19 12:17:21 +00:00
02e77655ad update 2025-05-19 12:04:26 +00:00
ec81678651 feat(smartproxy): Update dependencies and enhance ACME certificate provisioning with wildcard support 2025-05-19 10:11:29 +00:00