A handier wrapper around a CONNECT request

interface IProxyConnectAPI {
    connection: Readonly<Connection>;
    connectionsStack: readonly Readonly<Connection>[];
    destinationHostname: string;
    destinationPort: number;
    hostname: string;
    mode: ProxyConnectMode;
    port: number;
    request: IncomingMessage | Http2ServerRequest;
    socket: Socket | ServerHttp2Stream;
    process(): void;
    setDestination(hostname: string, port: number): void;
    setMode(mode: ProxyConnectMode): void;
}

Properties

connection: Readonly<Connection>

The last connection in connectionsStack

connectionsStack: readonly Readonly<Connection>[]

The connections stack

destinationHostname: string

The destination hostname that will be used in forward mode. By default, it is equal to hostname. Can be changed with setDestination.

destinationPort: number

The destination port that will be used in forward mode. By default, it is equal to port. Can be changed with setDestination.

hostname: string

The target hostname in the CONNECT request

The currently selected mode, configured either by a call to setMode or by the global setting

port: number

The target port in the CONNECT request

request: IncomingMessage | Http2ServerRequest

The original Node.js object representing the request

socket: Socket | ServerHttp2Stream

The underlying socket

Methods

  • Processes the socket according to the mode stored in mode. This method is called automatically when the onProxyConnect function finishes, but it can also be called manually before.

    Returns void

  • Sets the destination hostname and port that will be used when the process method is called. Also changes the mode to forward.

    Parameters

    • hostname: string

      Destination hostname

    • port: number

      Destination port

    Returns void