Better selection of auth type

If no authentication is required then we should pick the None
option to avoid bothering the user.
This commit is contained in:
Pierre Ossman 2017-02-13 13:58:10 +01:00
parent bd7d89e7cc
commit 95533c579e
1 changed files with 11 additions and 16 deletions

View File

@ -792,25 +792,20 @@
"Security failure: " + reason); "Security failure: " + reason);
} }
this._rfb_auth_scheme = 0;
var types = this._sock.rQshiftBytes(num_types); var types = this._sock.rQshiftBytes(num_types);
Util.Debug("Server security types: " + 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", return this._fail("Unsupported server",
"Unsupported security types: " + types); "Unsupported security types: " + types);
} }