@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.
63 lines (62 loc) • 2.46 kB
TypeScript
import * as plugins from '../../plugins.js';
import type { IForwardConfig, IForwardingHandler } from '../config/forwarding-types.js';
/**
* Base class for all forwarding handlers
*/
export declare abstract class ForwardingHandler extends plugins.EventEmitter implements IForwardingHandler {
protected config: IForwardConfig;
/**
* Create a new ForwardingHandler
* @param config The forwarding configuration
*/
constructor(config: IForwardConfig);
/**
* Initialize the handler
* Base implementation does nothing, subclasses should override as needed
*/
initialize(): Promise<void>;
/**
* Handle a new socket connection
* @param socket The incoming socket connection
*/
abstract handleConnection(socket: plugins.net.Socket): void;
/**
* Handle an HTTP request
* @param req The HTTP request
* @param res The HTTP response
*/
abstract handleHttpRequest(req: plugins.http.IncomingMessage, res: plugins.http.ServerResponse): void;
/**
* Get a target from the configuration, supporting round-robin selection
* @param incomingPort Optional incoming port for 'preserve' mode
* @returns A resolved target object with host and port
*/
protected getTargetFromConfig(incomingPort?: number): {
host: string;
port: number;
};
/**
* Resolves a port value, handling 'preserve' and function ports
* @param port The port value to resolve
* @param incomingPort Optional incoming port to use for 'preserve' mode
*/
protected resolvePort(port: number | 'preserve' | ((ctx: any) => number), incomingPort?: number): number;
/**
* Redirect an HTTP request to HTTPS
* @param req The HTTP request
* @param res The HTTP response
*/
protected redirectToHttps(req: plugins.http.IncomingMessage, res: plugins.http.ServerResponse): void;
/**
* Apply custom headers from configuration
* @param headers The original headers
* @param variables Variables to replace in the headers
* @returns The headers with custom values applied
*/
protected applyCustomHeaders(headers: Record<string, string | string[] | undefined>, variables: Record<string, string>): Record<string, string | string[] | undefined>;
/**
* Get the timeout for this connection from configuration
* @returns Timeout in milliseconds
*/
protected getTimeout(): number;
}