mirror of
https://github.com/SWG-Source/src.git
synced 2026-08-05 05:17:46 -04:00
allow the old style suid hashing in login server
This commit is contained in:
@@ -303,8 +303,6 @@ void ClientConnection::handleClientIdMessage(const ClientIdMsg &msg) {
|
||||
result = ConnectionServer::decryptToken(token, sessionId, m_requestedSuid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const std::string sessURL(ConfigConnectionServer::getSessionURL());
|
||||
|
||||
if (result || strlen(sessionId) != 0) {
|
||||
|
||||
@@ -152,11 +152,13 @@ void ClientConnection::onReceive(const Archive::ByteStream &message) {
|
||||
// originally was used to validate station API credentials, now uses our custom api
|
||||
void ClientConnection::validateClient(const std::string &id, const std::string &key) {
|
||||
bool authOK = false;
|
||||
bool testMode = false;
|
||||
static const std::string authURL(ConfigLoginServer::getExternalAuthUrl());
|
||||
|
||||
std::string uname;
|
||||
std::string parentAccount;
|
||||
std::string sessionID;
|
||||
|
||||
StationId user_id;
|
||||
StationId parent_id;
|
||||
std::unordered_map<int, std::string> childAccounts;
|
||||
@@ -181,8 +183,21 @@ void ClientConnection::validateClient(const std::string &id, const std::string &
|
||||
parentAccount = api.getString("mainAccount");
|
||||
childAccounts = api.getStringMap("subAccounts");
|
||||
|
||||
user_id = static_cast<StationId>(api.getNullableValue<int>("user_id"));
|
||||
parent_id = static_cast<StationId>(api.getNullableValue<int>("parent_id"));
|
||||
if (!ConfigLoginServer::getUseOldSuidGenerator()) {
|
||||
user_id = static_cast<StationId>(api.getNullableValue<int>("user_id"));
|
||||
parent_id = static_cast<StationId>(api.getNullableValue<int>("parent_id"));
|
||||
} else {
|
||||
if (parentAccount.length() > MAX_ACCOUNT_NAME_LENGTH) {
|
||||
parentAccount.resize(MAX_ACCOUNT_NAME_LENGTH);
|
||||
}
|
||||
|
||||
if (uname.length() > MAX_ACCOUNT_NAME_LENGTH) {
|
||||
uname.resize(MAX_ACCOUNT_NAME_LENGTH);
|
||||
}
|
||||
|
||||
parent_id = std::hash<std::string>{}(parentAccount.c_str());
|
||||
user_id = std::hash<std::string>{}(uname.c_str());
|
||||
}
|
||||
} else {
|
||||
std::string msg(api.getString("message"));
|
||||
if (msg.empty()) {
|
||||
@@ -199,10 +214,19 @@ void ClientConnection::validateClient(const std::string &id, const std::string &
|
||||
} else {
|
||||
// test mode
|
||||
authOK = true;
|
||||
testMode = true;
|
||||
uname = id;
|
||||
|
||||
if (uname.length() > MAX_ACCOUNT_NAME_LENGTH) {
|
||||
uname.resize(MAX_ACCOUNT_NAME_LENGTH);
|
||||
}
|
||||
|
||||
user_id = std::hash<std::string>{}(uname.c_str());
|
||||
}
|
||||
|
||||
if (authOK) {
|
||||
m_stationId = user_id;
|
||||
|
||||
if (authOK && !testMode) {
|
||||
REPORT_LOG(true, ("Client connected. Username: %s (%i) \n", uname.c_str(), user_id));
|
||||
|
||||
if (!parentAccount.empty()) {
|
||||
@@ -217,24 +241,33 @@ void ClientConnection::validateClient(const std::string &id, const std::string &
|
||||
StationId child_id = static_cast<StationId>(i.first);
|
||||
std::string child(i.second);
|
||||
|
||||
if (!child.empty()) {
|
||||
REPORT_LOG((parent_id !=
|
||||
child_id), ("\tchild of %s (%i) is %s (%i) \n", parentAccount.c_str(), parent_id, child.c_str(), child_id));
|
||||
if (!child.empty() && i.first > 0) {
|
||||
if (ConfigLoginServer::getUseOldSuidGenerator()) {
|
||||
if (child.length() > MAX_ACCOUNT_NAME_LENGTH) {
|
||||
child.resize(MAX_ACCOUNT_NAME_LENGTH);
|
||||
}
|
||||
|
||||
child_id = std::hash<std::string>{}(child.c_str());
|
||||
}
|
||||
|
||||
REPORT_LOG((parent_id != child_id), ("\tchild of %s (%i) is %s (%i) \n", parentAccount.c_str(), parent_id, child.c_str(), child_id));
|
||||
|
||||
// insert all related accounts, if not already there, into the db
|
||||
if (parent_id != child_id) {
|
||||
DatabaseConnection::getInstance().upsertAccountRelationship(parent_id, child_id);
|
||||
}
|
||||
} else {
|
||||
WARNING(true, ("Login API returned empty child account(s)."));
|
||||
}
|
||||
} else {
|
||||
WARNING(true, ("Login API returned empty child account(s)."));
|
||||
}
|
||||
}
|
||||
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%i) at IP (%s), id (%s)", user_id, getRemoteAddress().c_str(), uname.c_str()));
|
||||
|
||||
m_stationId = user_id;
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%i) at IP (%s), id (%s)", user_id, getRemoteAddress().c_str(), uname.c_str()));
|
||||
|
||||
if (!testMode) {
|
||||
LoginServer::getInstance().onValidateClient(m_stationId, uname, this, true, sessionID.c_str(), 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
} else {
|
||||
LoginServer::getInstance().onValidateClient(m_stationId, uname, this, true, nullptr, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ void ConfigLoginServer::install(void)
|
||||
KEY_BOOL(requireSecureLoginForCsTool, true);
|
||||
KEY_BOOL(useExternalAuth, false);
|
||||
KEY_STRING(externalAuthURL, "");
|
||||
KEY_INT(maxConnectionsPerIP, 4); // assuming 2 people playing in the same household
|
||||
KEY_BOOL(useOldSuidGenerator, false);
|
||||
|
||||
int index = 0;
|
||||
char const * result = 0;
|
||||
|
||||
@@ -69,7 +69,7 @@ class ConfigLoginServer
|
||||
|
||||
const char * externalAuthURL;
|
||||
|
||||
int maxConnectionsPerIP;
|
||||
bool useOldSuidGenerator;
|
||||
};
|
||||
|
||||
static const uint16 getCentralServicePort();
|
||||
@@ -139,8 +139,6 @@ class ConfigLoginServer
|
||||
static bool isCharacterCreationDisabled(std::string const & cluster);
|
||||
static std::set<std::string> const & getCharacterCreationDisabledClusterList();
|
||||
|
||||
static const int getMaxConnectionsPerIP();
|
||||
|
||||
private:
|
||||
static Data * data;
|
||||
};
|
||||
@@ -488,9 +486,10 @@ inline const char * ConfigLoginServer::getExternalAuthUrl()
|
||||
return data->externalAuthURL;
|
||||
}
|
||||
|
||||
inline const int ConfigLoginServer::getMaxConnectionsPerIP()
|
||||
|
||||
inline const bool ConfigLoginServer::getUseOldSuidGenerator()
|
||||
{
|
||||
return data->maxConnectionsPerIP;
|
||||
return data->useOldSuidGenerator;
|
||||
}
|
||||
// ======================================================================
|
||||
|
||||
|
||||
@@ -130,7 +130,6 @@ LoginServer::LoginServer()
|
||||
NetworkSetupData setup;
|
||||
setup.port = ConfigLoginServer::getClientServicePort();
|
||||
setup.maxConnections = ConfigLoginServer::getMaxClients();
|
||||
setup.maxConnectionsPerIP = ConfigLoginServer::getMaxConnectionsPerIP();
|
||||
setup.oldestUnacknowledgedTimeout = 30000;
|
||||
setup.keepAliveDelay = 45000;
|
||||
setup.compress = ConfigLoginServer::getCompressClientNetworkTraffic();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user