Class SshProxyServer
java.lang.Object
de.iip_ecosphere.platform.deviceMgt.ssh.SshProxyServer
- All Implemented Interfaces:
Runnable
With the Help of the
SshProxyServer one can create a server
to which ssh clients can connect to.
Main parts were acquired from https://github.com/oksuz/tcp-proxy (MIT)- Author:
- oksuz, Github on 29/10/2017.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final de.iip_ecosphere.platform.support.logging.Loggerprivate intprivate final Stringprivate final intprivate ServerSocket -
Constructor Summary
ConstructorsConstructorDescriptionSshProxyServer(String remoteIp, int remotePort, int localPort) Creates a SshProxyServer, which can listen on all interface and a given port. -
Method Summary
Modifier and TypeMethodDescriptionintgetPort()Get the port the server is listening on.Get the remote ip.intGet the remote port.voidlisten()Starts listening, so others can connect to this proxy.voidrun()Runs the SshProxyServer and listens on the specified/chosen port.private voidstartThread(Connection connection) Starts a connection thread.voidstop()Stops the proxy server.
-
Field Details
-
LOGGER
private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER -
remoteIp
-
remotePort
private final int remotePort -
port
private int port -
serverSocket
-
-
Constructor Details
-
SshProxyServer
Creates a SshProxyServer, which can listen on all interface and a given port.- Parameters:
remoteIp- the remote ip to connect toremotePort- the remote port to connect tolocalPort- the local port to accept connections
-
-
Method Details
-
listen
Starts listening, so others can connect to this proxy. If the desired port is set to 0, a server socket is listening on a randomly chosen port in the ephemeral port range (1024–65535). One can get the assigned port throughgetPort().- Throws:
IOException- in case of network problems
-
stop
Stops the proxy server.- Throws:
IOException- in case of network problems
-
startThread
Starts a connection thread.- Parameters:
connection- the connection thread
-
getRemoteIp
Get the remote ip.- Returns:
- the remote ip
-
getRemotePort
public int getRemotePort()Get the remote port.- Returns:
- the remote port
-
getPort
public int getPort()Get the port the server is listening on.- Returns:
- the local port
-
run
public void run()Runs the SshProxyServer and listens on the specified/chosen port.
-