Skip to content

Commit cb995e2

Browse files
author
Github Actions
committed
Merge 3.3.5 to 3.3.5-1vs1
2 parents d759e70 + 0b10514 commit cb995e2

File tree

11 files changed

+873
-167
lines changed

11 files changed

+873
-167
lines changed

sql/base/auth_database.sql

Lines changed: 594 additions & 90 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE `build_info` ADD `macArmAuthSeed` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL AFTER `mac64AuthSeed`;
2+
3+
UPDATE `build_info` SET `macArmAuthSeed`='778F6A5DF79A4EF1B86F651F3B303CE7' WHERE `build`=56196;
4+
UPDATE `build_info` SET `macArmAuthSeed`='41710C793EF021721F14B06EC1896D3F' WHERE `build`=56288;
5+
UPDATE `build_info` SET `macArmAuthSeed`='412D3200715AAFDC0522DF031A941F0E' WHERE `build`=56311;
6+
UPDATE `build_info` SET `macArmAuthSeed`='A83ED19EE659BC95CC322D1E49BDEDBB' WHERE `build`=56313;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--
2+
-- Table structure for table `build_auth_key`
3+
--
4+
DROP TABLE IF EXISTS `build_auth_key`;
5+
CREATE TABLE `build_auth_key` (
6+
`build` int NOT NULL,
7+
`platform` char(4) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
8+
`arch` char(4) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
9+
`type` char(4) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
10+
`key` binary(16) NOT NULL,
11+
PRIMARY KEY (`build`,`platform`,`arch`,`type`)
12+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
13+
14+
--
15+
-- Table structure for table `build_executable_hash`
16+
--
17+
DROP TABLE IF EXISTS `build_executable_hash`;
18+
CREATE TABLE `build_executable_hash` (
19+
`build` int NOT NULL,
20+
`platform` char(4) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
21+
`executableHash` binary(20) NOT NULL,
22+
PRIMARY KEY (`build`,`platform`)
23+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
24+
25+
INSERT INTO `build_auth_key` SELECT `build`,'Win','x86','WoW',UNHEX(`winAuthSeed`) FROM `build_info` WHERE LENGTH(`winAuthSeed`)=32;
26+
INSERT INTO `build_auth_key` SELECT `build`,'Win','x64','WoW',UNHEX(`win64AuthSeed`) FROM `build_info` WHERE LENGTH(`win64AuthSeed`)=32;
27+
INSERT INTO `build_auth_key` SELECT `build`,'Mac','x64','WoW',UNHEX(`mac64AuthSeed`) FROM `build_info` WHERE LENGTH(`mac64AuthSeed`)=32;
28+
INSERT INTO `build_auth_key` SELECT `build`,'Mac','A64','WoW',UNHEX(`macArmAuthSeed`) FROM `build_info` WHERE LENGTH(`macArmAuthSeed`)=32;
29+
30+
INSERT INTO `build_executable_hash` SELECT `build`,'Win',UNHEX(`winChecksumSeed`) FROM `build_info` WHERE LENGTH(`winChecksumSeed`)=40;
31+
INSERT INTO `build_executable_hash` SELECT `build`,'OSX',UNHEX(`macChecksumSeed`) FROM `build_info` WHERE LENGTH(`macChecksumSeed`)=40;
32+
33+
ALTER TABLE `build_info`
34+
DROP `winAuthSeed`,
35+
DROP `win64AuthSeed`,
36+
DROP `mac64AuthSeed`,
37+
DROP `macArmAuthSeed`,
38+
DROP `winChecksumSeed`,
39+
DROP `macChecksumSeed`;

src/server/authserver/Authentication/AuthCodes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@
1616
*/
1717

1818
#include "AuthCodes.h"
19-
#include "RealmList.h"
19+
#include "ClientBuildInfo.h"
2020

2121
namespace AuthHelper
2222
{
2323
constexpr static uint32 MAX_PRE_BC_CLIENT_BUILD = 6141;
2424

2525
bool IsPreBCAcceptedClientBuild(uint32 build)
2626
{
27-
return build <= MAX_PRE_BC_CLIENT_BUILD && sRealmList->GetBuildInfo(build);
27+
return build <= MAX_PRE_BC_CLIENT_BUILD && ClientBuild::GetBuildInfo(build);
2828
}
2929

3030
bool IsPostBCAcceptedClientBuild(uint32 build)
3131
{
32-
return build > MAX_PRE_BC_CLIENT_BUILD && sRealmList->GetBuildInfo(build);
32+
return build > MAX_PRE_BC_CLIENT_BUILD && ClientBuild::GetBuildInfo(build);
3333
}
3434

3535
bool IsAcceptedClientBuild(uint32 build)
3636
{
37-
return sRealmList->GetBuildInfo(build) != nullptr;
37+
return ClientBuild::GetBuildInfo(build) != nullptr;
3838
}
3939
}

src/server/authserver/Server/AuthSession.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "AES.h"
2020
#include "AuthCodes.h"
2121
#include "ByteBuffer.h"
22+
#include "ClientBuildInfo.h"
2223
#include "Config.h"
2324
#include "CryptoGenerics.h"
2425
#include "CryptoHash.h"
@@ -756,7 +757,7 @@ void AuthSession::RealmListCallback(PreparedQueryResult result)
756757

757758
// No SQL injection. id of realm is controlled by the database.
758759
uint32 flag = realm.Flags;
759-
RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(realm.Build);
760+
ClientBuild::Info const* buildInfo = ClientBuild::GetBuildInfo(realm.Build);
760761
if (!okBuild)
761762
{
762763
if (!buildInfo)
@@ -841,20 +842,15 @@ bool AuthSession::VerifyVersion(uint8 const* a, int32 aLength, Trinity::Crypto::
841842
Trinity::Crypto::SHA1::Digest const* versionHash = nullptr;
842843
if (!isReconnect)
843844
{
844-
RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(_build);
845+
ClientBuild::Info const* buildInfo = ClientBuild::GetBuildInfo(_build);
845846
if (!buildInfo)
846847
return false;
847848

848-
if (_os == "Win")
849-
versionHash = &buildInfo->WindowsHash;
850-
else if (_os == "OSX")
851-
versionHash = &buildInfo->MacHash;
852-
853-
if (!versionHash)
854-
return false;
855-
856-
if (zeros == *versionHash)
849+
auto platformItr = std::ranges::find(buildInfo->ExecutableHashes, ClientBuild::ToFourCC(_os), &ClientBuild::ExecutableHash::Platform);
850+
if (platformItr == buildInfo->ExecutableHashes.end())
857851
return true; // not filled serverside
852+
853+
versionHash = &platformItr->Hash;
858854
}
859855
else
860856
versionHash = &zeros;

src/server/game/Miscellaneous/Language.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ enum TrinityStrings
344344
LANG_COMMAND_NPC_SHOWLOOT_LABEL_2 = 293,
345345
LANG_COMMAND_NPC_SHOWLOOT_SUBLABEL = 294,
346346
LANG_COMMAND_NPC_SHOWLOOT_ENTRY_2 = 295,
347-
// 296 free
347+
LANG_COMMAND_NPC_SHOWLOOT_CURRENCY = 296, // master branch ONLY
348348

349349
// END
350350
LANG_COMMAND_WANDER_DISTANCE = 297,

src/server/game/Server/WorldSocket.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "WorldSocket.h"
1919
#include "BigNumber.h"
20+
#include "ClientBuildInfo.h"
2021
#include "DatabaseEnv.h"
2122
#include "GameTime.h"
2223
#include "CryptoHash.h"
@@ -506,7 +507,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
506507

507508
// Must be done before WorldSession is created
508509
bool wardenActive = sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED);
509-
if (wardenActive && account.OS != "Win" && account.OS != "OSX")
510+
if (wardenActive && !ClientBuild::Platform::IsValid(account.OS))
510511
{
511512
SendAuthResponseError(AUTH_REJECT);
512513
TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client {} attempted to log in using invalid client OS ({}).", address, account.OS);
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms of the GNU General Public License as published by the
6+
* Free Software Foundation; either version 2 of the License, or (at your
7+
* option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+
* more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include "ClientBuildInfo.h"
19+
#include "DatabaseEnv.h"
20+
#include "Log.h"
21+
#include "Util.h"
22+
#include <algorithm>
23+
#include <cctype>
24+
25+
namespace
26+
{
27+
std::vector<ClientBuild::Info> Builds;
28+
}
29+
30+
namespace ClientBuild
31+
{
32+
std::array<char, 5> ToCharArray(uint32 value)
33+
{
34+
auto normalize = [](uint8 c) -> char
35+
{
36+
if (!c || std::isprint(c))
37+
return char(c);
38+
return ' ';
39+
};
40+
41+
std::array<char, 5> chars = { char((value >> 24) & 0xFF), char((value >> 16) & 0xFF), char((value >> 8) & 0xFF), char(value & 0xFF), '\0' };
42+
43+
auto firstNonZero = std::ranges::find_if(chars, [](char c) { return c != '\0'; });
44+
if (firstNonZero != chars.end())
45+
{
46+
// move leading zeros to end
47+
std::rotate(chars.begin(), firstNonZero, chars.end());
48+
49+
// ensure we only have printable characters remaining
50+
std::ranges::transform(chars, chars.begin(), normalize);
51+
}
52+
53+
return chars;
54+
}
55+
56+
bool Platform::IsValid(std::string_view platform)
57+
{
58+
if (platform.length() > sizeof(uint32))
59+
return false;
60+
61+
switch (ToFourCC(platform))
62+
{
63+
case Win_x86:
64+
case Mac_x86:
65+
return true;
66+
default:
67+
break;
68+
}
69+
70+
return false;
71+
}
72+
73+
void LoadBuildInfo()
74+
{
75+
Builds.clear();
76+
77+
// 0 1 2 3 4
78+
if (QueryResult result = LoginDatabase.Query("SELECT majorVersion, minorVersion, bugfixVersion, hotfixVersion, build FROM build_info ORDER BY build ASC"))
79+
{
80+
do
81+
{
82+
Field* fields = result->Fetch();
83+
Info& build = Builds.emplace_back();
84+
build.MajorVersion = fields[0].GetUInt32();
85+
build.MinorVersion = fields[1].GetUInt32();
86+
build.BugfixVersion = fields[2].GetUInt32();
87+
std::string hotfixVersion = fields[3].GetString();
88+
if (hotfixVersion.length() < build.HotfixVersion.size())
89+
std::ranges::copy(hotfixVersion, build.HotfixVersion.begin());
90+
else
91+
build.HotfixVersion = { };
92+
93+
build.Build = fields[4].GetUInt32();
94+
95+
} while (result->NextRow());
96+
}
97+
98+
// 0 1 2
99+
if (QueryResult result = LoginDatabase.Query("SELECT `build`, `platform`, `executableHash` FROM `build_executable_hash`"))
100+
{
101+
do
102+
{
103+
Field* fields = result->Fetch();
104+
105+
uint32 build = fields[0].GetInt32();
106+
auto buildInfo = std::ranges::find(Builds, build, &Info::Build);
107+
if (buildInfo == Builds.end())
108+
{
109+
TC_LOG_ERROR("sql.sql", "ClientBuild::LoadBuildInfo: Unknown `build` {} in `build_executable_hash` - missing from `build_info`, skipped.", build);
110+
continue;
111+
}
112+
113+
std::string_view platform = fields[1].GetStringView();
114+
if (!Platform::IsValid(platform))
115+
{
116+
TC_LOG_ERROR("sql.sql", "ClientBuild::LoadBuildInfo: Invalid platform {} for `build` {} in `build_executable_hash`, skipped.", platform, build);
117+
continue;
118+
}
119+
120+
ExecutableHash& buildKey = buildInfo->ExecutableHashes.emplace_back();
121+
buildKey.Platform = ToFourCC(platform);
122+
buildKey.Hash = fields[2].GetBinary<ExecutableHash::Size>();
123+
124+
} while (result->NextRow());
125+
}
126+
}
127+
128+
Info const* GetBuildInfo(uint32 build)
129+
{
130+
auto buildInfo = std::ranges::find(Builds, build, &Info::Build);
131+
return buildInfo != Builds.end() ? &*buildInfo : nullptr;
132+
}
133+
134+
uint32 GetMinorMajorBugfixVersionForBuild(uint32 build)
135+
{
136+
auto buildInfo = std::ranges::lower_bound(Builds, build, {}, &Info::Build);
137+
return buildInfo != Builds.end() ? (buildInfo->MajorVersion * 10000 + buildInfo->MinorVersion * 100 + buildInfo->BugfixVersion) : 0;
138+
}
139+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms of the GNU General Public License as published by the
6+
* Free Software Foundation; either version 2 of the License, or (at your
7+
* option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+
* more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#ifndef TRINITYCORE_CLIENT_BUILD_INFO_H
19+
#define TRINITYCORE_CLIENT_BUILD_INFO_H
20+
21+
#include "Define.h"
22+
#include <array>
23+
#include <string_view>
24+
#include <vector>
25+
26+
namespace ClientBuild
27+
{
28+
inline constexpr uint32 ToFourCC(std::string_view text)
29+
{
30+
uint32 uintValue = 0;
31+
for (uint8 c : text)
32+
{
33+
uintValue <<= 8;
34+
uintValue |= c;
35+
}
36+
return uintValue;
37+
}
38+
39+
consteval uint32 operator""_fourcc(char const* chars, std::size_t length)
40+
{
41+
if (length > sizeof(uint32))
42+
throw "Text can only be max 4 characters long";
43+
44+
return ToFourCC({ chars, length });
45+
}
46+
47+
TC_SHARED_API std::array<char, 5> ToCharArray(uint32 value);
48+
49+
namespace Platform
50+
{
51+
inline constexpr uint32 Win_x86 = "Win"_fourcc;
52+
inline constexpr uint32 Mac_x86 = "OSX"_fourcc;
53+
54+
TC_SHARED_API bool IsValid(std::string_view platform);
55+
}
56+
57+
struct ExecutableHash
58+
{
59+
static constexpr std::size_t Size = 20;
60+
61+
uint32 Platform;
62+
std::array<uint8, Size> Hash;
63+
};
64+
65+
struct Info
66+
{
67+
uint32 Build;
68+
uint32 MajorVersion;
69+
uint32 MinorVersion;
70+
uint32 BugfixVersion;
71+
std::array<char, 4> HotfixVersion;
72+
std::vector<ExecutableHash> ExecutableHashes;
73+
};
74+
75+
TC_SHARED_API void LoadBuildInfo();
76+
TC_SHARED_API Info const* GetBuildInfo(uint32 build);
77+
}
78+
79+
#endif // TRINITYCORE_CLIENT_BUILD_INFO_H

0 commit comments

Comments
 (0)