public class Tunnel
extends java.lang.Object
| Constructor and Description |
|---|
Tunnel(int localPort,
java.lang.String destinationHostname,
int destinationPort)
Creates a Tunnel to
destinationPort on
destinationHostname from localPort on
localhost. |
Tunnel(java.lang.String spec)
Creates a Tunnel from a
spec string. |
Tunnel(java.lang.String destinationHostname,
int destinationPort)
Creates a Tunnel to
destinationPort on
destinationHostname from a dynamically assigned port on
localhost. |
Tunnel(java.lang.String localAlias,
int localPort,
java.lang.String destinationHostname,
int destinationPort)
Creates a Tunnel to
destinationPort on
destinationHostname from localPort on
localAlias. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other)
Returns true if
other is a Tunnel whose spec
(either specified or calculated) is equal to this tunnels
spec. |
int |
getAssignedLocalPort()
Returns the local port currently bound to.
|
java.lang.String |
getDestinationHostname()
Returns the hostname of the destination.
|
int |
getDestinationPort()
Returns the port of the destination.
|
java.lang.String |
getLocalAlias()
Returns the local alias bound to.
|
int |
getLocalPort()
Returns the port this tunnel was configured with.
|
java.lang.String |
getSpec()
Returns the spec string (either calculated or specified) for this tunnel.
|
int |
hashCode() |
java.lang.String |
toString() |
public Tunnel(java.lang.String spec)
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" );
spec - A tunnel spec stringTunnel(String, int, String, int),
rfc4254public Tunnel(java.lang.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,
java.lang.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(java.lang.String localAlias,
int localPort,
java.lang.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 boolean equals(java.lang.Object other)
other is a Tunnel whose spec
(either specified or calculated) is equal to this tunnels
spec.equals in class java.lang.Objectspec'sgetSpec()public 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 java.lang.String getDestinationHostname()
public int getDestinationPort()
public java.lang.String getLocalAlias()
public int getLocalPort()
getAssignedLocalPort().public java.lang.String getSpec()
A spec string is composed of 4 parts separated by a colon (:
):
localAlias (optional)localPort (optional)destinationHostnamedestinationPortpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2018 pastdev.com. All Rights Reserved.