Package com.ngrok
Interface Session
-
- All Superinterfaces:
AutoCloseable
public interface Session extends AutoCloseable
A session with the ngrok service.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Session.Builder
A builder for creating a sessionstatic class
Session.ClientInfo
Represents additional information about the client.static interface
Session.CommandHandler
Provides a way to listen for specific server side events.static interface
Session.HeartbeatHandler
Provides a way to monitor current session's heartbeats and disconnects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
void
closeForwarder(String forwarderId)
Closes a forwarder by its IDvoid
closeListener(String listenerId)
Closes a listener by its IDstatic Session
connect(Session.Builder builder)
Connects a session with specifiedSession.Builder
default EdgeBuilder
edge()
Creates a newEdgeBuilder
associated with this session.Forwarder.Edge
forwardEdge(EdgeBuilder builder, URL url)
Configures and starts aForwarder.Edge
Forwarder.Endpoint
forwardHttp(HttpBuilder builder, URL url)
Configures and starts a HTTPForwarder.Endpoint
Forwarder.Endpoint
forwardTcp(TcpBuilder builder, URL url)
Configures and starts a TCPForwarder.Endpoint
Forwarder.Endpoint
forwardTls(TlsBuilder builder, URL url)
Configures and starts a TLSForwarder.Endpoint
String
getId()
Returns the ID of this sessionString
getMetadata()
Returns the metadata of this sessiondefault HttpBuilder
httpEndpoint()
Creates a newHttpBuilder
associated with this session.Listener.Edge
listenEdge(EdgeBuilder builder)
Configures and starts aListener.Edge
Listener.Endpoint
listenHttp(HttpBuilder builder)
Configures and starts a HTTPListener.Endpoint
Listener.Endpoint
listenTcp(TcpBuilder builder)
Configures and starts a TCPListener.Endpoint
Listener.Endpoint
listenTls(TlsBuilder builder)
Configures and starts a TLSListener.Endpoint
default TcpBuilder
tcpEndpoint()
Creates a newTcpBuilder
associated with this session.default TlsBuilder
tlsEndpoint()
Creates a newTlsBuilder
associated with this session.static Session.Builder
withAuthtoken(String authtoken)
Creates a new sessionSession.Builder
with specified ngrok authtokenstatic Session.Builder
withAuthtokenFromEnv()
Creates a new sessionSession.Builder
resolving the ngrok authtoken fromNGROK_AUTHTOKEN
env variable
-
-
-
Method Detail
-
withAuthtoken
static Session.Builder withAuthtoken(String authtoken)
Creates a new sessionSession.Builder
with specified ngrok authtoken- Parameters:
authtoken
- the authtoken- Returns:
- the builder
-
withAuthtokenFromEnv
static Session.Builder withAuthtokenFromEnv()
Creates a new sessionSession.Builder
resolving the ngrok authtoken fromNGROK_AUTHTOKEN
env variable- Returns:
- the builder
-
connect
static Session connect(Session.Builder builder) throws IOException
Connects a session with specifiedSession.Builder
- Parameters:
builder
- the builder- Returns:
- newly created session
- Throws:
IOException
- if an I/O error occurs
-
getId
String getId()
Returns the ID of this session- Returns:
- session ID
-
getMetadata
String getMetadata()
Returns the metadata of this session- Returns:
- session metadata
-
tcpEndpoint
default TcpBuilder tcpEndpoint()
Creates a newTcpBuilder
associated with this session.- Returns:
- the builder
-
listenTcp
Listener.Endpoint listenTcp(TcpBuilder builder) throws IOException
Configures and starts a TCPListener.Endpoint
- Parameters:
builder
- the builder- Returns:
- the running listener
- Throws:
IOException
- if an I/O error occurs
-
forwardTcp
Forwarder.Endpoint forwardTcp(TcpBuilder builder, URL url) throws IOException
Configures and starts a TCPForwarder.Endpoint
- Parameters:
builder
- the builderurl
- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException
- if an I/O error occurs
-
tlsEndpoint
default TlsBuilder tlsEndpoint()
Creates a newTlsBuilder
associated with this session.- Returns:
- the builder
-
listenTls
Listener.Endpoint listenTls(TlsBuilder builder) throws IOException
Configures and starts a TLSListener.Endpoint
- Parameters:
builder
- the builder- Returns:
- the running listener
- Throws:
IOException
- if an I/O error occurs
-
forwardTls
Forwarder.Endpoint forwardTls(TlsBuilder builder, URL url) throws IOException
Configures and starts a TLSForwarder.Endpoint
- Parameters:
builder
- the builderurl
- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException
- if an I/O error occurs
-
httpEndpoint
default HttpBuilder httpEndpoint()
Creates a newHttpBuilder
associated with this session.- Returns:
- the builder
-
listenHttp
Listener.Endpoint listenHttp(HttpBuilder builder) throws IOException
Configures and starts a HTTPListener.Endpoint
- Parameters:
builder
- the builder- Returns:
- the running listener
- Throws:
IOException
- if an I/O error occurs
-
forwardHttp
Forwarder.Endpoint forwardHttp(HttpBuilder builder, URL url) throws IOException
Configures and starts a HTTPForwarder.Endpoint
- Parameters:
builder
- the builderurl
- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException
- if an I/O error occurs
-
edge
default EdgeBuilder edge()
Creates a newEdgeBuilder
associated with this session.- Returns:
- the builder
-
listenEdge
Listener.Edge listenEdge(EdgeBuilder builder) throws IOException
Configures and starts aListener.Edge
- Parameters:
builder
- the builder- Returns:
- the running listener
- Throws:
IOException
- if an I/O error occurs
-
forwardEdge
Forwarder.Edge forwardEdge(EdgeBuilder builder, URL url) throws IOException
Configures and starts aForwarder.Edge
- Parameters:
builder
- the builderurl
- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException
- if an I/O error occurs
-
closeListener
void closeListener(String listenerId) throws IOException
Closes a listener by its ID- Parameters:
listenerId
- the listener ID- Throws:
IOException
- if an I/O error occurs
-
closeForwarder
void closeForwarder(String forwarderId) throws IOException
Closes a forwarder by its ID- Parameters:
forwarderId
- the forwarder ID- Throws:
IOException
- if an I/O error occurs
-
close
void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
-