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.

This commit is contained in:
2025-05-29 00:24:57 +00:00
parent d42fa8b1e9
commit e4aade4a9a
11 changed files with 1338 additions and 6 deletions

View File

@ -6,7 +6,12 @@ import type { PortRange } from '../../../proxies/nftables-proxy/models/interface
/**
* Supported action types for route configurations
*/
export type TRouteActionType = 'forward' | 'redirect' | 'block' | 'static';
export type TRouteActionType = 'forward' | 'redirect' | 'block' | 'static' | 'socket-handler';
/**
* Socket handler function type
*/
export type TSocketHandler = (socket: plugins.net.Socket) => void | Promise<void>;
/**
* TLS handling modes for route configurations
@ -297,6 +302,9 @@ export interface IRouteAction {
// Handler function for static routes
handler?: (context: IRouteContext) => Promise<IStaticResponse>;
// Socket handler function (when type is 'socket-handler')
socketHandler?: TSocketHandler;
}
/**