Class SSHSocket
java.lang.Object
de.bytestore.hostinger.process.entity.console.ssh.SSHSocket
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(SSHShellListener listenerIO) Adds a SSHShellListener to the list of listeners.voidclose()Closes the SSHSocket and removes it from the sockets HashMap if it exists.voidCloses the connection of the SSHSocket by disconnecting the channel and session, if they are not null.static PatternReturns the host pattern used by the ProxMoxPool class.static MatchergetMatcher(String lineIO) Retrieves the matcher object for a given input line using the host pattern.voidload()voidPrepares 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.voidremoveListener(SSHShellListener listenerIO) Removes the specified SSHShellListener from the list of listeners.voidwrite(byte[] bytesIO) Writes the given byte array to the output stream.voidWrites the commandIO to the output stream of the SSHSocket.voidWrites the given command to the output stream of the SSHSocket followed by a new line character.
-
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
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 libraryIOException- if there is an I/O error while preparing the channel
-
addListener
Adds a SSHShellListener to the list of listeners.- Parameters:
listenerIO- the SSHShellListener to be added
-
removeListener
Removes the specified SSHShellListener from the list of listeners.- Parameters:
listenerIO- the SSHShellListener to be removed
-
write
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
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
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
Returns the host pattern used by the ProxMoxPool class.- Returns:
- The host pattern as a java.util.regex.Pattern object.
-
getMatcher
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()
-