UNPKG

@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.

102 lines (87 loc) 2 kB
/** * Type definitions for protocol detection */ /** * Supported protocol types that can be detected */ export type TProtocolType = 'tls' | 'http' | 'unknown'; /** * HTTP method types */ export type THttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE'; /** * TLS version identifiers */ export type TTlsVersion = 'SSLv3' | 'TLSv1.0' | 'TLSv1.1' | 'TLSv1.2' | 'TLSv1.3'; /** * Connection information extracted from protocol detection */ export interface IConnectionInfo { /** * The detected protocol type */ protocol: TProtocolType; /** * Domain/hostname extracted from the connection * - For TLS: from SNI extension * - For HTTP: from Host header */ domain?: string; /** * HTTP-specific fields */ method?: THttpMethod; path?: string; httpVersion?: string; headers?: Record<string, string>; /** * TLS-specific fields */ tlsVersion?: TTlsVersion; sni?: string; alpn?: string[]; cipherSuites?: number[]; } /** * Result of protocol detection */ export interface IDetectionResult { /** * The detected protocol type */ protocol: TProtocolType; /** * Extracted connection information */ connectionInfo: IConnectionInfo; /** * Any remaining buffer data after detection headers * This can be used to continue processing the stream */ remainingBuffer?: Buffer; /** * Whether the detection is complete or needs more data */ isComplete: boolean; /** * Minimum bytes needed for complete detection (if incomplete) */ bytesNeeded?: number; } /** * Options for protocol detection */ export interface IDetectionOptions { /** * Maximum bytes to buffer for detection (default: 8192) */ maxBufferSize?: number; /** * Timeout for detection in milliseconds (default: 5000) */ timeout?: number; /** * Whether to extract full headers or just essential info */ extractFullHeaders?: boolean; }