mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-622: Increase size of instruction queue within FailoverGuacamoleSocket. Allow limit to be overridden.
Some protocols, in particular SSH and telnet, may send a decent amount of data before the connection status is known.
This commit is contained in:
@@ -49,11 +49,10 @@ public class FailoverGuacamoleSocket implements GuacamoleSocket {
|
|||||||
LoggerFactory.getLogger(FailoverGuacamoleSocket.class);
|
LoggerFactory.getLogger(FailoverGuacamoleSocket.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of characters of Guacamole instruction data to store
|
* The default maximum number of characters of Guacamole instruction data
|
||||||
* within the instruction queue while searching for errors. Once this limit
|
* to store if no explicit limit is provided.
|
||||||
* is exceeded, the connection is assumed to be successful.
|
|
||||||
*/
|
*/
|
||||||
private static final int INSTRUCTION_QUEUE_LIMIT = 2048;
|
private static final int DEFAULT_INSTRUCTION_QUEUE_LIMIT = 131072;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The wrapped socket being used.
|
* The wrapped socket being used.
|
||||||
@@ -131,9 +130,11 @@ public class FailoverGuacamoleSocket implements GuacamoleSocket {
|
|||||||
/**
|
/**
|
||||||
* Creates a new FailoverGuacamoleSocket which reads Guacamole instructions
|
* Creates a new FailoverGuacamoleSocket which reads Guacamole instructions
|
||||||
* from the given socket, searching for errors from the upstream remote
|
* from the given socket, searching for errors from the upstream remote
|
||||||
* desktop. If an upstream error is encountered, it is thrown as a
|
* desktop until the given instruction queue limit is reached. If an
|
||||||
|
* upstream error is encountered, it is thrown as a
|
||||||
* GuacamoleUpstreamException. This constructor will block until an error
|
* GuacamoleUpstreamException. This constructor will block until an error
|
||||||
* is encountered, or until the connection appears to have been successful.
|
* is encountered, until insufficient space remains in the instruction
|
||||||
|
* queue, or until the connection appears to have been successful.
|
||||||
* Once the FailoverGuacamoleSocket has been created, all reads, writes,
|
* Once the FailoverGuacamoleSocket has been created, all reads, writes,
|
||||||
* etc. will be delegated to the provided socket.
|
* etc. will be delegated to the provided socket.
|
||||||
*
|
*
|
||||||
@@ -141,6 +142,11 @@ public class FailoverGuacamoleSocket implements GuacamoleSocket {
|
|||||||
* The GuacamoleSocket of the Guacamole connection this
|
* The GuacamoleSocket of the Guacamole connection this
|
||||||
* FailoverGuacamoleSocket should handle.
|
* FailoverGuacamoleSocket should handle.
|
||||||
*
|
*
|
||||||
|
* @param instructionQueueLimit
|
||||||
|
* The maximum number of characters of Guacamole instruction data to
|
||||||
|
* store within the instruction queue while searching for errors. Once
|
||||||
|
* this limit is exceeded, the connection is assumed to be successful.
|
||||||
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs while reading data from the provided socket.
|
* If an error occurs while reading data from the provided socket.
|
||||||
*
|
*
|
||||||
@@ -148,7 +154,8 @@ public class FailoverGuacamoleSocket implements GuacamoleSocket {
|
|||||||
* If the connection to guacd succeeded, but an error occurred while
|
* If the connection to guacd succeeded, but an error occurred while
|
||||||
* connecting to the remote desktop.
|
* connecting to the remote desktop.
|
||||||
*/
|
*/
|
||||||
public FailoverGuacamoleSocket(GuacamoleSocket socket)
|
public FailoverGuacamoleSocket(GuacamoleSocket socket,
|
||||||
|
final int instructionQueueLimit)
|
||||||
throws GuacamoleException, GuacamoleUpstreamException {
|
throws GuacamoleException, GuacamoleUpstreamException {
|
||||||
|
|
||||||
int totalQueueSize = 0;
|
int totalQueueSize = 0;
|
||||||
@@ -177,7 +184,7 @@ public class FailoverGuacamoleSocket implements GuacamoleSocket {
|
|||||||
// Otherwise, track total data parsed, and assume connection is
|
// Otherwise, track total data parsed, and assume connection is
|
||||||
// successful if no error encountered within reasonable space
|
// successful if no error encountered within reasonable space
|
||||||
totalQueueSize += instruction.toString().length();
|
totalQueueSize += instruction.toString().length();
|
||||||
if (totalQueueSize >= INSTRUCTION_QUEUE_LIMIT)
|
if (totalQueueSize >= instructionQueueLimit)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -186,6 +193,33 @@ public class FailoverGuacamoleSocket implements GuacamoleSocket {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new FailoverGuacamoleSocket which reads Guacamole instructions
|
||||||
|
* from the given socket, searching for errors from the upstream remote
|
||||||
|
* desktop until a maximum of 128KB of instruction data has been queued. If
|
||||||
|
* an upstream error is encountered, it is thrown as a
|
||||||
|
* GuacamoleUpstreamException. This constructor will block until an error
|
||||||
|
* is encountered, until insufficient space remains in the instruction
|
||||||
|
* queue, or until the connection appears to have been successful.
|
||||||
|
* Once the FailoverGuacamoleSocket has been created, all reads, writes,
|
||||||
|
* etc. will be delegated to the provided socket.
|
||||||
|
*
|
||||||
|
* @param socket
|
||||||
|
* The GuacamoleSocket of the Guacamole connection this
|
||||||
|
* FailoverGuacamoleSocket should handle.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while reading data from the provided socket.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleUpstreamException
|
||||||
|
* If the connection to guacd succeeded, but an error occurred while
|
||||||
|
* connecting to the remote desktop.
|
||||||
|
*/
|
||||||
|
public FailoverGuacamoleSocket(GuacamoleSocket socket)
|
||||||
|
throws GuacamoleException, GuacamoleUpstreamException {
|
||||||
|
this(socket, DEFAULT_INSTRUCTION_QUEUE_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GuacamoleReader which reads instructions from the queue populated when
|
* GuacamoleReader which reads instructions from the queue populated when
|
||||||
* the FailoverGuacamoleSocket was constructed. Once the queue has been
|
* the FailoverGuacamoleSocket was constructed. Once the queue has been
|
||||||
|
Reference in New Issue
Block a user