Package com.github.alexdlaird.ngrok
Class NgrokClient
- java.lang.Object
-
- com.github.alexdlaird.ngrok.NgrokClient
-
public class NgrokClient extends java.lang.Object
A 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 class
NgrokClient.Builder
Builder for aNgrokClient
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tunnel
connect()
Tunnel
connect(CreateTunnel createTunnel)
Establish a newngrok
tunnel for the tunnel definition, returning an object representing the connected tunnel.void
disconnect(java.lang.String publicUrl)
Disconnect thengrok
tunnel for the given URL, if open.HttpClient
getHttpClient()
Get the class used to make HTTP requests tongrok
's APIs.JavaNgrokConfig
getJavaNgrokConfig()
Get thejava-ngrok
to use when interacting with thengrok
binary.NgrokInstaller
getNgrokInstaller()
Get the class used to download and installngrok
.NgrokProcess
getNgrokProcess()
Get the class used to manage thengrok
binary.Tunnels
getTunnels()
Get a list of activengrok
tunnels.Version
getVersion()
Get thengrok
andjava-ngrok
version.void
kill()
Terminate thengrok
processes, if running.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
update()
Updatengrok
, if an update is available.
-
-
-
Method Detail
-
connect
public Tunnel connect(CreateTunnel createTunnel)
Establish a newngrok
tunnel for the tunnel definition, returning an object representing the connected tunnel.ngrok
's default behavior forhttp
when no additional properties are passed is to open two tunnels, onehttp
and onehttps
. This method will return a reference to thehttp
tunnel in this case. If only a single tunnel is needed, callCreateTunnel.Builder.withBindTls(boolean)
withtrue
and a reference to thehttps
tunnel 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 thengrok
tunnel for the given URL, if open.- Parameters:
publicUrl
- The public URL of the tunnel to disconnect.
-
getTunnels
public Tunnels getTunnels()
Get a list of activengrok
tunnels.- Returns:
- The active
ngrok
tunnels.
-
kill
public void kill()
Terminate thengrok
processes, if running. This method will not block, it will just issue a kill request.
-
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.).- Parameters:
authToken
- The auth token.
-
update
public void update()
Updatengrok
, if an update is available.
-
getVersion
public Version getVersion()
Get thengrok
andjava-ngrok
version.- Returns:
- The versions.
-
getJavaNgrokConfig
public JavaNgrokConfig getJavaNgrokConfig()
Get thejava-ngrok
to use when interacting with thengrok
binary.
-
getNgrokInstaller
public NgrokInstaller getNgrokInstaller()
Get the class used to download and installngrok
.
-
getNgrokProcess
public NgrokProcess getNgrokProcess()
Get the class used to manage thengrok
binary.
-
getHttpClient
public HttpClient getHttpClient()
Get the class used to make HTTP requests tongrok
's APIs.
-
-