MCPcopy
hub / github.com/novnc/noVNC / _negotiateProtocolVersion

Method _negotiateProtocolVersion

core/rfb.js:1496–1547  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1494 // Message handlers
1495
1496 _negotiateProtocolVersion() {
1497 if (this._sock.rQwait("version", 12)) {
1498 return false;
1499 }
1500
1501 const sversion = this._sock.rQshiftStr(12).substr(4, 7);
1502 Log.Info("Server ProtocolVersion: " + sversion);
1503 let isRepeater = 0;
1504 switch (sversion) {
1505 case "000.000": // UltraVNC repeater
1506 isRepeater = 1;
1507 break;
1508 case "003.003":
1509 case "003.006": // UltraVNC
1510 this._rfbVersion = 3.3;
1511 break;
1512 case "003.007":
1513 this._rfbVersion = 3.7;
1514 break;
1515 case "003.008":
1516 case "003.889": // Apple Remote Desktop
1517 case "004.000": // Intel AMT KVM
1518 case "004.001": // RealVNC 4.6
1519 case "005.000": // RealVNC 5.3
1520 this._rfbVersion = 3.8;
1521 break;
1522 default:
1523 return this._fail("Invalid server version " + sversion);
1524 }
1525
1526 if (isRepeater) {
1527 let repeaterID = "ID:" + this._repeaterID;
1528 while (repeaterID.length < 250) {
1529 repeaterID += "\0";
1530 }
1531 this._sock.sQpushString(repeaterID);
1532 this._sock.flush();
1533 return true;
1534 }
1535
1536 if (this._rfbVersion > this._rfbMaxVersion) {
1537 this._rfbVersion = this._rfbMaxVersion;
1538 }
1539
1540 const cversion = "00" + parseInt(this._rfbVersion, 10) +
1541 ".00" + ((this._rfbVersion * 10) % 10);
1542 this._sock.sQpushString("RFB " + cversion + "\n");
1543 this._sock.flush();
1544 Log.Debug('Sent ProtocolVersion: ' + cversion);
1545
1546 this._rfbInitState = 'Security';
1547 }
1548
1549 _isSupportedSecurityType(type) {
1550 const clientTypes = [

Callers 1

_initMsgMethod · 0.95

Calls 5

_failMethod · 0.95
rQwaitMethod · 0.80
rQshiftStrMethod · 0.80
sQpushStringMethod · 0.80
flushMethod · 0.45

Tested by

no test coverage detected