Package com.github.alexdlaird.ngrok
Class NgrokClient
- java.lang.Object
-
- com.github.alexdlaird.ngrok.NgrokClient
-
public class NgrokClient extends java.lang.ObjectA client for interacting with ngrok, its binary, and its APIs. Can be configured withJavaNgrokConfig.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNgrokClient.BuilderBuilder for aNgrokClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tunnelconnect()Tunnelconnect(CreateTunnel createTunnel)Establish a newngroktunnel for the tunnel definition, returning an object representing the connected tunnel.voiddisconnect(java.lang.String publicUrl)Disconnect thengroktunnel for the given URL, if open.HttpClientgetHttpClient()Get the class used to make HTTP requests tongrok's APIs.JavaNgrokConfiggetJavaNgrokConfig()Get thejava-ngrokto use when interacting with thengrokbinary.NgrokInstallergetNgrokInstaller()Get the class used to download and installngrok.NgrokProcessgetNgrokProcess()Get the class used to manage thengrokbinary.TunnelsgetTunnels()Get a list of activengroktunnels.VersiongetVersion()Get thengrokandjava-ngrokversion.voidkill()Terminate thengrokprocesses, if running.voidsetAuthToken(java.lang.String authToken)Set thengrokauth token in the config file, enabling authenticated features (for instance, more concurrent tunnels, custom subdomains, etc.).voidupdate()Updatengrok, if an update is available.
-
-
-
Method Detail
-
connect
public Tunnel connect(CreateTunnel createTunnel)
Establish a newngroktunnel for the tunnel definition, returning an object representing the connected tunnel.ngrok's default behavior forhttpwhen no additional properties are passed is to open two tunnels, onehttpand onehttps. This method will return a reference to thehttptunnel in this case. If only a single tunnel is needed, callCreateTunnel.Builder.withBindTls(boolean)withtrueand a reference to thehttpstunnel will be returned.- Parameters:
createTunnel- The tunnel definition.- Returns:
- The created Tunnel.
-
connect
public Tunnel connect()
-
disconnect
public void disconnect(java.lang.String publicUrl)
Disconnect thengroktunnel for the given URL, if open.- Parameters:
publicUrl- The public URL of the tunnel to disconnect.
-
getTunnels
public Tunnels getTunnels()
Get a list of activengroktunnels.- Returns:
- The active
ngroktunnels.
-
kill
public void kill()
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.).- Parameters:
authToken- The auth token.
-
update
public void update()
Updatengrok, if an update is available.
-
getVersion
public Version getVersion()
Get thengrokandjava-ngrokversion.- Returns:
- The versions.
-
getJavaNgrokConfig
public JavaNgrokConfig getJavaNgrokConfig()
Get thejava-ngrokto use when interacting with thengrokbinary.
-
getNgrokInstaller
public NgrokInstaller getNgrokInstaller()
Get the class used to download and installngrok.
-
getNgrokProcess
public NgrokProcess getNgrokProcess()
Get the class used to manage thengrokbinary.
-
getHttpClient
public HttpClient getHttpClient()
Get the class used to make HTTP requests tongrok's APIs.
-
-