aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Server/WorldSocket.cpp18
-rw-r--r--src/server/shared/Realm/RealmList.cpp67
-rw-r--r--src/server/shared/Realm/RealmList.h7
3 files changed, 54 insertions, 38 deletions
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index ace6d375e48..cc1deaabf16 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -25,7 +25,7 @@
#include "HmacHash.h"
#include "IPLocation.h"
#include "PacketLog.h"
-#include "Realm.h"
+#include "RealmList.h"
#include "RBAC.h"
#include "ScriptMgr.h"
#include "SessionKeyGeneration.h"
@@ -69,9 +69,6 @@ uint8 const WorldSocket::SessionKeySeed[16] = { 0x58, 0xCB, 0xCF, 0x40, 0xFE, 0x
uint8 const WorldSocket::ContinuedSessionSeed[16] = { 0x16, 0xAD, 0x0C, 0xD4, 0x46, 0xF9, 0x4F, 0xB2, 0xEF, 0x7D, 0xEA, 0x2A, 0x17, 0x66, 0x4D, 0x2F };
uint8 const WorldSocket::EncryptionKeySeed[16] = { 0xE9, 0x75, 0x3C, 0x50, 0x90, 0x93, 0x61, 0xDA, 0x3B, 0x07, 0xEE, 0xFA, 0xFF, 0x9D, 0x41, 0xB8 };
-uint8 const ClientTypeSeed_Wn64[16] = { 0x1A, 0x09, 0xBE, 0x1D, 0x38, 0xA1, 0x22, 0x58, 0x6B, 0x49, 0x31, 0xBE, 0xCC, 0xEA, 0xD4, 0xAA };
-uint8 const ClientTypeSeed_Mc64[16] = { 0x34, 0x1C, 0xFE, 0xFE, 0x3D, 0x72, 0xAC, 0xA9, 0xA4, 0x40, 0x7D, 0xC5, 0x35, 0xDE, 0xD6, 0x6A };
-
WorldSocket::WorldSocket(tcp::socket&& socket) : Socket(std::move(socket)),
_type(CONNECTION_TYPE_REALM), _key(0), _OverSpeedPings(0),
_worldSession(nullptr), _authed(false), _sendBufferSize(4096), _compressionStream(nullptr)
@@ -671,6 +668,15 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<WorldPackets::Auth::
return;
}
+ RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(realm.Build);
+ if (!buildInfo)
+ {
+ SendAuthResponseError(ERROR_BAD_VERSION);
+ TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Missing auth seed for realm build %u (%s).", realm.Build, GetRemoteIpAddress().to_string().c_str());
+ DelayedCloseSocket();
+ return;
+ }
+
AccountInfo account(result->Fetch());
// For hook purposes, we get Remoteaddress at this point.
@@ -679,9 +685,9 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<WorldPackets::Auth::
SHA256Hash digestKeyHash;
digestKeyHash.UpdateData(account.Game.KeyData.data(), account.Game.KeyData.size());
if (account.Game.OS == "Wn64")
- digestKeyHash.UpdateData(ClientTypeSeed_Wn64, 16);
+ digestKeyHash.UpdateData(buildInfo->Win64AuthSeed.data(), buildInfo->Win64AuthSeed.size());
else if (account.Game.OS == "Mc64")
- digestKeyHash.UpdateData(ClientTypeSeed_Mc64, 16);
+ digestKeyHash.UpdateData(buildInfo->Mac64AuthSeed.data(), buildInfo->Mac64AuthSeed.size());
digestKeyHash.Finalize();
diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp
index 8bc4726c17d..4b1d1dc2d8c 100644
--- a/src/server/shared/Realm/RealmList.cpp
+++ b/src/server/shared/Realm/RealmList.cpp
@@ -56,6 +56,7 @@ void RealmList::Initialize(Trinity::Asio::IoContext& ioContext, uint32 updateInt
_updateTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
_resolver = Trinity::make_unique<boost::asio::ip::tcp::resolver>(ioContext);
+ LoadBuildInfo();
// Get the content of the realmlist table in the database
UpdateRealms(boost::system::error_code());
}
@@ -65,6 +66,38 @@ void RealmList::Close()
_updateTimer->cancel();
}
+void RealmList::LoadBuildInfo()
+{
+ // 0 1 2 3 4 5 6
+ if (QueryResult result = LoginDatabase.Query("SELECT majorVersion, minorVersion, bugfixVersion, hotfixVersion, build, win64AuthSeed, mac64AuthSeed FROM build_info ORDER BY build ASC"))
+ {
+ do
+ {
+ Field* fields = result->Fetch();
+ _builds.emplace_back();
+ RealmBuildInfo& build = _builds.back();
+ build.MajorVersion = fields[0].GetUInt32();
+ build.MinorVersion = fields[1].GetUInt32();
+ build.BugfixVersion = fields[2].GetUInt32();
+ std::string hotfixVersion = fields[3].GetString();
+ if (hotfixVersion.length() < build.HotfixVersion.size())
+ std::copy(hotfixVersion.begin(), hotfixVersion.end(), build.HotfixVersion.begin());
+ else
+ std::fill(hotfixVersion.begin(), hotfixVersion.end(), '\0');
+
+ build.Build = fields[4].GetUInt32();
+ std::string win64AuthSeedHexStr = fields[5].GetString();
+ if (win64AuthSeedHexStr.length() == build.Win64AuthSeed.size() * 2)
+ HexStrToByteArray(win64AuthSeedHexStr, build.Win64AuthSeed.data());
+
+ std::string mac64AuthSeedHexStr = fields[6].GetString();
+ if (mac64AuthSeedHexStr.length() == build.Mac64AuthSeed.size() * 2)
+ HexStrToByteArray(mac64AuthSeedHexStr, build.Mac64AuthSeed.data());
+
+ } while (result->NextRow());
+ }
+}
+
void RealmList::UpdateRealm(Realm& realm, Battlenet::RealmHandle const& id, uint32 build, std::string const& name,
boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask,
uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel,
@@ -204,37 +237,9 @@ Realm const* RealmList::GetRealm(Battlenet::RealmHandle const& id) const
return NULL;
}
-// List of client builds for verbose version info in realmlist packet
-static RealmBuildInfo const ClientBuilds[] =
-{
- { 32722, 8, 2, 5, ' ' },
- { 32638, 8, 2, 5, ' ' },
- { 32580, 8, 2, 5, ' ' },
- { 32494, 8, 2, 5, ' ' },
- { 28938, 8, 1, 5, ' ' },
- { 21355, 6, 2, 4, ' ' },
- { 20726, 6, 2, 3, ' ' },
- { 20574, 6, 2, 2, 'a' },
- { 20490, 6, 2, 2, 'a' },
- { 15595, 4, 3, 4, ' ' },
- { 14545, 4, 2, 2, ' ' },
- { 13623, 4, 0, 6, 'a' },
- { 13930, 3, 3, 5, 'a' }, // 3.3.5a China Mainland build
- { 12340, 3, 3, 5, 'a' },
- { 11723, 3, 3, 3, 'a' },
- { 11403, 3, 3, 2, ' ' },
- { 11159, 3, 3, 0, 'a' },
- { 10505, 3, 2, 2, 'a' },
- { 9947, 3, 1, 3, ' ' },
- { 8606, 2, 4, 3, ' ' },
- { 6141, 1, 12, 3, ' ' },
- { 6005, 1, 12, 2, ' ' },
- { 5875, 1, 12, 1, ' ' },
-};
-
RealmBuildInfo const* RealmList::GetBuildInfo(uint32 build) const
{
- for (RealmBuildInfo const& clientBuild : ClientBuilds)
+ for (RealmBuildInfo const& clientBuild : _builds)
if (clientBuild.Build == build)
return &clientBuild;
@@ -243,11 +248,11 @@ RealmBuildInfo const* RealmList::GetBuildInfo(uint32 build) const
uint32 RealmList::GetMinorMajorBugfixVersionForBuild(uint32 build) const
{
- RealmBuildInfo const* buildInfo = std::lower_bound(std::begin(ClientBuilds), std::end(ClientBuilds), build, [](RealmBuildInfo const& buildInfo, uint32 value)
+ auto buildInfo = std::lower_bound(_builds.begin(), _builds.end(), build, [](RealmBuildInfo const& buildInfo, uint32 value)
{
return buildInfo.Build < value;
});
- return buildInfo != std::end(ClientBuilds) ? (buildInfo->MajorVersion * 10000 + buildInfo->MinorVersion * 100 + buildInfo->BugfixVersion) : 0;
+ return buildInfo != _builds.end() ? (buildInfo->MajorVersion * 10000 + buildInfo->MinorVersion * 100 + buildInfo->BugfixVersion) : 0;
}
void RealmList::WriteSubRegions(bgs::protocol::game_utilities::v1::GetAllValuesForAttributeResponse* response) const
diff --git a/src/server/shared/Realm/RealmList.h b/src/server/shared/Realm/RealmList.h
index da1a6b2c4e8..7f99b618e96 100644
--- a/src/server/shared/Realm/RealmList.h
+++ b/src/server/shared/Realm/RealmList.h
@@ -21,6 +21,7 @@
#include "Define.h"
#include "Realm.h"
+#include <array>
#include <map>
#include <vector>
#include <unordered_set>
@@ -31,7 +32,9 @@ struct RealmBuildInfo
uint32 MajorVersion;
uint32 MinorVersion;
uint32 BugfixVersion;
- uint32 HotfixVersion;
+ std::array<char, 4> HotfixVersion;
+ std::array<uint8, 16> Win64AuthSeed;
+ std::array<uint8, 16> Mac64AuthSeed;
};
namespace boost
@@ -102,11 +105,13 @@ public:
private:
RealmList();
+ void LoadBuildInfo();
void UpdateRealms(boost::system::error_code const& error);
void UpdateRealm(Realm& realm, Battlenet::RealmHandle const& id, uint32 build, std::string const& name,
boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask,
uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population);
+ std::vector<RealmBuildInfo> _builds;
std::unique_ptr<boost::shared_mutex> _realmsMutex;
RealmMap _realms;
std::unordered_set<std::string> _subRegions;