nvazquez commented on code in PR #7015:
URL: https://github.com/apache/cloudstack/pull/7015#discussion_r1055918022


##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVncClient.java:
##########
@@ -137,18 +145,80 @@ public void run() {
 
     /**
      * Authenticate to VNC server when not using websockets
+     *
+     * Since we are supporting the 3.8 version of the RFB protocol, there are 
changes on the stages:
+     * 1. Handshake:
+     *    1.a. Protocol version
+     *    1.b. Security types
+     * 2. Security types
+     * 3. Initialisation
+     *
+     * Reference: 
https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#7protocol-messages
      * @throws IOException
      */
     private void authenticateToVNCServer() throws IOException {
-        if (!client.isVncOverWebSocketConnection()) {
+        if (client.isVncOverWebSocketConnection()) {
+            return;
+        }
+
+        if (client.isVncOverTunnel()) {
             String ver = client.handshake();
             session.getRemote().sendBytes(ByteBuffer.wrap(ver.getBytes(), 0, 
ver.length()));
 
-            byte[] b = client.authenticate(getClientHostPassword());
+            byte[] b = client.authenticateTunnel(getClientHostPassword());
             session.getRemote().sendBytes(ByteBuffer.wrap(b, 0, 4));
+        } else {
+            ByteBuffer verStr = client.handshakeProtocolVersion();
+            sendMessageToVNCClient(verStr.array(), 12);
+
+            int secType = client.handshakeSecurityType();
+            byte[] numberTypesToClient = new byte[] { 1, (byte) secType };
+            sendMessageToVNCClient(numberTypesToClient, 2);
+
+            client.processHandshakeSecurityType(secType, 
getClientHostPassword(),
+                    getClientHostAddress(), getClientHostPort());
+
+            byte[] securityResultToClient = new byte[] { 0, 0, 0, 0 };
+            sendMessageToVNCClient(securityResultToClient, 4);
+            client.setWaitForNoVnc(true);
+
+            while (client.isWaitForNoVnc()) {
+                s_logger.debug("Waiting");
+            }

Review Comment:
   Done, thanks



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to