- java.lang.Object
-
- com.github.alexdlaird.ngrok.process.NgrokProcess
-
public class NgrokProcess extends java.lang.ObjectAn object containing information about thengrokprocess. Can be configured withJavaNgrokConfig.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNgrokProcess.ProcessMonitor
-
Constructor Summary
Constructors Constructor Description NgrokProcess(JavaNgrokConfig javaNgrokConfig, NgrokInstaller ngrokInstaller)Ifngrokis not already installed atJavaNgrokConfig.getNgrokPath(), the givenNgrokInstallerwill install it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetApiUrl()Get the API URL for thengrokweb interface.NgrokInstallergetNgrokInstaller()Get the class used to download and installngrok.NgrokProcess.ProcessMonitorgetProcessMonitor()Get the Runnable that is monitoring thengrokthread.java.lang.StringgetVersion()Get thengrokversion.booleanisRunning()Check if this object is currently managing a runningngrokprocess.voidsetAuthToken(java.lang.String authToken)Set thengrokauth token in the config file, enabling authenticated features (for instance, more concurrent tunnels, custom subdomains, etc.).voidstart()If not already running, start angrokprocess with no tunnels.voidstop()Terminate thengrokprocesses, if running.voidupdate()Updatengrok, if an update is available.
-
-
-
Constructor Detail
-
NgrokProcess
public NgrokProcess(JavaNgrokConfig javaNgrokConfig, NgrokInstaller ngrokInstaller)
Ifngrokis not already installed atJavaNgrokConfig.getNgrokPath(), the givenNgrokInstallerwill install it. This will also provision a defaultngrokconfig atJavaNgrokConfig.getConfigPath(), if none exists.- Parameters:
javaNgrokConfig- Thejava-ngrokto use when interacting with thengrokbinary.ngrokInstaller- The class used to download and installngrok.
-
-
Method Detail
-
start
public void start()
If not already running, start angrokprocess with no tunnels. This will start thengrokweb 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 runningngrokprocess.
-
stop
public void stop()
Terminate thengrokprocesses, if running. This method will not block, it will just issue a kill request.
-
setAuthToken
public void setAuthToken(java.lang.String authToken)
Set thengrokauth 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("") // <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
JavaNgrokConfigthat 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 thengrokversion.- Returns:
- The version.
-
getApiUrl
public java.lang.String getApiUrl()
Get the API URL for thengrokweb interface.
-
getNgrokInstaller
public NgrokInstaller getNgrokInstaller()
Get the class used to download and installngrok.
-
getProcessMonitor
public NgrokProcess.ProcessMonitor getProcessMonitor()
Get the Runnable that is monitoring thengrokthread.
-
-