connector.d.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { TLSSocket, ConnectionOptions } from 'tls'
  2. import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from 'net'
  3. export default buildConnector
  4. declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
  5. declare namespace buildConnector {
  6. export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
  7. allowH2?: boolean;
  8. maxCachedSessions?: number | null;
  9. socketPath?: string | null;
  10. timeout?: number | null;
  11. port?: number;
  12. keepAlive?: boolean | null;
  13. keepAliveInitialDelay?: number | null;
  14. }
  15. export interface Options {
  16. hostname: string
  17. host?: string
  18. protocol: string
  19. port: string
  20. servername?: string
  21. localAddress?: string | null
  22. httpSocket?: Socket
  23. }
  24. export type Callback = (...args: CallbackArgs) => void
  25. type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
  26. export interface connector {
  27. (options: buildConnector.Options, callback: buildConnector.Callback): void
  28. }
  29. }