import * as net from "node:net"; import * as tls from "node:tls"; import { type PooledConnection } from "./connection-pool"; /** * Parses a standard SOCKS5 connection string. * Example: socks5://user:pass@127.0.0.1:1080 */ export declare function parseProxyUrl(proxyUrl: string): { host: string; port: number; user: string; password: string; protocol: string; }; /** * Establishes a raw TCP connection to the SOCKS5 proxy and performs the handshake. */ export declare function connectSocks5(proxyConfig: string, targetHost: string, targetPort: number, useTLS?: boolean, resolveDnsLocally?: boolean, signal?: AbortSignal, tlsOptions?: tls.ConnectionOptions): Promise; export declare function decodeChunked(buffer: Uint8Array): Uint8Array; /** * Handle HTTP redirects according to RFC 7231 * * Connection reuse: If existingConnection is provided and redirect is to same host/port/protocol, * the connection will be reused to avoid SOCKS5 handshake overhead. * * Security features: * - Sensitive headers (authorization, cookie, proxy-authorization) are removed on cross-origin redirects * - Referer header is automatically added * - Proxy settings are preserved to ensure all requests go through the same proxy */ export declare function handleRedirects(input: string | URL | Request, init: BunFetchRequestInit & { proxy?: { resolveDnsLocally?: boolean; }; }, maxRedirects?: number, currentRedirects?: number, existingConnection?: PooledConnection): Promise; /** * Custom Fetch implementation that supports SOCKS5 via the 'proxy' init option. */ export declare function fetch(input: string | URL | Request, // url init?: BunFetchRequestInit & { proxy?: string | { url: string; resolveDnsLocally?: boolean; }; }): Promise; export declare namespace fetch { var preconnect: (_url: string | URL) => void; } /** * Internal fetch implementation without redirect handling */ export declare function fetchInternal(input: string | URL | Request, // url init?: BunFetchRequestInit & { proxy?: { resolveDnsLocally?: boolean; }; }, // bun fetch opts existingConnection?: PooledConnection): Promise;