index.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /// <reference types="node" />
  2. import { SocksProxy } from 'socks';
  3. import { Agent, ClientRequest, RequestOptions } from 'agent-base';
  4. import { AgentOptions } from 'agent-base';
  5. import { Url } from 'url';
  6. import net from 'net';
  7. import tls from 'tls';
  8. interface BaseSocksProxyAgentOptions {
  9. /**
  10. * hostname is preferred over host
  11. *
  12. * @deprecated
  13. */
  14. host?: string | null;
  15. port?: string | number | null;
  16. username?: string | null;
  17. tls?: tls.ConnectionOptions | null;
  18. }
  19. interface SocksProxyAgentOptionsExtra {
  20. timeout?: number;
  21. }
  22. export interface SocksProxyAgentOptions extends AgentOptions, BaseSocksProxyAgentOptions, Partial<Omit<Url & SocksProxy, keyof BaseSocksProxyAgentOptions>> {
  23. }
  24. export declare class SocksProxyAgent extends Agent {
  25. private readonly shouldLookup;
  26. private readonly proxy;
  27. private readonly tlsConnectionOptions;
  28. timeout: number | null;
  29. constructor(input: string | SocksProxyAgentOptions, options?: SocksProxyAgentOptionsExtra);
  30. /**
  31. * Initiates a SOCKS connection to the specified SOCKS proxy server,
  32. * which in turn connects to the specified remote host and port.
  33. *
  34. * @api protected
  35. */
  36. callback(req: ClientRequest, opts: RequestOptions): Promise<net.Socket>;
  37. }
  38. export {};