diff options
author | Pierre Ossman <ossman@cendio.se> | 2017-02-13 13:58:10 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2017-02-13 13:58:10 +0100 |
commit | 95533c579ef84719a215b74798fe10412b786a3e (patch) | |
tree | 5e381d3dccd22ee2762851706801d132400084b8 | |
parent | bd7d89e7cc1d3a39ffbec7c9c678b86752f1bc82 (diff) | |
download | novnc-95533c579ef84719a215b74798fe10412b786a3e.tar.gz |
Better selection of auth type
If no authentication is required then we should pick the None
option to avoid bothering the user.
-rw-r--r-- | core/rfb.js | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/core/rfb.js b/core/rfb.js index c6e1973..b8ff782 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); } |