You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/12/22 15:08:26 UTC

[GitHub] [cloudstack] slavkap commented on a diff in pull request #7015: Secure KVM VNC Console Access Using the CA Framework

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


##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/vnc/NoVncClient.java:
##########
@@ -80,7 +78,7 @@ public void connectTo(String host, int port, String path, String session, boolea
         setTunnelSocketStreams();
     }
 
-    public void connectTo(String host, int port) throws UnknownHostException, IOException {
+    public void connectTo(String host, int port) {
         // Connect to server
         s_logger.info("Connecting to VNC server " + host + ":" + port + "...");

Review Comment:
   ```suggestion
           s_logger.info(String.format("Connecting to VNC server %s:%s", host, port));
   ```
   a few suggestions 



##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/vnc/NoVncClient.java:
##########
@@ -143,16 +141,15 @@ public String handshake() throws IOException {
 
         // Server should use RFB protocol 3.x
         if (!rfbProtocol.contains(RfbConstants.RFB_PROTOCOL_VERSION_MAJOR)) {
-            s_logger.error("Cannot handshake with VNC server. Unsupported protocol version: \"" + rfbProtocol + "\".");
-            throw new RuntimeException(
-                    "Cannot handshake with VNC server. Unsupported protocol version: \"" + rfbProtocol + "\".");
+            String msg = "Cannot handshake with VNC server. Unsupported protocol version: \"" + rfbProtocol + "\".";

Review Comment:
   ```suggestion
               String msg = String.format("Cannot handshake with VNC server. Unsupported protocol version: [%s]" , rfbProtocol);
   ```



##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/vnc/NoVncClient.java:
##########
@@ -219,23 +216,27 @@ private void doVncAuth(DataInputStream in, DataOutputStream out, String password
         // Read security result
         int authResult = in.readInt();
 
+        String msg;
         switch (authResult) {
             case RfbConstants.VNC_AUTH_OK: {
                 // Nothing to do
                 break;
             }
 
             case RfbConstants.VNC_AUTH_TOO_MANY:
-                s_logger.error("Connection to VNC server failed: too many wrong attempts.");
-                throw new RuntimeException("Connection to VNC server failed: too many wrong attempts.");
+                msg = "Connection to VNC server failed: too many wrong attempts.";
+                s_logger.error(msg);
+                throw new RuntimeException(msg);
 
             case RfbConstants.VNC_AUTH_FAILED:
-                s_logger.error("Connection to VNC server failed: wrong password.");
-                throw new RuntimeException("Connection to VNC server failed: wrong password.");
+                msg = "Connection to VNC server failed: wrong password.";
+                s_logger.error(msg);
+                throw new RuntimeException(msg);
 
             default:
-                s_logger.error("Connection to VNC server failed, reason code: " + authResult);
-                throw new RuntimeException("Connection to VNC server failed, reason code: " + authResult);
+                msg = "Connection to VNC server failed, reason code: " + authResult;

Review Comment:
   ```suggestion
                   msg = String.format("Connection to VNC server failed, reason code: %s", authResult);
   ```



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org