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.

89 lines (88 loc) 2.67 kB
import * as plugins from '../../plugins.js'; import type { IRouteConfig, TPortRange, IRouteContext } from '../../proxies/smart-proxy/models/route-types.js'; /** * Result of route matching */ export interface IRouteMatchResult { route: IRouteConfig; params?: Record<string, string>; } /** * Logger interface for RouteManager */ export interface ILogger { info: (message: string, ...args: any[]) => void; warn: (message: string, ...args: any[]) => void; error: (message: string, ...args: any[]) => void; debug?: (message: string, ...args: any[]) => void; } /** * Shared RouteManager used by both SmartProxy and NetworkProxy * * This provides a unified implementation for route management, * route matching, and port handling. */ export declare class SharedRouteManager extends plugins.EventEmitter { private routes; private portMap; private logger; private enableDetailedLogging; /** * Memoization cache for expanded port ranges */ private portRangeCache; constructor(options: { logger?: ILogger; enableDetailedLogging?: boolean; routes?: IRouteConfig[]; }); /** * Update routes with new configuration */ updateRoutes(routes?: IRouteConfig[]): void; /** * Get all routes */ getRoutes(): IRouteConfig[]; /** * Rebuild the port mapping for fast lookups * Also logs information about the ports being listened on */ private rebuildPortMap; /** * Expand a port range specification into an array of individual ports * Uses caching to improve performance for frequently used port ranges * * @public - Made public to allow external code to interpret port ranges */ expandPortRange(portRange: TPortRange): number[]; /** * Get all ports that should be listened on * This method automatically infers all required ports from route configurations */ getListeningPorts(): number[]; /** * Get all routes for a given port */ getRoutesForPort(port: number): IRouteConfig[]; /** * Find the matching route for a connection */ findMatchingRoute(context: IRouteContext): IRouteMatchResult | null; /** * Check if a route matches the given context */ private matchesRoute; /** * Validate the route configuration and return any warnings */ validateConfiguration(): string[]; /** * Check if two route matches are similar (potential conflict) */ private areMatchesSimilar; /** * Check if a route is completely shadowed by a higher priority route */ private isRouteShadowed; }