Pinggy SDK - v0.2.4
    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

    Constructors

    Methods

    • Retrieves Allow-Preflight configuration for this tunnel instance.

      Returns Promise<null | boolean>

      The Allow-Preflight sconfig

    • Gets the current argument string for the tunnel configuration.

      Delegates to Config#getArgument.

      Returns Promise<null | string>

      The argument string, or null if unavailable.

    • Returns auto-reconnect configuration for this tunnel instance.

      Returns Promise<null | boolean>

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

    • Retrieves the basic authentication values from the instance configuration.

      Returns Promise<null | string[]>

      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<null | PinggyOptions>

      The tunnel configuration, or null if unavailable.

    • Gets the current force configuration setting for the tunnel.

      Delegates to Config#getForce.

      Returns Promise<null | boolean>

      The force setting, or null if unavailable.

    • Returns header modification values defined in the configuration.

      Returns Promise<null | string[]>

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

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

      Returns Promise<null | boolean>

      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<null | string>

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

    • Returns MaxReconnectAttempts configuration for this tunnel instance.

      Returns Promise<null | number>

      The MaxReconnectAttempts setting, or null if not configured.

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

      Returns Promise<null | boolean>

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

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

      Returns Promise<null | boolean>

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

    • Returns reconnect interval configuration for this tunnel instance.

      Returns Promise<null | number>

      The reconnect interval setting, or null if not configured.

    • Gets the current server address for the tunnel.

      Delegates to Config#getServerAddress.

      Returns Promise<null | string>

      The server address, or null if unavailable.

    • Gets the current SNI server name for the tunnel.

      Delegates to Config#getSniServerName.

      Returns Promise<null | string>

      The SNI server name, or null if unavailable.

    • Gets the TCP forward-to address for the tunnel.

      Delegates to Config#getTcpForwardTo.

      Returns Promise<null | string>

      The TCP forward-to address, or null if unavailable.

    • Gets the current authentication token for the tunnel.

      Delegates to Config#getToken.

      Returns Promise<null | string>

      The authentication token, or null if unavailable.

    • Gets the current SSL setting for the tunnel.

      Delegates to Config#getTunnelSsl.

      Returns Promise<null | boolean>

      The SSL setting, or null if unavailable.

    • Gets the current tunnel type for the tunnel.

      Delegates to Config#getTunnelType.

      Returns Promise<null | string>

      The tunnel type, or null if unavailable.

    • Gets the UDP forward-to address for the tunnel.

      Delegates to Config#getUdpForwardTo.

      Returns Promise<null | string>

      The UDP forward-to address, or null if unavailable.

    • Gets the current UDP type for the tunnel.

      Delegates to Config#getUdpType.

      Returns Promise<null | string>

      The UDP type, or null if unavailable.

    • 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<null | string>

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

      If the tunnel or its tunnelRef is not initialized.

    • Returns WebDebuggerPort configuration for this tunnel instance.

      Returns Promise<number>

      The WebDebuggerPort setting, or null if not configured.

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

      Returns Promise<null | boolean>

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

    • Sets a callback function to receive AdditionalForwarding events.

      Delegates to Tunnel#setAdditionalForwardingCallback.

      Parameters

      • callback: (
            bindAddress: string,
            forwardToAddr: string,
            errorMessage: null | string,
        ) => void

        The callback function to receive AdditionalForwarding events.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive Authenticated events.

      Delegates to Tunnel#setAuthenticatedCallback.

      Parameters

      • callback: (message: string) => void

        The callback function to receive Authenticated events.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive PrimaryForwarding events.

      Delegates to Tunnel#setPrimaryForwardingCallback.

      Parameters

      • callback: (message: string, address: string[]) => void

        The callback function to receive PrimaryForwarding events.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive disconnected events.

      Delegates to Tunnel#setTunnelDisconnectedCallback.

      Parameters

      • callback: (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: (errorNo: number, error: string, recoverable: boolean) => void

        The callback function to receive errors.

      Returns void

      If the tunnel is not initialized.

    • Sets a callback function to receive usage updates.

      Delegates to Tunnel#setUsageUpdateCallback.

      Parameters

      • callback: (usage: Record<string, any>) => void

        The callback function to receive usage updates.

      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

    • 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.

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

      Delegates to Tunnel#startWebDebugging.

      Parameters

      • port: number

        The local port to start web debugging on.

      Returns void

      If the tunnel 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: null | Config = null
    tunnel: null | Tunnel = null