@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.
130 lines (129 loc) • 4.09 kB
TypeScript
import type { IRouteConfig, IRouteMatch, IRouteAction } from '../models/route-types.js';
/**
* Validates route configurations for correctness and safety
*/
export declare class RouteValidator {
private static readonly VALID_TLS_MODES;
private static readonly VALID_ACTION_TYPES;
private static readonly VALID_PROTOCOLS;
private static readonly MAX_PORTS;
private static readonly MAX_DOMAINS;
private static readonly MAX_HEADER_SIZE;
/**
* Validate a single route configuration
*/
static validateRoute(route: IRouteConfig): {
valid: boolean;
errors: string[];
};
/**
* Validate multiple route configurations
*/
static validateRoutes(routes: IRouteConfig[]): {
valid: boolean;
errors: Map<string, string[]>;
};
/**
* Find potential conflicts between routes
*/
private static findRouteConflicts;
private static expandPorts;
private static transportsForMatch;
private static inboundProxyPolicyFingerprint;
private static isCatchAllDomainMatch;
private static hasSourceScope;
/**
* Validate port number
*/
private static isValidPort;
/**
* Validate domain pattern
*/
private static isValidDomain;
/**
* Validate path pattern
*/
private static isValidPath;
/**
* Validate IP pattern
*/
private static isValidIPPattern;
/**
* Validate IPv4 address
*/
private static isValidIPv4;
/**
* Validate IPv6 address
*/
private static isValidIPv6;
/**
* Log validation errors
*/
static logValidationErrors(errors: Map<string, string[]>): void;
}
/**
* Validates a port range or port number
* @param port Port number, port range, or port function
* @returns True if valid, false otherwise
*/
export declare function isValidPort(port: any): boolean;
/**
* Validates a domain string - supports wildcards, localhost, and IP addresses
* @param domain Domain string to validate
* @returns True if valid, false otherwise
*/
export declare function isValidDomain(domain: string): boolean;
/**
* Validates a route match configuration
* @param match Route match configuration to validate
* @returns { valid: boolean, errors: string[] } Validation result
*/
export declare function validateRouteMatch(match: IRouteMatch): {
valid: boolean;
errors: string[];
};
/**
* Validates a route action configuration
* @param action Route action configuration to validate
* @returns { valid: boolean, errors: string[] } Validation result
*/
export declare function validateRouteAction(action: IRouteAction): {
valid: boolean;
errors: string[];
};
/**
* Validates a complete route configuration
* @param route Route configuration to validate
* @returns { valid: boolean, errors: string[] } Validation result
*/
export declare function validateRouteConfig(route: IRouteConfig): {
valid: boolean;
errors: string[];
};
/**
* Validate an array of route configurations
* @param routes Array of route configurations to validate
* @returns { valid: boolean, errors: { index: number, errors: string[] }[] } Validation result
*/
export declare function validateRoutes(routes: IRouteConfig[]): {
valid: boolean;
errors: {
index: number;
errors: string[];
}[];
};
/**
* Check if a route configuration has the required properties for a specific action type
* @param route Route configuration to check
* @param actionType Expected action type
* @returns True if the route has the necessary properties, false otherwise
*/
export declare function hasRequiredPropertiesForAction(route: IRouteConfig, actionType: string): boolean;
/**
* Throws an error if the route config is invalid, returns the config if valid
* Useful for immediate validation when creating routes
* @param route Route configuration to validate
* @returns The validated route configuration
* @throws Error if the route configuration is invalid
*/
export declare function assertValidRoute(route: IRouteConfig): IRouteConfig;