public class TunnelConnectionManager
extends java.lang.Object
implements java.io.Closeable
| Constructor and Description |
|---|
TunnelConnectionManager(SessionFactory baseSessionFactory)
Creates a TunnelConnectionManager that will use the
baseSessionFactory to obtain its session connections. |
TunnelConnectionManager(SessionFactory baseSessionFactory,
java.lang.Iterable<java.lang.String> pathAndSpecList)
Creates a TunnelConnectionManager that will use the
baseSessionFactory to obtain its session connections and
provide the tunnels specified. |
TunnelConnectionManager(SessionFactory baseSessionFactory,
java.lang.String... pathAndSpecList)
Creates a TunnelConnectionManager that will use the
baseSessionFactory to obtain its session connections and
provide the tunnels specified. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes all sessions and their associated tunnels.
|
void |
ensureOpen()
Will re-open any connections that are not still open.
|
Tunnel |
getTunnel(java.lang.String destinationHostname,
int destinationPort)
Returns the tunnel matching the supplied values, or
null if
there isn't one that matches. |
void |
open()
Opens all the necessary sessions and connects all of the tunnels.
|
void |
setTunnelConnections(java.lang.Iterable<java.lang.String> pathAndSpecList)
Creates a set of tunnel connections based upon the pathAndTunnels.
|
void |
setTunnelConnectionsFromFile(java.io.File tunnelsConfig)
Creates a set of tunnel connections based upon the contents of
tunnelsConfig. |
public TunnelConnectionManager(SessionFactory baseSessionFactory) throws com.jcraft.jsch.JSchException
baseSessionFactory to obtain its session connections.
Because this constructor does not set the tunnel connections for you, you
will need to call setTunnelConnections(Iterable).baseSessionFactory - The session factorycom.jcraft.jsch.JSchException - For connection failuressetTunnelConnections(Iterable)public TunnelConnectionManager(SessionFactory baseSessionFactory, java.lang.String... pathAndSpecList) throws com.jcraft.jsch.JSchException
baseSessionFactory to obtain its session connections and
provide the tunnels specified.baseSessionFactory - The session factorypathAndSpecList - A list of path and
spec stringscom.jcraft.jsch.JSchException - For connection failuressetTunnelConnections(Iterable)public TunnelConnectionManager(SessionFactory baseSessionFactory, java.lang.Iterable<java.lang.String> pathAndSpecList) throws com.jcraft.jsch.JSchException
baseSessionFactory to obtain its session connections and
provide the tunnels specified.baseSessionFactory - The session factorypathAndSpecList - A list of path and
spec stringscom.jcraft.jsch.JSchException - For connection failuressetTunnelConnections(Iterable)public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableTunnelConnection.close()public void ensureOpen()
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException - For connection failurespublic Tunnel getTunnel(java.lang.String destinationHostname, int destinationPort)
null if
there isn't one that matches.destinationHostname - The tunnels destination hostnamedestinationPort - The tunnels destination portTunnelConnection.getTunnel(String, int)public void open()
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException - For connection failuresTunnelConnection.open()public void setTunnelConnectionsFromFile(java.io.File tunnelsConfig)
throws java.io.IOException,
com.jcraft.jsch.JSchException
tunnelsConfig. The format of this file is one path and
tunnel per line. Comments and empty lines are allowed and are excluded
using the pattern ^\s*(?:#.*)?$.tunnelsConfig - A file containing tunnel configurationjava.io.IOException - If unable to read from tunnelsConfigcom.jcraft.jsch.JSchException - For connection failurespublic void setTunnelConnections(java.lang.Iterable<java.lang.String> pathAndSpecList)
throws com.jcraft.jsch.JSchException
path and tunnels = path and tunnel, {new line, path and tunnel}
path and tunnel = path, "|", tunnel
new line = "\n"
path = path part, {"->", path part}
path part = {user, "@"}, hostname
tunnel = {local part}, ":", destination hostname, ":", destination port
local part = {local alias, ":"}, local port
local alias = hostname
local port = port
destination hostname = hostname
destination port = port
user = ? user name ?
hostname = ? hostname ?
port = ? port ?
For example:
jimhenson@admin.muppets.com->animal@drteethandtheelectricmahem.muppets.com|drteeth:8080:drteeth.muppets.com:80
Says open an ssh connection as user jimhenson to host
admin.muppets.com. Then, through that connection, open a
connection as user animal to host
drteethandtheelectricmahem.muppets.com. Then map local port
8080 on the interface with alias drteeth
through the two-hop tunnel to port 80 on
drteeth.muppets.com.
pathAndSpecList - A list of path and spec entriescom.jcraft.jsch.JSchException - For connection failuresCopyright © 2018 pastdev.com. All Rights Reserved.