From 95533c579ef84719a215b74798fe10412b786a3e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 13 Feb 2017 13:58:10 +0100 Subject: [PATCH] Better selection of auth type If no authentication is required then we should pick the None option to avoid bothering the user. --- core/rfb.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/core/rfb.js b/core/rfb.js index c6e19731..b8ff7820 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -792,25 +792,20 @@ "Security failure: " + reason); } - this._rfb_auth_scheme = 0; var types = this._sock.rQshiftBytes(num_types); Util.Debug("Server security types: " + types); - for (var i = 0; i < types.length; i++) { - switch (types[i]) { - case 1: // None - case 2: // VNC Authentication - case 16: // Tight - case 22: // XVP - if (types[i] > this._rfb_auth_scheme) { - this._rfb_auth_scheme = types[i]; - } - break; - default: - break; - } - } - if (this._rfb_auth_scheme === 0) { + // Look for each auth in preferred order + this._rfb_auth_scheme = 0; + if (types.indexOf(1) !== -1) { + this._rfb_auth_scheme = 1; // None + } else if (types.indexOf(22) !== -1) { + this._rfb_auth_scheme = 22; // XVP + } else if (types.indexOf(16) !== -1) { + this._rfb_auth_scheme = 16; // Tight + } else if (types.indexOf(2) !== -1) { + this._rfb_auth_scheme = 2; // VNC Auth + } else { return this._fail("Unsupported server", "Unsupported security types: " + types); }