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.

51 lines (50 loc) 1.5 kB
import * as plugins from '../../plugins.js'; import '../../core/models/socket-augmentation.js'; import { type IHttpProxyOptions } from './models/types.js'; import { ConnectionPool } from './connection-pool.js'; import type { IRouteConfig } from '../smart-proxy/models/route-types.js'; /** * Handles WebSocket connections and proxying */ export declare class WebSocketHandler { private options; private connectionPool; private routes; private heartbeatInterval; private wsServer; private logger; private contextCreator; private router; private securityManager; constructor(options: IHttpProxyOptions, connectionPool: ConnectionPool, routes?: IRouteConfig[]); /** * Set the route configurations */ setRoutes(routes: IRouteConfig[]): void; /** * Select the appropriate target from the targets array based on sub-matching criteria */ private selectTarget; /** * Initialize WebSocket server on an existing HTTPS server */ initialize(server: plugins.https.Server): void; /** * Start the heartbeat interval to check for inactive WebSocket connections */ private startHeartbeat; /** * Handle a new WebSocket connection */ private handleWebSocketConnection; /** * Get information about active WebSocket connections */ getConnectionInfo(): { activeConnections: number; }; /** * Shutdown the WebSocket handler */ shutdown(): void; }