public class ConnectTunnel extends Object implements TcpTunnel
Such tunnel is often used for "HTTPS proxy"; but it can be used for tunneling any TCP traffic too.
Basic/Digest authentications are supported.
This class is stateful for caching authentication state.
Constructor and Description |
---|
ConnectTunnel(TcpAddress address,
Supplier<Async<UserPass>> userPassSupplier)
Create an HTTP CONNECT tunnel.
|
ConnectTunnel(String host,
int port,
String username,
String password)
Create an HTTP CONNECT tunnel.
|
ConnectTunnel(String host,
int port)
Create an HTTP CONNECT tunnel.
|
Instance Methods | |
---|---|
TcpAddress |
address()
The address of the tunnel service.
|
Async<TcpConnection> |
tunnelTo(TcpConnection tcpConn,
String host,
int port)
Tunnel to the remote host:port.
|
public ConnectTunnel(TcpAddress address, Supplier<Async<UserPass>> userPassSupplier)
If userPassSupplier!=null, BASIC and DIGEST authentications are supported.
public ConnectTunnel(String host, int port, String username, String password)
This is a convenience method for
ConnectTunnel(address, userPassSupplier)
with address.ssl=false.
public ConnectTunnel(String host, int port)
This is a convenience method for
ConnectTunnel(address, userPassSupplier)
with address.ssl=false, userPassSupplier=null.
public TcpAddress address()
TcpTunnel
If address.ssl
==true,
traffic between the client and the tunnel must be encrypted in SSL.
public Async<TcpConnection> tunnelTo(TcpConnection tcpConn, String host, int port)
TcpTunnel
The `connection` is established between the client and the tunnel service. The implementation of this method does necessary protocol dance to instruct the tunnel service to tunnel to the server (at host:port).
When this action succeeds, the resulting TcpConnection is used by the client to communicate to the server, as if it's a direct connection. The resulting TcpConnection could be the same object as the `connection` argument.