| Constructor and Description |
|---|
Tunnel(int localPort,
String destinationHostname,
int destinationPort)
Creates a Tunnel to
destinationPort on
destinationHostname from localPort on
localhost. |
Tunnel(String sSpec)
Creates a Tunnel from a
spec string. |
Tunnel(String destinationHostname,
int destinationPort)
Creates a Tunnel to
destinationPort on
destinationHostname from a dynamically assigned port on
localhost. |
Tunnel(String localAlias,
int localPort,
String destinationHostname,
int destinationPort)
Creates a Tunnel to
destinationPort on
destinationHostname from localPort on
localAlias. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
int |
getAssignedLocalPort()
Returns the local port currently bound to.
|
String |
getAsString() |
String |
getDestinationHostname()
Returns the hostname of the destination.
|
int |
getDestinationPort()
Returns the port of the destination.
|
String |
getLocalAlias()
Returns the local alias bound to.
|
int |
getLocalPort()
Returns the port this tunnel was configured with.
|
String |
getSpec()
Returns the spec string (either calculated or specified) for this tunnel.
|
int |
hashCode() |
String |
toString() |
public Tunnel(@Nonnull @Nonempty String sSpec)
spec string. For details on this
string, see getSpec().
Both localAlias and localPort are optional, in
which case they default to localhost and 0
respectively.
Examples:
// Equivalaent to new Tunnel("localhost", 0, "foobar", 1234);
new Tunnel ("foobar:1234");
// Equivalaent to new Tunnel("localhost", 1234, "foobar", 1234);
new Tunnel ("1234:foobar:1234");
// Equivalaent to new Tunnel("local_foobar", 1234, "foobar", 1234);
new Tunnel ("local_foobar:1234:foobar:1234");
sSpec - A tunnel spec stringTunnel(String, int, String, int),
rfc4254public Tunnel(String destinationHostname, int destinationPort)
destinationPort on
destinationHostname from a dynamically assigned port on
localhost. Simply callsdestinationHostname - The hostname to tunnel todestinationPort - The port to tunnel toTunnel(int, String, int),
rfc4254public Tunnel(int localPort,
String destinationHostname,
int destinationPort)
destinationPort on
destinationHostname from localPort on
localhost.localPort - The local port to bind todestinationHostname - The hostname to tunnel todestinationPort - The port to tunnel toTunnel(String, int, String, int),
rfc4254public Tunnel(String localAlias, int localPort, String destinationHostname, int destinationPort)
destinationPort on
destinationHostname from localPort on
localAlias.
This is similar in behavior to the -L option in ssh, with the
exception that you can specify 0 for the local port in which
case the port will be dynamically allocated and you can
getAssignedLocalPort() after the tunnel has been started.
A common use case for localAlias might be to link your
loopback interfaces to names via an entries in /etc/hosts
which would allow you to use the same port number for more than one tunnel.
For example:
127.0.0.2 foo 127.0.0.3 barWould allow you to have both of these open at the same time:
new Tunnel ("foo", 1234, "remote_foo", 1234);
new Tunnel ("bar", 1234, "remote_bar", 1234);
localAlias - The local interface to bind tolocalPort - The local port to bind todestinationHostname - The hostname to tunnel todestinationPort - The port to tunnel toSession.setPortForwardingL(String, int, String, int),
rfc4254public int getAssignedLocalPort()
0 was specified
as the port to bind to, this will return the dynamically allocated port,
otherwise it will return the port specified.public String getDestinationHostname()
public int getDestinationPort()
public String getLocalAlias()
public int getLocalPort()
getAssignedLocalPort().@Nonnull public String getSpec()
A spec string is composed of 4 parts separated by a colon (:
):
localAlias (optional)localPort (optional)destinationHostnamedestinationPortCopyright © 2020 Philip Helger. All rights reserved.