public class NgrokInstaller
extends java.lang.Object
ngrok for the current system.
ngrok will look for its config file in
the default location.
We can override this behavior with
JavaNgrokConfig.Builder.withConfigPath(Path).
java-ngrok package manages its own ngrok binary. We can use our ngrok
binary if we want by setting it with
JavaNgrokConfig.Builder.withNgrokPath(Path) and passing that config to
NgrokClient.| Modifier and Type | Field and Description |
|---|---|
static java.nio.file.Path |
DEFAULT_CONFIG_PATH |
static java.nio.file.Path |
DEFAULT_NGROK_PATH |
static java.lang.String |
FREEBSD |
static java.lang.String |
LINUX |
static java.lang.String |
MAC |
static java.util.List<java.lang.String> |
UNIX_BINARIES |
static java.lang.String |
WINDOWS |
| Constructor and Description |
|---|
NgrokInstaller()
Construct with the
DefaultHttpClient. |
NgrokInstaller(HttpClient httpClient)
Construct with a custom
HttpClient. |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.Object> |
getDefaultConfig(NgrokVersion ngrokVersion,
ConfigVersion configVersion)
Get the default config params for the given major version of
ngrok. |
static java.lang.String |
getNgrokBin()
Get the
ngrok executable for the current system. |
NgrokCDNUrl |
getNgrokCDNUrl()
|
NgrokCDNUrl |
getNgrokCDNUrl(NgrokVersion ngrokVersion)
Determine the
ngrok CDN URL for the current OS and architecture. |
java.util.Map<java.lang.String,java.lang.Object> |
getNgrokConfig(java.nio.file.Path configPath)
|
java.util.Map<java.lang.String,java.lang.Object> |
getNgrokConfig(java.nio.file.Path configPath,
boolean useCache)
|
java.util.Map<java.lang.String,java.lang.Object> |
getNgrokConfig(java.nio.file.Path configPath,
boolean useCache,
NgrokVersion ngrokVersion,
ConfigVersion configVersion)
Get the
ngrok config from the given path. |
static java.lang.String |
getSystem()
Parse the name of the OS from system properties and return a friendly name.
|
void |
installDefaultConfig(java.nio.file.Path configPath,
java.util.Map<java.lang.String,java.lang.Object> data)
|
void |
installDefaultConfig(java.nio.file.Path configPath,
java.util.Map<java.lang.String,java.lang.Object> data,
NgrokVersion ngrokVersion)
|
void |
installDefaultConfig(java.nio.file.Path configPath,
java.util.Map<java.lang.String,java.lang.Object> data,
NgrokVersion ngrokVersion,
ConfigVersion configVersion)
Install the default
ngrok config. |
void |
installNgrok(java.nio.file.Path ngrokPath)
|
void |
installNgrok(java.nio.file.Path ngrokPath,
NgrokVersion ngrokVersion)
Download and install the latest
ngrok for the current system, overwriting any existing contents at
the given path. |
void |
validateConfig(java.util.Map<java.lang.String,java.lang.Object> data)
Validate that the given map of config items are valid for
ngrok and java-ngrok. |
void |
validateConfig(java.nio.file.Path configPath)
Validate that the config file at the given path is valid for
ngrok and java-ngrok. |
public static final java.lang.String MAC
public static final java.lang.String WINDOWS
public static final java.lang.String LINUX
public static final java.lang.String FREEBSD
public static final java.util.List<java.lang.String> UNIX_BINARIES
public static final java.nio.file.Path DEFAULT_NGROK_PATH
public static final java.nio.file.Path DEFAULT_CONFIG_PATH
public NgrokInstaller()
DefaultHttpClient.public NgrokInstaller(HttpClient httpClient)
HttpClient.httpClient - The HTTP client.public static java.lang.String getNgrokBin()
ngrok executable for the current system.ngrok executable.public static java.lang.String getSystem()
JavaNgrokInstallerException - The OS is not supported.public void installDefaultConfig(java.nio.file.Path configPath,
java.util.Map<java.lang.String,java.lang.Object> data)
public void installDefaultConfig(java.nio.file.Path configPath,
java.util.Map<java.lang.String,java.lang.Object> data,
NgrokVersion ngrokVersion)
public void installDefaultConfig(java.nio.file.Path configPath,
java.util.Map<java.lang.String,java.lang.Object> data,
NgrokVersion ngrokVersion,
ConfigVersion configVersion)
ngrok config. If a config is not already present for the given path, create
one.configPath - The path to where the ngrok config should be installed.data - A map of things to add to the default config.ngrokVersion - The major version of ngrok installed.configVersion - The ngrok config version.JavaNgrokInstallerException - An error occurred downloading ngrok.public void installNgrok(java.nio.file.Path ngrokPath)
public void installNgrok(java.nio.file.Path ngrokPath,
NgrokVersion ngrokVersion)
ngrok for the current system, overwriting any existing contents at
the given path.ngrokPath - The path to where the ngrok binary will be downloaded.ngrokVersion - The major ngrok version to install.JavaNgrokInstallerException - An error occurred installing ngrok.JavaNgrokSecurityException - An error occurred unzipping the download.public NgrokCDNUrl getNgrokCDNUrl()
public NgrokCDNUrl getNgrokCDNUrl(NgrokVersion ngrokVersion)
ngrok CDN URL for the current OS and architecture.ngrokVersion - The major version of ngrok to install.ngrok CDN URL.public void validateConfig(java.nio.file.Path configPath)
ngrok and java-ngrok.configPath - The config path to validate.public void validateConfig(java.util.Map<java.lang.String,java.lang.Object> data)
ngrok and java-ngrok.data - A map of things to be validated as config items.JavaNgrokException - A key or value failed validation.public java.util.Map<java.lang.String,java.lang.Object> getNgrokConfig(java.nio.file.Path configPath,
boolean useCache,
NgrokVersion ngrokVersion,
ConfigVersion configVersion)
ngrok config from the given path.configPath - The ngrok config path to read.useCache - Use the cached version of the config (if populated).ngrokVersion - The major version of ngrok installed.configVersion - The ngrok config version.ngrok config.JavaNgrokInstallerException - The config could not be parsed.public java.util.Map<java.lang.String,java.lang.Object> getNgrokConfig(java.nio.file.Path configPath,
boolean useCache)
public java.util.Map<java.lang.String,java.lang.Object> getNgrokConfig(java.nio.file.Path configPath)
public java.util.Map<java.lang.String,java.lang.Object> getDefaultConfig(NgrokVersion ngrokVersion, ConfigVersion configVersion)
ngrok.ngrokVersion - The major version of ngrok installed.configVersion - The ngrok config version.