@push.rocks/smartproxy
Version:
A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.
74 lines (73 loc) • 1.66 kB
TypeScript
/**
* Shared Fragment Handler for Protocol Detection
*
* Provides unified fragment buffering and reassembly for protocols
* that may span multiple TCP packets.
*/
import { Buffer } from 'buffer';
/**
* Fragment tracking information
*/
export interface IFragmentInfo {
buffer: Buffer;
timestamp: number;
connectionId: string;
}
/**
* Options for fragment handling
*/
export interface IFragmentOptions {
maxBufferSize?: number;
timeout?: number;
cleanupInterval?: number;
}
/**
* Result of fragment processing
*/
export interface IFragmentResult {
isComplete: boolean;
buffer?: Buffer;
needsMoreData: boolean;
error?: string;
}
/**
* Shared fragment handler for protocol detection
*/
export declare class FragmentHandler {
private options;
private fragments;
private cleanupTimer?;
constructor(options?: IFragmentOptions);
/**
* Add a fragment for a connection
*/
addFragment(connectionId: string, fragment: Buffer): IFragmentResult;
/**
* Get the current buffer for a connection
*/
getBuffer(connectionId: string): Buffer | undefined;
/**
* Mark a connection as complete and clean up
*/
complete(connectionId: string): void;
/**
* Check if we're tracking a connection
*/
hasConnection(connectionId: string): boolean;
/**
* Clean up expired fragments
*/
cleanup(): void;
/**
* Clear all fragments
*/
clear(): void;
/**
* Destroy the handler and clean up resources
*/
destroy(): void;
/**
* Get the number of tracked connections
*/
get size(): number;
}