- java.lang.Object
-
- com.github.alexdlaird.ngrok.process.NgrokProcess
-
public class NgrokProcess extends java.lang.Object
An object containing information about thengrok
process. Can be configured withJavaNgrokConfig
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NgrokProcess.ProcessMonitor
A Runnable that monitors thengrok
thread.
-
Constructor Summary
Constructors Constructor Description NgrokProcess(JavaNgrokConfig javaNgrokConfig, NgrokInstaller ngrokInstaller)
Ifngrok
is not already installed atJavaNgrokConfig.getNgrokPath()
, the givenNgrokInstaller
will install it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getApiUrl()
Get the API URL for thengrok
web interface.NgrokInstaller
getNgrokInstaller()
Get the class used to download and installngrok
.NgrokProcess.ProcessMonitor
getProcessMonitor()
Get the Runnable that is monitoring thengrok
thread.java.lang.String
getVersion()
Get thengrok
version.boolean
isRunning()
Check if this object is currently managing a runningngrok
process.void
setAuthToken(java.lang.String authToken)
Set thengrok
auth token in the config file, enabling authenticated features (for instance, more concurrent tunnels, custom subdomains, etc.).void
start()
If not already running, start angrok
process with no tunnels.void
stop()
Terminate thengrok
processes, if running.void
update()
Updatengrok
, if an update is available.
-
-
-
Constructor Detail
-
NgrokProcess
public NgrokProcess(JavaNgrokConfig javaNgrokConfig, NgrokInstaller ngrokInstaller)
Ifngrok
is not already installed atJavaNgrokConfig.getNgrokPath()
, the givenNgrokInstaller
will install it. This will also provision a defaultngrok
config atJavaNgrokConfig.getConfigPath()
, if none exists.- Parameters:
javaNgrokConfig
- Thejava-ngrok
to use when interacting with thengrok
binary.ngrokInstaller
- The class used to download and installngrok
.
-
-
Method Detail
-
start
public void start()
If not already running, start angrok
process with no tunnels. This will start thengrok
web interface, against which HTTP requests can be made to create, interact with, and destroy tunnels.
-
isRunning
public boolean isRunning()
Check if this object is currently managing a runningngrok
process.
-
stop
public void stop() throws java.io.IOException
Terminate thengrok
processes, if running. This method will not block, it will just issue a kill request.- Throws:
java.io.IOException
-
setAuthToken
public void setAuthToken(java.lang.String authToken)
Set thengrok
auth token in the config file, enabling authenticated features (for instance, more concurrent tunnels, custom subdomains, etc.).// Setting an auth token allows us to do things like open multiple tunnels at the same time final NgrokClient ngrokClient = new NgrokClient.Builder().build(); ngrokClient.setAuthToken("<NGROK_AUTHTOKEN>") // <NgrokTunnel: "http://<public_sub1>.ngrok.io" -> "http://localhost:80"> final Tunnel ngrokTunnel1 = ngrokClient.connect(); // <NgrokTunnel: "http://<public_sub2>.ngrok.io" -> "http://localhost:8000"> final CreateTunnel sshCreateTunnel = new CreateTunnel.Builder() .withAddr(8000) .build(); final Tunnel ngrokTunnel2 = ngrokClient.connect(createTunnel);
The auth token can also be set in the
JavaNgrokConfig
that is passed to theNgrokClient.Builder
.- Parameters:
authToken
- The auth token.
-
update
public void update()
Updatengrok
, if an update is available.
-
getVersion
public java.lang.String getVersion()
Get thengrok
version.- Returns:
- The version.
-
getApiUrl
public java.lang.String getApiUrl()
Get the API URL for thengrok
web interface.
-
getNgrokInstaller
public NgrokInstaller getNgrokInstaller()
Get the class used to download and installngrok
.
-
getProcessMonitor
public NgrokProcess.ProcessMonitor getProcessMonitor()
Get the Runnable that is monitoring thengrok
thread.
-
-