public class TunnelConnection extends Object implements Closeable
Tunnel's.| Constructor and Description |
|---|
TunnelConnection(ISessionFactory sessionFactory,
int localPort,
String destinationHostname,
int destinationPort)
Creates a TunnelConnection using the the
sessionFactory to
obtain its ssh connection with a single tunnel defined by
Tunnel(localPort, destinationHostname, destinationPort). |
TunnelConnection(ISessionFactory sessionFactory,
List<Tunnel> tunnels)
Creates a TunnelConnection using the the
sessionFactory to
obtain its ssh connection with a list of
Tunnel's. |
TunnelConnection(ISessionFactory sessionFactory,
Tunnel... tunnels)
Creates a TunnelConnection using the the
sessionFactory to
obtain its ssh connection with a list of
Tunnel's. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying ssh session causing all tunnels to be closed.
|
String |
getAsString() |
Tunnel |
getTunnel(String destinationHostname,
int destinationPort)
Returns the tunnel matching the supplied values, or
null if
there isn't one that matches. |
boolean |
isOpen()
Returns true if the underlying ssh session is open.
|
void |
open()
Opens a session and connects all of the tunnels.
|
void |
reopen()
Closes, and re-opens the session and all its tunnels.
|
public TunnelConnection(ISessionFactory sessionFactory, int localPort, String destinationHostname, int destinationPort)
sessionFactory to
obtain its ssh connection with a single tunnel defined by
Tunnel(localPort, destinationHostname, destinationPort).sessionFactory - The sessionFactorylocalPort - The local port to bind todestinationHostname - The destination hostname to tunnel todestinationPort - The destination port to tunnel topublic TunnelConnection(ISessionFactory sessionFactory, Tunnel... tunnels)
sessionFactory to
obtain its ssh connection with a list of
Tunnel's.sessionFactory - The sessionFactorytunnels - The tunnelspublic TunnelConnection(ISessionFactory sessionFactory, List<Tunnel> tunnels)
sessionFactory to
obtain its ssh connection with a list of
Tunnel's.sessionFactory - The sessionFactorytunnels - The tunnelspublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic Tunnel getTunnel(String destinationHostname, int destinationPort)
null if
there isn't one that matches.destinationHostname - The tunnels destination hostnamedestinationPort - The tunnels destination portpublic boolean isOpen()
public void open()
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException - If unable to connectpublic void reopen()
throws com.jcraft.jsch.JSchException
close() followed by a call to open().com.jcraft.jsch.JSchException - If unable to connectCopyright © 2020 Philip Helger. All rights reserved.