UNPKG

@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.

113 lines (112 loc) 3.22 kB
/** * Represents a port range for forwarding */ export interface IPortRange { from: number; to: number; } /** * Settings for IPTablesProxy. */ export interface IIpTableProxySettings { fromPort: number | IPortRange | Array<number | IPortRange>; toPort: number | IPortRange | Array<number | IPortRange>; toHost?: string; preserveSourceIP?: boolean; deleteOnExit?: boolean; protocol?: 'tcp' | 'udp' | 'all'; enableLogging?: boolean; ipv6Support?: boolean; allowedSourceIPs?: string[]; bannedSourceIPs?: string[]; forceCleanSlate?: boolean; addJumpRule?: boolean; checkExistingRules?: boolean; netProxyIntegration?: { enabled: boolean; redirectLocalhost?: boolean; sslTerminationPort?: number; }; } /** * IPTablesProxy sets up iptables NAT rules to forward TCP traffic. * Enhanced with multi-port support, IPv6, and integration with PortProxy/NetworkProxy. */ export declare class IPTablesProxy { settings: IIpTableProxySettings; private rules; private ruleTag; private customChain; constructor(settings: IIpTableProxySettings); /** * Validates settings to prevent command injection and ensure valid values */ private validateSettings; /** * Normalizes port specifications into an array of port ranges */ private normalizePortSpec; /** * Gets the appropriate iptables command based on settings */ private getIptablesCommand; /** * Checks if a rule already exists in iptables */ private ruleExists; /** * Sets up a custom chain for better rule management */ private setupCustomChain; /** * Add a source IP filter rule */ private addSourceIPFilter; /** * Adds a port forwarding rule */ private addPortForwardingRule; /** * Special handling for NetworkProxy integration */ private setupNetworkProxyIntegration; /** * Rolls back rules that were added in case of error */ private rollbackRules; /** * Sets up iptables rules for port forwarding with enhanced features */ start(): Promise<void>; /** * Removes all added iptables rules */ stop(): Promise<void>; /** * Synchronous version of stop, for use in exit handlers */ stopSync(): void; /** * Asynchronously cleans up any iptables rules in the nat table that were added by this module. * It looks for rules with comments containing "IPTablesProxy:". */ static cleanSlate(): Promise<void>; /** * Internal implementation of cleanSlate with IPv6 support */ private static cleanSlateInternal; /** * Synchronously cleans up any iptables rules in the nat table that were added by this module. * It looks for rules with comments containing "IPTablesProxy:". * This method is intended for use in process exit handlers. */ static cleanSlateSync(): void; /** * Internal implementation of cleanSlateSync with IPv6 support */ private static cleanSlateSyncInternal; /** * Logging utility that respects the enableLogging setting */ private log; }