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 newTcpBuilderwith a given session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Forwarder.Endpointforward(URL url)Start listening and forwarding connections to given url.Optional<String>getRemoteAddress()Returns the remote address on this builder.Listener.Endpointlisten()Starts listening and accepting new connections.TcpBuilderremoteAddress(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 newTcpBuilderwith a given session.- Parameters:
session- the session over which this listener will connect. Ifnull,listen()andforward(URL)will throwNullPointerException, use the corresponding methods on theSessionobject 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.BuilderStarts listening and accepting new connections.- Specified by:
listenin interfaceListener.Builder<Listener.Endpoint>- Returns:
- the concrete
Listenerinstance - Throws:
IOException- if an I/O error occurs
-
forward
public Forwarder.Endpoint forward(URL url) throws IOException
Description copied from interface:Forwarder.BuilderStart listening and forwarding connections to given url.- Specified by:
forwardin interfaceForwarder.Builder<Forwarder.Endpoint>- Parameters:
url- to forward connections to- Returns:
- the concrete
Forwarderinstance - Throws:
IOException- if an I/O error occurs
-
-