Echos Protocol Version, Even When Not Supported
Currently in VncClient::frb_wait_for_version(), it simply echos the protocol version, even when it's unrecognized / not supported.
For example, the current version of RealVNC uses RFB 004.001. Thus far, this protocol hasn't been published (and I've heard that as of 2012, RFB 004.yyy won't have the protocol publicly released like the RFB 003.yyy series was.) Simply returning RFB 004.001 doesn't work, because the server never sends anything after the client sends ClientInit - most likely in this new version ClientInit requires something more to be sent than in prior versions.
As a work around, I have a few lines in VncClient::frb_wait_for_version() commented out and replaced with this:
write("RFB 003.008\n"); _proto_hi_version = 3; _proto_lo_version = 8;
A better solution would be to check what you're given, and if it's recognized, echo that, and if it's not, echo RFB 003.008\n. (If I get around to doing this myself, I'll make a pull request.)
here's my version of the else block:
else
{
char version_hi[] = { r[4] != '0' ? r[4] : (r[5] != '0' ? r[5] : r[6]), 0 };
char version_lo[] = { r[8] != '0' ? r[8] : (r[9] != '0' ? r[9] : r[10]), 0 };
_proto_hi_version = atoi(version_hi);
_proto_lo_version = atoi(version_lo);
if (_proto_hi_version > 3 || (_proto_hi_version == 3 && _proto_lo_version > 8))
{
//respond with 3.8
_proto_hi_version = 3;
_proto_lo_version = 8;
std::string version = "RFB 003.008";
write(&*version.begin(), &*version.begin() + 12);
}
else
{
// Simply respond with the same protocol version as we've got from server.
write(&*r.begin(), &*r.begin() + 12);
}
eat(12);
if (_proto_hi_version == 3 && _proto_lo_version < 7)
_state = vnc_waiting_for_security_server;
else
_state = vnc_waiting_for_security_handshake;
}