@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.
97 lines (96 loc) • 2.41 kB
TypeScript
export interface RedirectRule {
/**
* Optional protocol to match (http or https). If not specified, matches both.
*/
fromProtocol?: 'http' | 'https';
/**
* Optional hostname pattern to match. Can use * as wildcard.
* If not specified, matches all hosts.
*/
fromHost?: string;
/**
* Optional path prefix to match. If not specified, matches all paths.
*/
fromPath?: string;
/**
* Target protocol for the redirect (http or https)
*/
toProtocol: 'http' | 'https';
/**
* Target hostname for the redirect. Can use $1, $2, etc. to reference
* captured groups from wildcard matches in fromHost.
*/
toHost: string;
/**
* Optional target path prefix. If not specified, keeps original path.
* Can use $path to reference the original path.
*/
toPath?: string;
/**
* HTTP status code for the redirect (301 for permanent, 302 for temporary)
*/
statusCode?: 301 | 302 | 307 | 308;
}
export declare class Redirect {
private httpServer?;
private httpsServer?;
private rules;
private httpPort;
private httpsPort;
private sslOptions?;
/**
* Create a new Redirect instance
* @param options Configuration options
*/
constructor(options?: {
httpPort?: number;
httpsPort?: number;
sslOptions?: {
key: Buffer;
cert: Buffer;
};
rules?: RedirectRule[];
});
/**
* Add a redirect rule
*/
addRule(rule: RedirectRule): void;
/**
* Remove all redirect rules
*/
clearRules(): void;
/**
* Set SSL options for HTTPS redirects
*/
setSslOptions(options: {
key: Buffer;
cert: Buffer;
}): void;
/**
* Process a request according to the configured rules
*/
private handleRequest;
/**
* Find a matching redirect rule for the given request
*/
private findMatchingRule;
/**
* Build the target URL for a redirect
*/
private buildTargetUrl;
/**
* Start the redirect server(s)
*/
start(): Promise<void>;
/**
* Stop the redirect server(s)
*/
stop(): Promise<void>;
}
export declare class SslRedirect {
private redirect;
port: number;
constructor(portArg: number);
start(): Promise<void>;
stop(): Promise<void>;
}