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:
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user