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_r278347446
 
 

 ##########
 File path: src/libguac/user-handshake.c
 ##########
 @@ -286,11 +230,72 @@ 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 handling opcode during handshake.");
+            guac_user_log(user, GUAC_LOG_DEBUG, "Failed opcode: %s",
+                    parser->opcode);
+
+            guac_parser_free(parser);
+            return 1;
+            
+        }
+        
+    }
+    
+    /* If we get here something has gone wrong. */
 
 Review comment:
   Is that "something" worth identifying and logging? ;)
   
   It looks like we reach this point strictly when the read fails, with the 
reason for that failure being within `guac_error`.

----------------------------------------------------------------
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

Reply via email to