@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.
48 lines (47 loc) • 1.43 kB
TypeScript
import type { IPortProxySettings } from './classes.pp.interfaces.js';
/**
* Handles security aspects like IP tracking, rate limiting, and authorization
*/
export declare class SecurityManager {
private settings;
private connectionsByIP;
private connectionRateByIP;
constructor(settings: IPortProxySettings);
/**
* Get connections count by IP
*/
getConnectionCountByIP(ip: string): number;
/**
* Check and update connection rate for an IP
* @returns true if within rate limit, false if exceeding limit
*/
checkConnectionRate(ip: string): boolean;
/**
* Track connection by IP
*/
trackConnectionByIP(ip: string, connectionId: string): void;
/**
* Remove connection tracking for an IP
*/
removeConnectionByIP(ip: string, connectionId: string): void;
/**
* Check if an IP is allowed using glob patterns
*/
isIPAuthorized(ip: string, allowedIPs: string[], blockedIPs?: string[]): boolean;
/**
* Check if the IP matches any of the glob patterns
*/
private isGlobIPMatch;
/**
* Check if IP should be allowed considering connection rate and max connections
* @returns Object with result and reason
*/
validateIP(ip: string): {
allowed: boolean;
reason?: string;
};
/**
* Clears all IP tracking data (for shutdown)
*/
clearIPTracking(): void;
}