@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.
113 lines (112 loc) • 3.25 kB
TypeScript
import * as plugins from '../../plugins.js';
import type { IRouteConfig, TPortRange } from './models/route-types.js';
import type { ISmartProxyOptions } from './models/interfaces.js';
/**
* Result of route matching
*/
export interface IRouteMatchResult {
route: IRouteConfig;
params?: Record<string, string>;
}
/**
* The RouteManager handles all routing decisions based on connections and attributes
*/
export declare class RouteManager extends plugins.EventEmitter {
private routes;
private portMap;
private options;
constructor(options: ISmartProxyOptions);
/**
* Update routes with new configuration
*/
updateRoutes(routes?: IRouteConfig[]): void;
/**
* 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[];
/**
* Memoization cache for expanded port ranges
*/
private portRangeCache;
/**
* 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[];
/**
* Get all routes
*/
getAllRoutes(): IRouteConfig[];
/**
* Test if a pattern matches a domain using glob matching
*/
private matchDomain;
/**
* Match a domain against all patterns in a route
*/
private matchRouteDomain;
/**
* Check if a client IP is allowed by a route's security settings
* @deprecated Security is now checked in route-connection-handler.ts after route matching
*/
private isClientIpAllowed;
/**
* Match an IP against a pattern
*/
private matchIpPattern;
/**
* Match an IP against a CIDR pattern
*/
private matchIpCidr;
/**
* Convert an IP address to a numeric value
*/
private ipToNumber;
/**
* Find the matching route for a connection
*/
findMatchingRoute(options: {
port: number;
domain?: string;
clientIp: string;
path?: string;
tlsVersion?: string;
skipDomainCheck?: boolean;
}): IRouteMatchResult | null;
/**
* Match a path against a pattern
*/
private matchPath;
/**
* Domain-based configuration methods have been removed
* as part of the migration to pure route-based configuration
*/
/**
* 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;
/**
* Check if route1 is more specific than route2
*/
private isRouteMoreSpecific;
}