You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by GitBox <gi...@apache.org> on 2021/05/24 09:25:52 UTC
[GitHub] [guacamole-client] mike-jumper opened a new pull request #611: GUACAMOLE-1048: Support server control commands during handshake
mike-jumper opened a new pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611
This change builds off #500, contributed by @holograph, refactoring the additional "error" and "disconnect" instruction handling to:
* Leverage a new `toException()` function on `GuacamoleStatus` that converts a status code into its corresponding exception.
* Throw `GuacamoleConnectionClosedException` for disconnects (rather than `GuacamoleServerException`).
No new exception class is defined in this case, as the existing equivalency between status codes and corresponding exceptions is used instead.
@holograph, I understand you're no longer working at the company that needed and proposed the original changes, but feel free to look over this and let us know what you think.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [guacamole-client] mike-jumper commented on a change in pull request #611: GUACAMOLE-1048: Support server control commands during handshake
Posted by GitBox <gi...@apache.org>.
mike-jumper commented on a change in pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611#discussion_r637830195
##########
File path: guacamole-common/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
##########
@@ -59,17 +68,87 @@
*/
private GuacamoleProtocolVersion protocolVersion =
GuacamoleProtocolVersion.VERSION_1_0_0;
-
+
+ /**
+ * Parses the given "error" instruction, throwing a GuacamoleException that
+ * corresponds to its status code and message.
+ *
+ * @param instruction
+ * The "error" instruction to parse.
+ *
+ * @throws GuacamoleException
+ * A GuacamoleException that corresponds to the status code and message
+ * present within the given "error" instruction.
+ */
+ private static void handleReceivedError(GuacamoleInstruction instruction)
+ throws GuacamoleException {
+
+ GuacamoleStatus status;
+
+ // Consider all error instructions without a corresponding status code
+ // to be server errors
+ List<String> args = instruction.getArgs();
+ if (args.size() < 2) {
+ logger.debug("Received \"error\" instruction without status code.");
+ status = GuacamoleStatus.SERVER_ERROR;
+ }
+
+ else {
+
+ // Parse the status code from the received error instruction
+ int statusCode;
+ try {
+ statusCode = Integer.parseInt(args.get(1));
+ }
+ catch (NumberFormatException e) {
+ logger.debug("Received \"error\" instruction with non-numeric status code.", e);
+ return;
Review comment:
Good catch! That's copy-pasta. That `return` definitely should not be there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [guacamole-client] holograph commented on a change in pull request #611: GUACAMOLE-1048: Support server control commands during handshake
Posted by GitBox <gi...@apache.org>.
holograph commented on a change in pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611#discussion_r637823743
##########
File path: guacamole-common/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
##########
@@ -59,17 +68,87 @@
*/
private GuacamoleProtocolVersion protocolVersion =
GuacamoleProtocolVersion.VERSION_1_0_0;
-
+
+ /**
+ * Parses the given "error" instruction, throwing a GuacamoleException that
+ * corresponds to its status code and message.
+ *
+ * @param instruction
+ * The "error" instruction to parse.
+ *
+ * @throws GuacamoleException
+ * A GuacamoleException that corresponds to the status code and message
+ * present within the given "error" instruction.
+ */
+ private static void handleReceivedError(GuacamoleInstruction instruction)
+ throws GuacamoleException {
+
+ GuacamoleStatus status;
+
+ // Consider all error instructions without a corresponding status code
+ // to be server errors
+ List<String> args = instruction.getArgs();
+ if (args.size() < 2) {
+ logger.debug("Received \"error\" instruction without status code.");
+ status = GuacamoleStatus.SERVER_ERROR;
+ }
+
+ else {
+
+ // Parse the status code from the received error instruction
+ int statusCode;
+ try {
+ statusCode = Integer.parseInt(args.get(1));
+ }
+ catch (NumberFormatException e) {
+ logger.debug("Received \"error\" instruction with non-numeric status code.", e);
+ return;
Review comment:
Are you sure ignoring the instruction is the right thing to do here? This arguably represents a completely corrupt connection that should be aborted outright. Just my opinion, of course...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [guacamole-client] mike-jumper commented on a change in pull request #611: GUACAMOLE-1048: Support server control commands during handshake
Posted by GitBox <gi...@apache.org>.
mike-jumper commented on a change in pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611#discussion_r639091983
##########
File path: guacamole-common/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
##########
@@ -59,17 +68,83 @@
*/
private GuacamoleProtocolVersion protocolVersion =
GuacamoleProtocolVersion.VERSION_1_0_0;
-
+
+ /**
+ * Parses the given "error" instruction, throwing a GuacamoleException that
+ * corresponds to its status code and message.
+ *
+ * @param instruction
+ * The "error" instruction to parse.
+ *
+ * @throws GuacamoleException
+ * A GuacamoleException that corresponds to the status code and message
+ * present within the given "error" instruction.
+ */
+ private static void handleReceivedError(GuacamoleInstruction instruction)
+ throws GuacamoleException {
+
+ // Provide reasonable default error message for invalid "error"
+ // instructions that fail to provide one
+ String message = "Internal error within guacd / protocol handling.";
+
+ // Consider all error instructions without a corresponding status code
+ // to be server errors
+ GuacamoleStatus status = GuacamoleStatus.SERVER_ERROR;
+
+ // Parse human-readable message from "error" instruction, warning if no
+ // message was given
+ List<String> args = instruction.getArgs();
+ if (args.size() >= 1)
+ message = args.get(0);
+ else
+ logger.debug("Received \"error\" instruction no corresponding message.");
Review comment:
Whoops. I've updated the message to be less caveman and rebased.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [guacamole-client] necouchman commented on a change in pull request #611: GUACAMOLE-1048: Support server control commands during handshake
Posted by GitBox <gi...@apache.org>.
necouchman commented on a change in pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611#discussion_r638410276
##########
File path: guacamole-common/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
##########
@@ -59,17 +68,83 @@
*/
private GuacamoleProtocolVersion protocolVersion =
GuacamoleProtocolVersion.VERSION_1_0_0;
-
+
+ /**
+ * Parses the given "error" instruction, throwing a GuacamoleException that
+ * corresponds to its status code and message.
+ *
+ * @param instruction
+ * The "error" instruction to parse.
+ *
+ * @throws GuacamoleException
+ * A GuacamoleException that corresponds to the status code and message
+ * present within the given "error" instruction.
+ */
+ private static void handleReceivedError(GuacamoleInstruction instruction)
+ throws GuacamoleException {
+
+ // Provide reasonable default error message for invalid "error"
+ // instructions that fail to provide one
+ String message = "Internal error within guacd / protocol handling.";
+
+ // Consider all error instructions without a corresponding status code
+ // to be server errors
+ GuacamoleStatus status = GuacamoleStatus.SERVER_ERROR;
+
+ // Parse human-readable message from "error" instruction, warning if no
+ // message was given
+ List<String> args = instruction.getArgs();
+ if (args.size() >= 1)
+ message = args.get(0);
+ else
+ logger.debug("Received \"error\" instruction no corresponding message.");
Review comment:
instruction _with_ no corresponding message?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [guacamole-client] holograph commented on a change in pull request #611: GUACAMOLE-1048: Support server control commands during handshake
Posted by GitBox <gi...@apache.org>.
holograph commented on a change in pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611#discussion_r637826005
##########
File path: guacamole-common/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
##########
@@ -59,17 +68,87 @@
*/
private GuacamoleProtocolVersion protocolVersion =
GuacamoleProtocolVersion.VERSION_1_0_0;
-
+
+ /**
+ * Parses the given "error" instruction, throwing a GuacamoleException that
+ * corresponds to its status code and message.
+ *
+ * @param instruction
+ * The "error" instruction to parse.
+ *
+ * @throws GuacamoleException
+ * A GuacamoleException that corresponds to the status code and message
+ * present within the given "error" instruction.
+ */
+ private static void handleReceivedError(GuacamoleInstruction instruction)
+ throws GuacamoleException {
+
+ GuacamoleStatus status;
+
+ // Consider all error instructions without a corresponding status code
+ // to be server errors
+ List<String> args = instruction.getArgs();
+ if (args.size() < 2) {
+ logger.debug("Received \"error\" instruction without status code.");
+ status = GuacamoleStatus.SERVER_ERROR;
+ }
+
+ else {
+
+ // Parse the status code from the received error instruction
+ int statusCode;
+ try {
+ statusCode = Integer.parseInt(args.get(1));
+ }
+ catch (NumberFormatException e) {
+ logger.debug("Received \"error\" instruction with non-numeric status code.", e);
+ return;
Review comment:
This should probably be included in the release notes though (or added explicitly to the exception signature) to reflect the API refinement.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [guacamole-client] necouchman merged pull request #611: GUACAMOLE-1048: Support server control commands during handshake
Posted by GitBox <gi...@apache.org>.
necouchman merged pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [guacamole-client] mike-jumper commented on a change in pull request #611: GUACAMOLE-1048: Support server control commands during handshake
Posted by GitBox <gi...@apache.org>.
mike-jumper commented on a change in pull request #611:
URL: https://github.com/apache/guacamole-client/pull/611#discussion_r638329067
##########
File path: guacamole-common/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
##########
@@ -59,17 +68,87 @@
*/
private GuacamoleProtocolVersion protocolVersion =
GuacamoleProtocolVersion.VERSION_1_0_0;
-
+
+ /**
+ * Parses the given "error" instruction, throwing a GuacamoleException that
+ * corresponds to its status code and message.
+ *
+ * @param instruction
+ * The "error" instruction to parse.
+ *
+ * @throws GuacamoleException
+ * A GuacamoleException that corresponds to the status code and message
+ * present within the given "error" instruction.
+ */
+ private static void handleReceivedError(GuacamoleInstruction instruction)
+ throws GuacamoleException {
+
+ GuacamoleStatus status;
+
+ // Consider all error instructions without a corresponding status code
+ // to be server errors
+ List<String> args = instruction.getArgs();
+ if (args.size() < 2) {
+ logger.debug("Received \"error\" instruction without status code.");
+ status = GuacamoleStatus.SERVER_ERROR;
+ }
+
+ else {
+
+ // Parse the status code from the received error instruction
+ int statusCode;
+ try {
+ statusCode = Integer.parseInt(args.get(1));
+ }
+ catch (NumberFormatException e) {
+ logger.debug("Received \"error\" instruction with non-numeric status code.", e);
+ return;
Review comment:
Corrected via refactor and rebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org