Class SshProxyServer

java.lang.Object
de.iip_ecosphere.platform.deviceMgt.ssh.SshProxyServer
All Implemented Interfaces:
Runnable

public class SshProxyServer extends Object implements 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 Details

    • LOGGER

      private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER
    • remoteIp

      private final String remoteIp
    • remotePort

      private final int remotePort
    • port

      private int port
    • serverSocket

      private ServerSocket serverSocket
  • Constructor Details

    • SshProxyServer

      public SshProxyServer(String remoteIp, int remotePort, int localPort)
      Creates a SshProxyServer, which can listen on all interface and a given port.
      Parameters:
      remoteIp - the remote ip to connect to
      remotePort - the remote port to connect to
      localPort - the local port to accept connections
  • Method Details

    • listen

      public void listen() throws IOException
      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 through getPort().
      Throws:
      IOException - in case of network problems
    • stop

      public void stop() throws IOException
      Stops the proxy server.
      Throws:
      IOException - in case of network problems
    • startThread

      private void startThread(Connection connection)
      Starts a connection thread.
      Parameters:
      connection - the connection thread
    • getRemoteIp

      public String 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.
      Specified by:
      run in interface Runnable