Handle connection init loop at the top
Avoid the mess of having lots of functions call back to _initMsg() just because they might be able to continue right away. Instead loop at the top level until we're either done, or we need more data.
This commit is contained in:
parent
05d68e118d
commit
084030fe68
27
core/rfb.js
27
core/rfb.js
|
@ -922,8 +922,15 @@ export default class RFB extends EventTargetMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'connecting':
|
||||||
|
while (this._rfbConnectionState === 'connecting') {
|
||||||
|
if (!this._initMsg()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
this._initMsg();
|
Log.Error("Got data while in an invalid state");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1342,7 +1349,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
this._rfbInitState = "SecurityReason";
|
this._rfbInitState = "SecurityReason";
|
||||||
this._securityContext = "no security types";
|
this._securityContext = "no security types";
|
||||||
this._securityStatus = 1;
|
this._securityStatus = 1;
|
||||||
return this._initMsg();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const types = this._sock.rQshiftBytes(numTypes);
|
const types = this._sock.rQshiftBytes(numTypes);
|
||||||
|
@ -1377,14 +1384,14 @@ export default class RFB extends EventTargetMixin {
|
||||||
this._rfbInitState = "SecurityReason";
|
this._rfbInitState = "SecurityReason";
|
||||||
this._securityContext = "authentication scheme";
|
this._securityContext = "authentication scheme";
|
||||||
this._securityStatus = 1;
|
this._securityStatus = 1;
|
||||||
return this._initMsg();
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._rfbInitState = 'Authentication';
|
this._rfbInitState = 'Authentication';
|
||||||
Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
|
Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
|
||||||
|
|
||||||
return this._initMsg(); // jump to authentication
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleSecurityReason() {
|
_handleSecurityReason() {
|
||||||
|
@ -1773,10 +1780,10 @@ export default class RFB extends EventTargetMixin {
|
||||||
return true;
|
return true;
|
||||||
case 'STDVVNCAUTH_': // VNC auth
|
case 'STDVVNCAUTH_': // VNC auth
|
||||||
this._rfbAuthScheme = 2;
|
this._rfbAuthScheme = 2;
|
||||||
return this._initMsg();
|
return true;
|
||||||
case 'TGHTULGNAUTH': // UNIX auth
|
case 'TGHTULGNAUTH': // UNIX auth
|
||||||
this._rfbAuthScheme = 129;
|
this._rfbAuthScheme = 129;
|
||||||
return this._initMsg();
|
return true;
|
||||||
default:
|
default:
|
||||||
return this._fail("Unsupported tiny auth scheme " +
|
return this._fail("Unsupported tiny auth scheme " +
|
||||||
"(scheme: " + authType + ")");
|
"(scheme: " + authType + ")");
|
||||||
|
@ -1813,7 +1820,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.dispatchEvent(new CustomEvent('securityresult'));
|
this.dispatchEvent(new CustomEvent('securityresult'));
|
||||||
this._rfbInitState = "SecurityResult";
|
this._rfbInitState = "SecurityResult";
|
||||||
this._initMsg();
|
return true;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this._rfbRSAAESAuthenticationState.removeEventListener(
|
this._rfbRSAAESAuthenticationState.removeEventListener(
|
||||||
"serververification", this._eventHandlers.handleRSAAESServerVerification);
|
"serververification", this._eventHandlers.handleRSAAESServerVerification);
|
||||||
|
@ -1833,7 +1840,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this._rfbInitState = 'ClientInitialisation';
|
this._rfbInitState = 'ClientInitialisation';
|
||||||
return this._initMsg();
|
return true;
|
||||||
|
|
||||||
case 22: // XVP auth
|
case 22: // XVP auth
|
||||||
return this._negotiateXvpAuth();
|
return this._negotiateXvpAuth();
|
||||||
|
@ -1870,13 +1877,13 @@ export default class RFB extends EventTargetMixin {
|
||||||
if (status === 0) { // OK
|
if (status === 0) { // OK
|
||||||
this._rfbInitState = 'ClientInitialisation';
|
this._rfbInitState = 'ClientInitialisation';
|
||||||
Log.Debug('Authentication OK');
|
Log.Debug('Authentication OK');
|
||||||
return this._initMsg();
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (this._rfbVersion >= 3.8) {
|
if (this._rfbVersion >= 3.8) {
|
||||||
this._rfbInitState = "SecurityReason";
|
this._rfbInitState = "SecurityReason";
|
||||||
this._securityContext = "security result";
|
this._securityContext = "security result";
|
||||||
this._securityStatus = status;
|
this._securityStatus = status;
|
||||||
return this._initMsg();
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.dispatchEvent(new CustomEvent(
|
this.dispatchEvent(new CustomEvent(
|
||||||
"securityfailure",
|
"securityfailure",
|
||||||
|
|
Loading…
Reference in New Issue