@rynn-k/proxy-agent
Version:
Efficient proxy rotation agent for Node.js with seamless axios integration
89 lines (74 loc) • 1.54 kB
TypeScript
import { HttpsProxyAgent } from 'https-proxy-agent';
import { HttpProxyAgent } from 'http-proxy-agent';
declare namespace ProxyAgent {
interface ProxyInfo {
index: number;
ip: string;
port: number;
hasAuth: boolean;
protocol: string;
}
interface ProxyStats {
total: number;
auth: number;
noAuth: number;
current: number;
random: boolean;
file: string;
autoReload: boolean;
}
interface TestResult {
success: boolean;
proxy: string;
time?: number;
data?: any;
error?: string;
}
interface AxiosConfig {
httpsAgent: HttpsProxyAgent;
httpAgent: HttpProxyAgent;
proxy: false;
}
interface Options {
random?: boolean;
log?: boolean;
encoding?: string;
autoReload?: boolean;
}
}
declare class ProxyAgent {
constructor(proxyFilePath?: string, options?: ProxyAgent.Options);
/**
* Get axios configuration with proxy agents
*/
config(): ProxyAgent.AxiosConfig;
/**
* Get HTTPS proxy agent
*/
https(): HttpsProxyAgent;
/**
* Get HTTP proxy agent
*/
http(): HttpProxyAgent;
/**
* Get all available proxies
*/
list(): ProxyAgent.ProxyInfo[];
/**
* Get proxy statistics
*/
stats(): ProxyAgent.ProxyStats;
/**
* Reload proxies from file
*/
reload(): void;
/**
* Test proxy connectivity
*/
test(testUrl?: string, timeout?: number): Promise<ProxyAgent.TestResult>;
/**
* Cleanup resources
*/
destroy(): void;
}
export = ProxyAgent;