Pinggy SDK - v0.2.13
    Preparing search index...

    Class TunnelInstance

    Represents a high-level tunnel instance, managing both configuration and tunnel lifecycle. Provides methods to start, stop, and interact with a Pinggy tunnel.

    Internally uses Config for configuration and Tunnel for tunnel management.

    Index

    Callbacks

    • Sets a callback function to receive AdditionalForwarding events.

      Delegates to Tunnel#setAdditionalForwardingCallback.

      Parameters

      • callback: (
            payload: {
                bindAddress: string;
                errorMessage: string | null;
                forwardToAddr: string;
            },
        ) => void

        The callback function to receive AdditionalForwarding events.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive disconnected events.

      Delegates to Tunnel#setTunnelDisconnectedCallback.

      Parameters

      • callback: (payload: { error: string; messages: string[] }) => void

        The callback function to receive disconnected events.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive errors.

      Delegates to Tunnel#setTunnelErrorCallback.

      Parameters

      • callback: (payload: { error: string; errorNo: number; recoverable: boolean }) => void

        The callback function to receive errors.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive Tunnel established events.

      Delegates to Tunnel#setTunnelEstablishedCallback.

      Parameters

      • callback: (payload: { message: string; urls?: string[] }) => void

        The callback function to receive Tunnel established events.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive Forwarding changed events.

      Delegates to Tunnel#setOnTunnelForwardingChanged.

      Parameters

      • callback: (payload: { address?: string[]; message: string }) => void

        The callback function to receive Forwarding change events.

      Returns void

      If the tunnel is not initialized.

    • Registers a callback function to receive errors from the tunnel worker. It is recommended to always set this callback to ensure your program exits gracefully, since if the tunnel worker exits, the tunnel is no longer active.

      Parameters

      • callback: Function

        The callback function to receive errors.

      Returns void

    Configuration

    • Retrieves Allow-Preflight configuration for this tunnel instance.

      Returns Promise<boolean | null>

      The Allow-Preflight sconfig

    • Gets the current argument string for the tunnel configuration.

      Delegates to Config#getArgument.

      Returns Promise<string | null>

      The argument string, or null if unavailable.

    • Returns auto-reconnect configuration for this tunnel instance.

      Returns Promise<boolean | null>

      The auto-reconnect setting, or null if not configured.

    • Retrieves the basic authentication values from the instance configuration.

      Returns Promise<string[] | null>

      An array of basic auth credentials when configured, or null if none are set.

    • Returns bearer token authentication values defined in the configuration.

      Returns Promise<string[]>

      An array of bearer token strings if present; otherwise an empty array.

    • Returns the current tunnel configuration as a PinggyOptions object. Extracts values from the instance and parses argument strings for advanced options.

      Returns Promise<PinggyOptions | null>

      The tunnel configuration, or null if unavailable.

    • Gets the current force configuration setting for the tunnel.

      Delegates to Config#getForce.

      Returns Promise<boolean | null>

      The force setting, or null if unavailable.

    • Gets the forwarding rules configuration. Returns a JSON string containing all forwarding rules configured for this tunnel. Delegates to Config#getForwarding.

      Returns Promise<string | null>

      The tunnel type, or null if unavailable.

    • Returns header modification values defined in the configuration.

      Returns Promise<string[] | null>

      An array of header modification objects if present; otherwise null.

    • Returns whether HTTPS-only mode is enabled for the tunnel instance.

      Returns Promise<boolean | null>

      true if HTTPS-only mode is enabled, false if disabled, or null if the configuration is unavailable.

    • Retrieves IP whitelist for this tunnel instance.

      Returns Promise<string[]>

      An array of whitelisted IP addresses, or an empty array if no whitelist is configured.

    • Returns local server TLS configuration for this tunnel instance.

      Returns Promise<string | null>

      The local server TLS setting, or null if not configured.

    • Returns MaxReconnectAttempts configuration for this tunnel instance.

      Returns Promise<number | null>

      The MaxReconnectAttempts setting, or null if not configured.

    • Retrieves No-Reverse-Proxy configuration for this tunnel instance.

      Returns Promise<boolean | null>

      The No-Reverse-Proxy setting, or null if not configured.

    • Retrieves Original-Request-URL configuration for this tunnel instance.

      Returns Promise<boolean | null>

      The Original-Request-URL setting, or null if not configured.

    • Returns reconnect interval configuration for this tunnel instance.

      Returns Promise<number | null>

      The reconnect interval setting, or null if not configured.

    • Gets the current server address for the tunnel.

      Delegates to Config#getServerAddress.

      Returns Promise<string | null>

      The server address, or null if unavailable.

    • Gets the current SNI server name for the tunnel.

      Delegates to Config#getSniServerName.

      Returns Promise<string | null>

      The SNI server name, or null if unavailable.

    • Gets the current authentication token for the tunnel.

      Delegates to Config#getToken.

      Returns Promise<string | null>

      The authentication token, or null if unavailable.

    • Gets the current SSL setting for the tunnel.

      Delegates to Config#getTunnelSsl.

      Returns Promise<boolean | null>

      The SSL setting, or null if unavailable.

    • Retrieves X-Forwarded-For configuration for this tunnel instance.

      Returns Promise<boolean | null>

      The X-Forwarded-For setting, or null if not configured.

    Methods

    • Retrieves usage information from the underlying tunnel instance.

      This method delegates to the tunnel's getTunnelUsages() implementation. If the tunnel is not initialized or its reference is missing, an Error is thrown.

      Returns Promise<string | null>

      The tunnel usages as a string, or null if no usages are available.

      If the tunnel or its tunnelRef is not initialized.

    • Starts the tunnel and returns the public URLs.

      Delegates to Tunnel#start.

      Returns Promise<string[]>

      Resolves with the list of public tunnel URLs.

      If the tunnel is not initialized or fails to start.

    • Starts continuous usage updates for the tunnel.

      Returns void

      void

      If the tunnel instance or its tunnelRef is not initialized.

    • Stops continuous usage updates for the tunnel.

      Returns Promise<void>

      If the tunnel instance or its tunnelRef is not initialized.

    • Requests additional forwarding for the tunnel.

      Delegates to Tunnel#tunnelRequestAdditionalForwarding.

      Parameters

      • hostname: string

        The remote address to forward from.

      • target: string

        The local address to forward to.

      Returns Promise<void>

      If the tunnel is not initialized.

    • Gets the list of public URLs for the tunnel.

      Delegates to Tunnel#getUrls.

      Returns Promise<string[]>

      The list of public tunnel URLs.

    Properties

    config: Config | null = null
    tunnel: Tunnel | null = null

    Utilities

    • Enables or disables debug logging for the tunnel worker.

      Parameters

      • enable: boolean
      • logLevel: LogLevel = LogLevel.INFO
      • logFilePath: string | null

      Returns Promise<void>

    Web Debugging

    • Returns the WebDebugger address for this tunnel instance.

      Returns string

    • Returns the WebDebugger information for this tunnel instance.

      Returns Promise<string | null>

    • Returns WebDebuggerPort configuration for this tunnel instance.

      Returns Promise<number>

      The WebDebuggerPort setting, or null if not configured.

    • Starts web debugging for the tunnel on the specified local port.

      Delegates to Tunnel#startWebDebugging.

      Parameters

      • listenAddress: string

        The local port to start web debugging on.

      Returns void

      If the tunnel is not initialized.