import { Handlers } from '../helper/handlers' import { Handler, HandlerResolve } from '../helper/handler' import { AuthMethod } from '../helper/authMethod' import { ObfsBuilder } from '../obfs/obfs' /** * The Client class is responsible for creating a TCP socket connection, * and communicate with a standard SOCKS server */ export declare class Client { /** * SOCKS server host */ private readonly host /** * SOCKS server port */ private readonly port /** * The object which contains all default handlers */ private readonly handlers /** * The main event object */ private readonly event /** * Server protocol version */ private readonly version /** * userId for identification in v4 */ private readonly userId? private readonly tls? obfs: ObfsBuilder constructor( port: number, host: string, version: 4 | 5, obfs: ObfsBuilder, userId?: string, tls?: boolean ) /** * The connector method establishes a TCP connection to the proxy server * @param port - Proxy server port * @param host - Proxy server host * @param cmd - Request command * @param resolve - This function fires after the server response * @param reject - This function fires after the server response if any error occurs * @param version - SOCKS version * @param userId - UserId for identification in SOCKS4 */ private connector /** * Sends a bind request * @param port - Target port * @param host - Target host address * @param version - Server protocol version * @returns void */ bind( port: number, host: string, version?: 4 | 5, userId?: string ): Promise /** * Sends an associate request * @param port - Target port * @param host - Target host address * @param version - Server protocol version * @returns void */ associate( port: number, host: string, version?: 4 | 5 ): Promise /** * Sends a connect request * @param port - Target port * @param host - Target host address * @param version - Server protocol version * @param userId - userId for identification in v4 * @returns void */ connect( port: number, host: string, version?: 4 | 5, userId?: string ): Promise /** * Get the handler function, and push it into this.handlers.req * @param handler - Emitted when the socks5 client sends an authentication request * @returns Client */ useAuth(handler: AuthMethod): Client /** * Get the handler function, and update this.handlers.req * @param cmd - Specify handler type (connect | associate | bind) * @param handler - Emitted when new request appears * @returns Server */ useReq(cmd: keyof Handlers['req'], handler: Handler): Client /** * Get the handler function, and update this.handlers.obfs * @param handler - Emitted when new request appears * @returns Server */ useObfs(handler: ObfsBuilder): Client } /** * Open new connection and connect to server * @param port - Server port * @param host - Server address * @param version - Server protocol version * @param obfs - Obfuscation Method * @param userId - userId for identification in v4 * @returns void */ export declare const connect: ( port: number, host: string, version: 4 | 5, userId?: string, tls?: boolean ) => Client