mike-jumper commented on a change in pull request #219: GUACAMOLE-422: Add
timezone to client handshake
URL: https://github.com/apache/guacamole-server/pull/219#discussion_r279173096
##########
File path: src/libguac/user-handshake.c
##########
@@ -286,11 +230,78 @@ static int guac_user_start(guac_parser* parser,
guac_user* user,
}
+/**
+ * This function loops through the received instructions during the handshake
+ * with the client attempting to join the connection, and runs the handlers
+ * for each of the opcodes, ending when the connect instruction is received.
+ * Returns zero if the handshake completes successfully with the connect
opcode,
+ * or a non-zero value if an error occurs.
+ *
+ * @param user
+ * The guac_user attempting to join the connection.
+ *
+ * @param parser
+ * The parser used to examine the received data.
+ *
+ * @param usec_timeout
+ * The timeout, in microseconds, for reading the instructions.
+ *
+ * @return
+ * Zero if the handshake completes successfully with the connect opcode,
+ * or non-zero if an error occurs.
+ */
+static int __guac_user_handshake(guac_user* user, guac_parser* parser,
+ int usec_timeout) {
+
+ guac_socket* socket = user->socket;
+
+ /* Handle each of the opcodes. */
+ while (guac_parser_read(parser, socket, usec_timeout) == 0) {
+
+ /* If we receive the connect opcode, we're done. */
+ if (strcmp(parser->opcode, "connect") == 0)
+ return 0;
+
+ guac_user_log(user, GUAC_LOG_DEBUG, "Processing instruction: %s",
+ parser->opcode);
+
+ /* Run instruction handler for opcode with arguments. */
+ if (__guac_user_call_opcode_handler(__guac_handshake_handler_map, user,
+ parser->opcode, parser->argc, parser->argv)) {
+
+ guac_user_log_handshake_failure(user);
+ guac_user_log_guac_error(user, GUAC_LOG_DEBUG,
+ "Error handling instruction during handshake.");
+ guac_user_log(user, GUAC_LOG_DEBUG, "Failed opcode: %s",
+ parser->opcode);
+
+ guac_parser_free(parser);
+ return 1;
+
+ }
+
+ }
+
+ /* If we get here it's because we never got the connect instruction. */
+ guac_user_log(user, GUAC_LOG_ERROR,
+ "Handshake failed, \"connect\" instruction was not received.");
+ return 1;
+}
+
int guac_user_handle_connection(guac_user* user, int usec_timeout) {
guac_socket* socket = user->socket;
guac_client* client = user->client;
-
+
+ user->info.audio_mimetypes = NULL;
+ user->info.image_mimetypes = NULL;
+ user->info.video_mimetypes = NULL;
+ user->info.timezone = NULL;
+
+ /* Count number of arguments. */
+ int numArgs;
Review comment:
Per existing style here and http://guacamole.apache.org/guac-style/#naming,
please use `lowercase_with_underscores` rather than `headlessCamelCase` for
variable names in C.
The `headlessCamelCase` convention is used only for the Java and JavaScript
of parts of Guacamole
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services