Add Login Session GUID Tracking Support

This commit is contained in:
AconiteX
2021-09-03 12:26:03 -04:00
parent 0d223b6524
commit 0187778dce
6 changed files with 71 additions and 2 deletions

View File

@@ -261,6 +261,7 @@ m_userPassword (ConfigClientGame::getLoginClientPassword()),
m_userIpAddress (),
m_centralServerName (),
m_pendingCentralServerName (),
m_guid (),
m_loginTokenLength (0),
m_userPort (0),
m_acceptSceneCommand (false),
@@ -466,6 +467,13 @@ void GameNetwork::setUserPassword (const std::string & newUserPassword)
s_instance->m_userPassword = newUserPassword;
}
//-------------------------------------------------------------------
void GameNetwork::setUserGuid(const std::string& newUserGuid)
{
s_instance->m_guid = newUserGuid;
}
//-----------------------------------------------------------------------
void GameNetwork::startScene(const std::string & sceneName, const NetworkId & objectId, const std::string & templateName, const Vector & startPosition, const float startYaw, const float timeInSeconds, bool disableSnapshot)
@@ -790,6 +798,14 @@ const std::string & GameNetwork::getUserPassword (void)
//-------------------------------------------------------------------
const std::string& GameNetwork::getUserGuid(void)
{
DEBUG_FATAL(s_instance == 0, ("GameNetwork not installed"));
return s_instance->m_guid;
}
//-------------------------------------------------------------------
const std::string & GameNetwork::getUserIpAddress (void)
{
DEBUG_FATAL(s_instance == 0, ("GameNetwork not installed"));

View File

@@ -70,6 +70,7 @@ public:
static const uint16 getLoginTokenLength ();
static const std::string & getUserName ();
static const std::string & getUserPassword ();
static const std::string & getUserGuid();
static const std::string & getUserIpAddress ();
static uint16 getUserPort ();
static const ConnectionServerConnection* getConnectionServerConnection();
@@ -95,6 +96,7 @@ public:
static void setSceneChannel ();
static void setUserName (const std::string & newUserName);
static void setUserPassword (const std::string & newUserPassword);
static void setUserGuid (const std::string& newUserGuid);
static void startScene (const std::string & sceneName,
const NetworkId & characterObjectId,
const std::string & characterTemplateName,
@@ -144,6 +146,7 @@ private:
std::string m_userIpAddress;
std::string m_centralServerName;
std::string m_pendingCentralServerName;
std::string m_guid;
uint16 m_loginTokenLength;
uint16 m_userPort;
bool m_acceptSceneCommand;

View File

@@ -65,8 +65,17 @@ void LoginConnection::onConnectionOpened()
if (CuiLoginManager::getSessionIdKey() && !ConfigClientGame::getEnableAdminLogin())
sendUserName = false;
LoginClientId id(sendUserName ? GameNetwork::getUserName() : "", GameNetwork::getUserPassword());
send(id, true);
if(!GameNetwork::getUserGuid().empty())
{
LoginClientId id(sendUserName ? GameNetwork::getUserName() : "", GameNetwork::getUserPassword(), GameNetwork::getUserGuid());
send(id, true);
}
else
{
LoginClientId id(sendUserName ? GameNetwork::getUserName() : "", GameNetwork::getUserPassword());
send(id, true);
}
#if PRODUCTION != 1
GenericValueTypeMessage< int > msg( "RequestExtendedClusterInfo", 0 );

View File

@@ -30,6 +30,21 @@ version(ConfigVersion ? ConfigVersion : NetworkVersionId) //-- todo production
//-----------------------------------------------------------------------
LoginClientId::LoginClientId(const std::string& newId, const std::string& newKey, const std::string& guidVal) :
GameNetworkMessage("LoginClientId"),
id(newId),
key(newKey),
version(NetworkVersionId),
guid(guidVal)
{
addVariable(id);
addVariable(key);
addVariable(version);
addVariable(guid);
}
//-----------------------------------------------------------------------
LoginClientId::LoginClientId(Archive::ReadIterator & source) :
GameNetworkMessage("LoginClientId"),
id(),

View File

@@ -22,15 +22,18 @@ class LoginClientId : public GameNetworkMessage
{
public:
LoginClientId(const std::string & newId, const std::string & newKey);
LoginClientId(const std::string & newId, const std::string & newKey, const std::string & guid);
LoginClientId(Archive::ReadIterator & source);
~LoginClientId();
const std::string & getId () const;
const std::string & getKey () const;
const std::string & getVersion () const;
const std::string & getGuid() const;
private:
Archive::AutoVariable<std::string> id;
Archive::AutoVariable<std::string> key;
Archive::AutoVariable<std::string> version;
Archive::AutoVariable<std::string> guid;
LoginClientId();
LoginClientId(const LoginClientId&);
@@ -60,6 +63,13 @@ inline const std::string & LoginClientId::getVersion() const
//-----------------------------------------------------------------------
inline const std::string& LoginClientId::getGuid() const
{
return guid.get();
}
//-----------------------------------------------------------------------
class LoginClientToken : public GameNetworkMessage
{
public:

View File

@@ -244,6 +244,22 @@ void SwgCuiLoginScreen::ok ()
GameNetwork::setUserName (Unicode::wideToNarrow (name));
GameNetwork::setUserPassword (Unicode::wideToNarrow (passwd));
char szGUID[255];
memset(szGUID, 0, 255);
DWORD lSize = 255;
HKEY hKey;
ULONG ulResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0,
KEY_WOW64_64KEY + KEY_READ, &hKey);
if (ulResult == ERROR_SUCCESS)
{
ulResult = RegGetValue(hKey, "", "MachineGUID", RRF_RT_ANY, nullptr, szGUID, &lSize);
if (ulResult == ERROR_SUCCESS)
{
GameNetwork::setUserGuid(szGUID);
}
}
RegCloseKey(hKey);
std::vector<std::pair<std::string, uint16> > loginServerList;
{