Class JavaNgrokConfig


  • public class JavaNgrokConfig
    extends java.lang.Object
    An object for managing java-ngrok's configuration to interact the ngrok binary.

    Basic Usage

     final Function<NgrokLog, Void> logEventCallback = ngrokLog -> {
         System.out.println(ngrokLog.getLine());
         return null;
     };
     final JavaNgrokConfig javaNgrokConfig = new JavaNgrokConfig.Builder()
             .withAuthToken("<NGROK_AUTHTOKEN>")
             .withRegion(Region.AU)
             .withLogEventCallback(logEventCallback)
             .withMaxLogs(10);
    
     final NgrokClient ngrokClient = new NgrokClient.Builder()
             .withJavaNgrokConfig(javaNgrokConfig)
             .build();
     

    ngrok Version Compatibility

    java-ngrok is compatible with ngrok v2 and v3, but by default it will install v3. To install v2 instead, set the version with JavaNgrokConfig.Builder.withNgrokVersion(NgrokVersion) and CreateTunnel.Builder.withNgrokVersion(NgrokVersion).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getApiKey()
      A ngrok API key.
      java.lang.String getAuthToken()
      Get the ngrok authtoken that will be passed to commands.
      java.nio.file.Path getConfigPath()
      Get the path to the ngrok config file.
      java.util.function.Function<NgrokLog,​java.lang.Void> getLogEventCallback()
      Get the log event callback that will be invoked each time ngrok emits a log.
      int getMaxLogs()
      Get the maximum number of ngrok logs to retain in the monitoring thread.
      java.nio.file.Path getNgrokPath()
      Get the path to the ngrok binary.
      NgrokVersion getNgrokVersion()
      Get the major ngrok version to be used.
      Region getRegion()
      Get the region in which ngrok will start.
      int getStartupTime()
      Get the startup time before ngrok times out on boot.
      boolean isKeepMonitoring()
      Get whether the ngrok process will continue to be monitored after it finishes starting up.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getNgrokPath

        public java.nio.file.Path getNgrokPath()
        Get the path to the ngrok binary.
      • getConfigPath

        public java.nio.file.Path getConfigPath()
        Get the path to the ngrok config file.
      • getAuthToken

        public java.lang.String getAuthToken()
        Get the ngrok authtoken that will be passed to commands.
      • getRegion

        public Region getRegion()
        Get the region in which ngrok will start.
      • isKeepMonitoring

        public boolean isKeepMonitoring()
        Get whether the ngrok process will continue to be monitored after it finishes starting up.
      • getMaxLogs

        public int getMaxLogs()
        Get the maximum number of ngrok logs to retain in the monitoring thread.
      • getLogEventCallback

        public java.util.function.Function<NgrokLog,​java.lang.Void> getLogEventCallback()
        Get the log event callback that will be invoked each time ngrok emits a log.
      • getStartupTime

        public int getStartupTime()
        Get the startup time before ngrok times out on boot.
      • getNgrokVersion

        public NgrokVersion getNgrokVersion()
        Get the major ngrok version to be used.
      • getApiKey

        public java.lang.String getApiKey()
        A ngrok API key.