UNPKG

@push.rocks/smartproxy

Version:

A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.

48 lines (47 loc) 1.37 kB
import * as plugins from '../plugins.js'; import { type INetworkProxyOptions } from './classes.np.types.js'; /** * Manages a pool of backend connections for efficient reuse */ export declare class ConnectionPool { private options; private connectionPool; private roundRobinPositions; private logger; constructor(options: INetworkProxyOptions); /** * Get a connection from the pool or create a new one */ getConnection(host: string, port: number): Promise<plugins.net.Socket>; /** * Return a connection to the pool for reuse */ returnConnection(socket: plugins.net.Socket, host: string, port: number): void; /** * Cleanup the connection pool by removing idle connections * or reducing pool size if it exceeds the configured maximum */ cleanupConnectionPool(): void; /** * Close all connections in the pool */ closeAllConnections(): void; /** * Get load balancing target using round-robin */ getNextTarget(targets: string[], port: number): { host: string; port: number; }; /** * Gets the connection pool status */ getPoolStatus(): Record<string, { total: number; idle: number; }>; /** * Setup a periodic cleanup task */ setupPeriodicCleanup(interval?: number): NodeJS.Timeout; }