Beispiel #1
0
//-------------------------------------------------------------------------------------
void ServerApp::hello(Network::Channel* pChannel, MemoryStream& s)
{
	std::string verInfo, scriptVerInfo, encryptedKey;

	s >> verInfo >> scriptVerInfo;
	s.readBlob(encryptedKey);

	char buf[MAX_BUF];
	std::string encryptedKey_str;

	if (encryptedKey.size() > 3 && encryptedKey.size() <= 65535)
	{
		for (int i = 0; i < (int)encryptedKey.size(); ++i)
		{
			memset(buf, 0, MAX_BUF);
			kbe_snprintf(buf, MAX_BUF / 2, "%02hhX ", (unsigned char)encryptedKey.data()[i]);
			encryptedKey_str += buf;
		}
	}
	else
	{
		encryptedKey = "";
		encryptedKey_str = "None";
	}

	INFO_MSG(fmt::format("ServerApp::onHello: verInfo={}, scriptVerInfo={}, encryptedKey={}, addr:{}\n", 
		verInfo, scriptVerInfo, encryptedKey_str, pChannel->c_str()));

	if(verInfo != KBEVersion::versionString())
		onVersionNotMatch(pChannel);
	else if(scriptVerInfo != KBEVersion::scriptVersionString())
		onScriptVersionNotMatch(pChannel);
	else
		onHello(pChannel, verInfo, scriptVerInfo, encryptedKey);
}
Beispiel #2
0
//-------------------------------------------------------------------------------------
void ServerApp::hello(Network::Channel* pChannel, MemoryStream& s)
{
	std::string verInfo, scriptVerInfo, encryptedKey;

	s >> verInfo >> scriptVerInfo;
	s.readBlob(encryptedKey);

	char buf[1024];

	if(encryptedKey.size() > 3)
	{
		char *c = buf;

		for (int i=0; i < (int)encryptedKey.size(); ++i)
		{
			c += sprintf(c, "%02hhX ", (unsigned char)encryptedKey.data()[i]);
		}

		c[-1] = '\0';
	}
	else
	{
		encryptedKey = "";
		sprintf(buf, "None");
		buf[4] = '\0';
	}

	INFO_MSG(fmt::format("ServerApp::onHello: verInfo={}, scriptVerInfo={}, encryptedKey={}, addr:{}\n", 
		verInfo, scriptVerInfo, buf, pChannel->c_str()));

	if(verInfo != KBEVersion::versionString())
		onVersionNotMatch(pChannel);
	else if(scriptVerInfo != KBEVersion::scriptVersionString())
		onScriptVersionNotMatch(pChannel);
	else
		onHello(pChannel, verInfo, scriptVerInfo, encryptedKey);
}