java.lang.Object
de.bytestore.hostinger.process.entity.console.ssh.SSHSocket

@Component public class SSHSocket extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a SSHShellListener to the list of listeners.
    void
    Closes the SSHSocket and removes it from the sockets HashMap if it exists.
    void
    Closes the connection of the SSHSocket by disconnecting the channel and session, if they are not null.
    static Pattern
    Returns the host pattern used by the ProxMoxPool class.
    static Matcher
    Retrieves the matcher object for a given input line using the host pattern.
    void
     
    void
    Prepares the channel for communication by initializing the output and input streams, and continuously reads input from the channel and passes it to the message listeners until the end of input is reached.
    void
    Removes the specified SSHShellListener from the list of listeners.
    void
    write(byte[] bytesIO)
    Writes the given byte array to the output stream.
    void
    write(String commandIO)
    Writes the commandIO to the output stream of the SSHSocket.
    void
    writeLine(String commandIO)
    Writes the given command to the output stream of the SSHSocket followed by a new line character.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SSHSocket

      public SSHSocket()
  • Method Details

    • close

      public void close()
      Closes the SSHSocket and removes it from the sockets HashMap if it exists.
    • closeConnection

      public void closeConnection()
      Closes the connection of the SSHSocket by disconnecting the channel and session, if they are not null. This method is typically called when closing the SSHSocket or when explicitly closing the connection.
    • prepareChannel

      public void prepareChannel() throws com.jcraft.jsch.JSchException, IOException
      Prepares the channel for communication by initializing the output and input streams, and continuously reads input from the channel and passes it to the message listeners until the end of input is reached.
      Throws:
      com.jcraft.jsch.JSchException - if there is an error with the JSch library
      IOException - if there is an I/O error while preparing the channel
    • addListener

      public void addListener(SSHShellListener listenerIO)
      Adds a SSHShellListener to the list of listeners.
      Parameters:
      listenerIO - the SSHShellListener to be added
    • removeListener

      public void removeListener(SSHShellListener listenerIO)
      Removes the specified SSHShellListener from the list of listeners.
      Parameters:
      listenerIO - the SSHShellListener to be removed
    • write

      public void write(String commandIO) throws IOException
      Writes the commandIO to the output stream of the SSHSocket.
      Parameters:
      commandIO - the command to be written to the SSHSocket
      Throws:
      IOException - if an I/O error occurs while writing to the output stream
    • writeLine

      public void writeLine(String commandIO) throws IOException
      Writes the given command to the output stream of the SSHSocket followed by a new line character.
      Parameters:
      commandIO - the command to be written to the SSHSocket
      Throws:
      IOException
    • write

      public void write(byte[] bytesIO) throws IOException
      Writes the given byte array to the output stream.
      Parameters:
      bytesIO - the byte array to be written
      Throws:
      IOException - if an I/O error occurs while writing to the output stream
    • getHostPattern

      public static Pattern getHostPattern()
      Returns the host pattern used by the ProxMoxPool class.
      Returns:
      The host pattern as a java.util.regex.Pattern object.
    • getMatcher

      public static Matcher getMatcher(String lineIO)
      Retrieves the matcher object for a given input line using the host pattern.
      Parameters:
      lineIO - The input line for which to retrieve the matcher object.
      Returns:
      The matcher object that matches the input line against the host pattern.
    • load

      public void load()