MCPcopy Create free account
hub / github.com/apache/cloudstack / _negotiateProtocolVersion

Method _negotiateProtocolVersion

systemvm/agent/noVNC/core/rfb.js:1653–1704  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1651 // Message handlers
1652
1653 _negotiateProtocolVersion() {
1654 if (this._sock.rQwait("version", 12)) {
1655 return false;
1656 }
1657
1658 const sversion = this._sock.rQshiftStr(12).substr(4, 7);
1659 Log.Info("Server ProtocolVersion: " + sversion);
1660 let isRepeater = 0;
1661 switch (sversion) {
1662 case "000.000": // UltraVNC repeater
1663 isRepeater = 1;
1664 break;
1665 case "003.003":
1666 case "003.006": // UltraVNC
1667 this._rfbVersion = 3.3;
1668 break;
1669 case "003.007":
1670 this._rfbVersion = 3.7;
1671 break;
1672 case "003.008":
1673 case "003.889": // Apple Remote Desktop
1674 case "004.000": // Intel AMT KVM
1675 case "004.001": // RealVNC 4.6
1676 case "005.000": // RealVNC 5.3
1677 this._rfbVersion = 3.8;
1678 break;
1679 default:
1680 return this._fail("Invalid server version " + sversion);
1681 }
1682
1683 if (isRepeater) {
1684 let repeaterID = "ID:" + this._repeaterID;
1685 while (repeaterID.length < 250) {
1686 repeaterID += "\0";
1687 }
1688 this._sock.sQpushString(repeaterID);
1689 this._sock.flush();
1690 return true;
1691 }
1692
1693 if (this._rfbVersion > this._rfbMaxVersion) {
1694 this._rfbVersion = this._rfbMaxVersion;
1695 }
1696
1697 const cversion = "00" + parseInt(this._rfbVersion, 10) +
1698 ".00" + ((this._rfbVersion * 10) % 10);
1699 this._sock.sQpushString("RFB " + cversion + "\n");
1700 this._sock.flush();
1701 Log.Debug('Sent ProtocolVersion: ' + cversion);
1702
1703 this._rfbInitState = 'Security';
1704 }
1705
1706 _isSupportedSecurityType(type) {
1707 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