Package com.ngrok
Class TcpBuilder
- java.lang.Object
-
- com.ngrok.MetadataBuilder<T>
-
- com.ngrok.EndpointBuilder<TcpBuilder>
-
- com.ngrok.TcpBuilder
-
- All Implemented Interfaces:
Forwarder.Builder<Forwarder.Endpoint>
,Listener.Builder<Listener.Endpoint>
public class TcpBuilder extends EndpointBuilder<TcpBuilder> implements Listener.Builder<Listener.Endpoint>, Forwarder.Builder<Forwarder.Endpoint>
A builder for creating a TCP endpoint listener
-
-
Constructor Summary
Constructors Constructor Description TcpBuilder(Session session)
Creates a newTcpBuilder
with a given session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Forwarder.Endpoint
forward(URL url)
Start listening and forwarding connections to given url.Optional<String>
getRemoteAddress()
Returns the remote address on this builder.Listener.Endpoint
listen()
Starts listening and accepting new connections.TcpBuilder
remoteAddress(String remoteAddress)
Sets the TCP address to request for this TCP endpoint.-
Methods inherited from class com.ngrok.EndpointBuilder
allowCIDR, denyCIDR, getAllowCIDR, getDenyCIDR, getPolicy, getProxyProto, getProxyProtoVersion, getTrafficPolicy, policy, proxyProto, trafficPolicy
-
Methods inherited from class com.ngrok.MetadataBuilder
forwardsTo, getForwardsTo, getMetadata, metadata
-
-
-
-
Constructor Detail
-
TcpBuilder
public TcpBuilder(Session session)
Creates a newTcpBuilder
with a given session.- Parameters:
session
- the session over which this listener will connect. Ifnull
,listen()
andforward(URL)
will throwNullPointerException
, use the corresponding methods on theSession
object directly.
-
-
Method Detail
-
remoteAddress
public TcpBuilder remoteAddress(String remoteAddress)
Sets the TCP address to request for this TCP endpoint.- Parameters:
remoteAddress
- the remote address- Returns:
- the builder instance
-
getRemoteAddress
public Optional<String> getRemoteAddress()
Returns the remote address on this builder.- Returns:
- the remote address
-
listen
public Listener.Endpoint listen() throws IOException
Description copied from interface:Listener.Builder
Starts listening and accepting new connections.- Specified by:
listen
in interfaceListener.Builder<Listener.Endpoint>
- Returns:
- the concrete
Listener
instance - Throws:
IOException
- if an I/O error occurs
-
forward
public Forwarder.Endpoint forward(URL url) throws IOException
Description copied from interface:Forwarder.Builder
Start listening and forwarding connections to given url.- Specified by:
forward
in interfaceForwarder.Builder<Forwarder.Endpoint>
- Parameters:
url
- to forward connections to- Returns:
- the concrete
Forwarder
instance - Throws:
IOException
- if an I/O error occurs
-
-