mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Auth: Moved battle.net handling to separate project
This commit is contained in:
@@ -25,6 +25,7 @@ if( SERVERS )
|
||||
add_subdirectory(game)
|
||||
add_subdirectory(collision)
|
||||
add_subdirectory(authserver)
|
||||
add_subdirectory(bnetserver)
|
||||
add_subdirectory(scripts)
|
||||
add_subdirectory(worldserver)
|
||||
else()
|
||||
|
||||
@@ -58,7 +58,6 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Authentication
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Realms
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Server
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Server/BattlenetPackets
|
||||
${MYSQL_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${VALGRIND_INCLUDE_DIR}
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
*/
|
||||
|
||||
#include "AuthSocketMgr.h"
|
||||
#include "BattlenetManager.h"
|
||||
#include "BattlenetSessionManager.h"
|
||||
#include "Common.h"
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
@@ -117,18 +115,9 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119);
|
||||
if (bnport < 0 || bnport > 0xFFFF)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Specified battle.net port (%d) out of allowed range (1-65535)", bnport);
|
||||
StopDB();
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
|
||||
sAuthSocketMgr.StartNetwork(_ioService, bindIp, port);
|
||||
sBattlenetSessionMgr.StartNetwork(_ioService, bindIp, bnport);
|
||||
|
||||
// Set signal handlers
|
||||
boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
|
||||
@@ -145,8 +134,6 @@ int main(int argc, char** argv)
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer.async_wait(KeepDatabaseAliveHandler);
|
||||
|
||||
sBattlenetMgr->Load();
|
||||
|
||||
// Start the io service worker loop
|
||||
_ioService.run();
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include "Configuration/Config.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "Log.h"
|
||||
#include "BattlenetManager.h"
|
||||
#include "RealmList.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "BattlenetPackets.h"
|
||||
#include "AuthSession.h"
|
||||
#include "BattlenetSession.h"
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include "Common.h"
|
||||
#include "RealmList.h"
|
||||
#include "BattlenetManager.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "Util.h"
|
||||
|
||||
@@ -193,16 +192,3 @@ void RealmList::UpdateRealms(bool init)
|
||||
while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
||||
Realm const* RealmList::GetRealm(Battlenet::RealmId const& id) const
|
||||
{
|
||||
auto itr = std::find_if(m_realms.begin(), m_realms.end(), [id](RealmMap::value_type const& pair)
|
||||
{
|
||||
return pair.second.Region == id.Region && pair.second.Battlegroup == id.Battlegroup && pair.second.m_ID == id.Index;
|
||||
});
|
||||
|
||||
if (itr != m_realms.end())
|
||||
return &itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -60,11 +60,6 @@ struct Realm
|
||||
ip::tcp::endpoint GetAddressForClient(ip::address const& clientAddr) const;
|
||||
};
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
struct RealmId;
|
||||
}
|
||||
|
||||
/// Storage object for the list of realms on the server
|
||||
class RealmList
|
||||
{
|
||||
@@ -88,7 +83,6 @@ public:
|
||||
RealmMap::const_iterator begin() const { return m_realms.begin(); }
|
||||
RealmMap::const_iterator end() const { return m_realms.end(); }
|
||||
uint32 size() const { return m_realms.size(); }
|
||||
Realm const* GetRealm(Battlenet::RealmId const& id) const;
|
||||
|
||||
private:
|
||||
RealmList();
|
||||
|
||||
55
src/server/bnetserver/Authentication/AuthCodes.cpp
Normal file
55
src/server/bnetserver/Authentication/AuthCodes.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AuthCodes.h"
|
||||
#include <cstddef>
|
||||
|
||||
namespace AuthHelper
|
||||
{
|
||||
static RealmBuildInfo const PostBcAcceptedClientBuilds[] =
|
||||
{
|
||||
{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, ' '},
|
||||
{0, 0, 0, 0, ' '} // terminator
|
||||
};
|
||||
|
||||
RealmBuildInfo const* GetBuildInfo(int build)
|
||||
{
|
||||
for (int i = 0; PostBcAcceptedClientBuilds[i].Build; ++i)
|
||||
if (PostBcAcceptedClientBuilds[i].Build == build)
|
||||
return &PostBcAcceptedClientBuilds[i];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool IsBuildSupportingBattlenet(int build)
|
||||
{
|
||||
return build >= 15595;
|
||||
}
|
||||
}
|
||||
128
src/server/bnetserver/Authentication/AuthCodes.h
Normal file
128
src/server/bnetserver/Authentication/AuthCodes.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUTHCODES_H
|
||||
#define _AUTHCODES_H
|
||||
|
||||
enum GameAccountFlags
|
||||
{
|
||||
GAMEACCOUNT_FLAG_GM = 0x00000001,
|
||||
GAMEACCOUNT_FLAG_NOKICK = 0x00000002,
|
||||
GAMEACCOUNT_FLAG_COLLECTOR = 0x00000004,
|
||||
GAMEACCOUNT_FLAG_WOW_TRIAL = 0x00000008,
|
||||
GAMEACCOUNT_FLAG_CANCELLED = 0x00000010,
|
||||
GAMEACCOUNT_FLAG_IGR = 0x00000020,
|
||||
GAMEACCOUNT_FLAG_WHOLESALER = 0x00000040,
|
||||
GAMEACCOUNT_FLAG_PRIVILEGED = 0x00000080,
|
||||
GAMEACCOUNT_FLAG_EU_FORBID_ELV = 0x00000100,
|
||||
GAMEACCOUNT_FLAG_EU_FORBID_BILLING = 0x00000200,
|
||||
GAMEACCOUNT_FLAG_WOW_RESTRICTED = 0x00000400,
|
||||
GAMEACCOUNT_FLAG_REFERRAL = 0x00000800,
|
||||
GAMEACCOUNT_FLAG_BLIZZARD = 0x00001000,
|
||||
GAMEACCOUNT_FLAG_RECURRING_BILLING = 0x00002000,
|
||||
GAMEACCOUNT_FLAG_NOELECTUP = 0x00004000,
|
||||
GAMEACCOUNT_FLAG_KR_CERTIFICATE = 0x00008000,
|
||||
GAMEACCOUNT_FLAG_EXPANSION_COLLECTOR = 0x00010000,
|
||||
GAMEACCOUNT_FLAG_DISABLE_VOICE = 0x00020000,
|
||||
GAMEACCOUNT_FLAG_DISABLE_VOICE_SPEAK = 0x00040000,
|
||||
GAMEACCOUNT_FLAG_REFERRAL_RESURRECT = 0x00080000,
|
||||
GAMEACCOUNT_FLAG_EU_FORBID_CC = 0x00100000,
|
||||
GAMEACCOUNT_FLAG_OPENBETA_DELL = 0x00200000,
|
||||
GAMEACCOUNT_FLAG_PROPASS = 0x00400000,
|
||||
GAMEACCOUNT_FLAG_PROPASS_LOCK = 0x00800000,
|
||||
GAMEACCOUNT_FLAG_PENDING_UPGRADE = 0x01000000,
|
||||
GAMEACCOUNT_FLAG_RETAIL_FROM_TRIAL = 0x02000000,
|
||||
GAMEACCOUNT_FLAG_EXPANSION2_COLLECTOR = 0x04000000,
|
||||
GAMEACCOUNT_FLAG_OVERMIND_LINKED = 0x08000000,
|
||||
GAMEACCOUNT_FLAG_DEMOS = 0x10000000,
|
||||
GAMEACCOUNT_FLAG_DEATH_KNIGHT_OK = 0x20000000,
|
||||
};
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
enum AuthResult
|
||||
{
|
||||
AUTH_OK = 0,
|
||||
AUTH_INTERNAL_ERROR = 100,
|
||||
AUTH_CORRUPTED_MODULE = 101,
|
||||
AUTH_NO_BATTLETAGS = 102,
|
||||
AUTH_BAD_SERVER_PROOF = 103,
|
||||
AUTH_UNKNOWN_ACCOUNT = 104,
|
||||
AUTH_CLOSED = 105,
|
||||
AUTH_LOGIN_TIMEOUT = 106,
|
||||
AUTH_NO_GAME_ACCOUNTS = 107,
|
||||
AUTH_INVALID_TOKEN = 108,
|
||||
AUTH_INVALID_PROGRAM = 109,
|
||||
AUTH_INVALID_OS = 110,
|
||||
AUTH_UNSUPPORTED_LANGUAGE = 111,
|
||||
AUTH_REGION_BAD_VERSION = 112,
|
||||
AUTH_TEMP_OUTAGE = 113,
|
||||
AUTH_CANT_DOWNLOAD_MODULE = 114,
|
||||
AUTH_DUPLICATE_LOGON = 115,
|
||||
AUTH_BAD_CREDENTIALS_2 = 116,
|
||||
AUTH_VERSION_CHECK_SUCCEEDED = 117,
|
||||
AUTH_BAD_VERSION_HASH = 118,
|
||||
AUTH_CANT_RETRIEVE_PORTAL_LIST = 119,
|
||||
AUTH_DARK_PORTAL_DOES_NOT_EXIST = 120,
|
||||
AUTH_DARK_PORTAL_FILE_CORRUPTED = 121,
|
||||
AUTH_BATTLENET_MAINTENANCE = 122,
|
||||
AUTH_LOGON_TOO_FAST = 123,
|
||||
AUTH_USE_GRUNT_LOGON = 124,
|
||||
AUTH_NO_GAME_ACCOUNTS_IN_REGION = 140,
|
||||
AUTH_ACCOUNT_LOCKED = 141,
|
||||
|
||||
LOGIN_SERVER_BUSY = 200,
|
||||
LOGIN_NO_GAME_ACCOUNT = 201,
|
||||
LOGIN_BANNED = 202,
|
||||
LOGIN_SUSPENDED = 203,
|
||||
LOGIN_GAME_ACCOUNT_LOCKED = 204,
|
||||
LOGIN_ALREADY_ONLINE = 205,
|
||||
LOGIN_NOTIME = 206,
|
||||
LOGIN_EXPIRED = 207,
|
||||
LOGIN_EXPIRED_2 = 208,
|
||||
LOGIN_PARENTALCONTROL = 209,
|
||||
LOGIN_TRIAL_EXPIRED = 210,
|
||||
LOGIN_ANTI_INDULGENCE = 211,
|
||||
LOGIN_INCORRECT_REGION = 212,
|
||||
LOGIN_LOCKED_ENFORCED = 213,
|
||||
LOGIN_CHARGEBACK = 214,
|
||||
LOGIN_IGR_WITHOUT_BNET = 215,
|
||||
LOGIN_UNLOCKABLE_LOCK = 216,
|
||||
LOGIN_IGR_REQUIRED = 217,
|
||||
LOGIN_PAYMENT_CHANGED = 218,
|
||||
LOGIN_INVALID_PAYMENT = 219,
|
||||
LOGIN_INVALID_ACCOUNT_STATE = 220
|
||||
};
|
||||
}
|
||||
|
||||
struct RealmBuildInfo
|
||||
{
|
||||
int Build;
|
||||
int MajorVersion;
|
||||
int MinorVersion;
|
||||
int BugfixVersion;
|
||||
int HotfixVersion;
|
||||
};
|
||||
|
||||
namespace AuthHelper
|
||||
{
|
||||
RealmBuildInfo const* GetBuildInfo(int build);
|
||||
bool IsBuildSupportingBattlenet(int build);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -15,8 +15,8 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BATTLENETPACKETCRYPT_H__
|
||||
#define __BATTLENETPACKETCRYPT_H__
|
||||
#ifndef BattlenetPacketCrypt_h__
|
||||
#define BattlenetPacketCrypt_h__
|
||||
|
||||
#include "PacketCrypt.h"
|
||||
|
||||
@@ -32,5 +32,5 @@ namespace Battlenet
|
||||
void Init(BigNumber* K) override;
|
||||
};
|
||||
}
|
||||
#endif // BattlenetPacketCrypt_h__
|
||||
|
||||
#endif // __BATTLENETPACKETCRYPT_H__
|
||||
115
src/server/bnetserver/CMakeLists.txt
Normal file
115
src/server/bnetserver/CMakeLists.txt
Normal file
@@ -0,0 +1,115 @@
|
||||
# Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
########### authserver ###############
|
||||
|
||||
file(GLOB_RECURSE sources_authentication Authentication/*.cpp Authentication/*.h)
|
||||
file(GLOB_RECURSE sources_realms Realms/*.cpp Realms/*.h)
|
||||
file(GLOB_RECURSE sources_server Server/*.cpp Server/*.h)
|
||||
file(GLOB_RECURSE sources_packets Packets/*.cpp Packets/*.h)
|
||||
file(GLOB sources_localdir *.cpp *.h)
|
||||
|
||||
if (USE_COREPCH)
|
||||
set(bnetserver_PCH_HDR PrecompiledHeaders/bnetPCH.h)
|
||||
set(bnetserver_PCH_SRC PrecompiledHeaders/bnetPCH.cpp)
|
||||
endif()
|
||||
|
||||
set(bnetserver_SRCS
|
||||
${bnetserver_SRCS}
|
||||
${sources_authentication}
|
||||
${sources_realms}
|
||||
${sources_server}
|
||||
${sources_packets}
|
||||
${sources_localdir}
|
||||
)
|
||||
|
||||
if( WIN32 )
|
||||
set(bnetserver_SRCS
|
||||
${bnetserver_SRCS}
|
||||
${sources_windows_Debugging}
|
||||
)
|
||||
if ( MSVC )
|
||||
set(bnetserver_SRCS
|
||||
${bnetserver_SRCS}
|
||||
bnetserver.rc
|
||||
)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Database
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Debugging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Packets
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography/Authentication
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Networking
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Authentication
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Realms
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Server
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Packets
|
||||
${MYSQL_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${VALGRIND_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
add_executable(bnetserver
|
||||
${bnetserver_SRCS}
|
||||
${bnetserver_PCH_SRC}
|
||||
)
|
||||
|
||||
add_dependencies(bnetserver revision.h)
|
||||
|
||||
if( NOT WIN32 )
|
||||
set_target_properties(bnetserver PROPERTIES
|
||||
COMPILE_DEFINITIONS _TRINITY_BNET_CONFIG="${CONF_DIR}/bnetserver.conf"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(bnetserver
|
||||
shared
|
||||
${MYSQL_LIBRARY}
|
||||
${OPENSSL_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${Boost_LIBRARIES}
|
||||
)
|
||||
|
||||
if( WIN32 )
|
||||
if ( MSVC )
|
||||
add_custom_command(TARGET bnetserver
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bnetserver.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
|
||||
)
|
||||
elseif ( MINGW )
|
||||
add_custom_command(TARGET bnetserver
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bnetserver.conf.dist ${CMAKE_BINARY_DIR}/bin/
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if( UNIX )
|
||||
install(TARGETS bnetserver DESTINATION bin)
|
||||
install(FILES bnetserver.conf.dist DESTINATION ${CONF_DIR})
|
||||
elseif( WIN32 )
|
||||
install(TARGETS bnetserver DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
install(FILES bnetserver.conf.dist DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
|
||||
# Generate precompiled header
|
||||
if (USE_COREPCH)
|
||||
add_cxx_pch(bnetserver ${bnetserver_PCH_HDR} ${bnetserver_PCH_SRC})
|
||||
endif()
|
||||
238
src/server/bnetserver/Main.cpp
Normal file
238
src/server/bnetserver/Main.cpp
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file main.cpp
|
||||
* @brief Authentication Server main program
|
||||
*
|
||||
* This file contains the main program for the
|
||||
* authentication server
|
||||
*/
|
||||
|
||||
#include "ComponentManager.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "SessionManager.h"
|
||||
#include "Common.h"
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Log.h"
|
||||
#include "ProcessPriority.h"
|
||||
#include "RealmList.h"
|
||||
#include "SystemConfig.h"
|
||||
#include "Util.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
using namespace boost::program_options;
|
||||
|
||||
#ifndef _TRINITY_BNET_CONFIG
|
||||
# define _TRINITY_BNET_CONFIG "authserver.conf"
|
||||
#endif
|
||||
|
||||
bool StartDB();
|
||||
void StopDB();
|
||||
void SignalHandler(const boost::system::error_code& error, int signalNumber);
|
||||
void KeepDatabaseAliveHandler(const boost::system::error_code& error);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile);
|
||||
|
||||
boost::asio::io_service _ioService;
|
||||
boost::asio::deadline_timer _dbPingTimer(_ioService);
|
||||
uint32 _dbPingInterval;
|
||||
LoginDatabaseWorkerPool LoginDatabase;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::string configFile = _TRINITY_BNET_CONFIG;
|
||||
auto vm = GetConsoleArguments(argc, argv, configFile);
|
||||
// exit if help is enabled
|
||||
if (vm.count("help"))
|
||||
return 0;
|
||||
|
||||
std::string configError;
|
||||
if (!sConfigMgr->LoadInitial(configFile, configError))
|
||||
{
|
||||
printf("Error in config file: %s\n", configError.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.bnetserver", "%s (bnetserver)", _FULLVERSION);
|
||||
TC_LOG_INFO("server.bnetserver", "<Ctrl-C> to stop.\n");
|
||||
TC_LOG_INFO("server.bnetserver", "Using configuration file %s.", configFile.c_str());
|
||||
TC_LOG_INFO("server.bnetserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
TC_LOG_INFO("server.bnetserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
|
||||
// authserver PID file creation
|
||||
std::string pidFile = sConfigMgr->GetStringDefault("PidFile", "");
|
||||
if (!pidFile.empty())
|
||||
{
|
||||
if (uint32 pid = CreatePIDFile(pidFile))
|
||||
TC_LOG_INFO("server.bnetserver", "Daemon PID: %u\n", pid);
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("server.bnetserver", "Cannot create PID file %s.\n", pidFile.c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the database connection
|
||||
if (!StartDB())
|
||||
return 1;
|
||||
|
||||
// Get the list of realms for the server
|
||||
sRealmList->Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
|
||||
if (sRealmList->size() == 0)
|
||||
{
|
||||
TC_LOG_ERROR("server.bnetserver", "No valid realms specified.");
|
||||
StopDB();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Start the listening port (acceptor) for auth connections
|
||||
int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119);
|
||||
if (bnport < 0 || bnport > 0xFFFF)
|
||||
{
|
||||
TC_LOG_ERROR("server.bnetserver", "Specified battle.net port (%d) out of allowed range (1-65535)", bnport);
|
||||
StopDB();
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
|
||||
sSessionMgr.StartNetwork(_ioService, bindIp, bnport);
|
||||
|
||||
// Set signal handlers
|
||||
boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
signals.add(SIGBREAK);
|
||||
#endif
|
||||
signals.async_wait(SignalHandler);
|
||||
|
||||
// Set process priority according to configuration settings
|
||||
SetProcessPriority("server.bnetserver");
|
||||
|
||||
// Enabled a timed callback for handling the database keep alive ping
|
||||
_dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer.async_wait(KeepDatabaseAliveHandler);
|
||||
|
||||
sComponentMgr->Load();
|
||||
sModuleMgr->Load();
|
||||
|
||||
// Start the io service worker loop
|
||||
_ioService.run();
|
||||
|
||||
// Close the Database Pool and library
|
||||
StopDB();
|
||||
|
||||
TC_LOG_INFO("server.bnetserver", "Halting process...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// Initialize connection to the database
|
||||
bool StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
std::string dbstring = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Database not specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 worker_threads = sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1);
|
||||
if (worker_threads < 1 || worker_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
|
||||
worker_threads = 1;
|
||||
}
|
||||
|
||||
int32 synch_threads = sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1);
|
||||
if (synch_threads < 1 || synch_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
|
||||
synch_threads = 1;
|
||||
}
|
||||
|
||||
// NOTE: While authserver is singlethreaded you should keep synch_threads == 1. Increasing it is just silly since only 1 will be used ever.
|
||||
if (!LoginDatabase.Open(dbstring, uint8(worker_threads), uint8(synch_threads)))
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Cannot connect to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.authserver", "Started auth database connection pool.");
|
||||
sLog->SetRealmId(0); // Enables DB appenders when realm is set.
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Close the connection to the database
|
||||
void StopDB()
|
||||
{
|
||||
LoginDatabase.Close();
|
||||
MySQL::Library_End();
|
||||
}
|
||||
|
||||
void SignalHandler(const boost::system::error_code& error, int /*signalNumber*/)
|
||||
{
|
||||
if (!error)
|
||||
_ioService.stop();
|
||||
}
|
||||
|
||||
void KeepDatabaseAliveHandler(const boost::system::error_code& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
TC_LOG_INFO("server.authserver", "Ping MySQL to keep connection alive");
|
||||
LoginDatabase.KeepAlive();
|
||||
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer.async_wait(KeepDatabaseAliveHandler);
|
||||
}
|
||||
}
|
||||
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile)
|
||||
{
|
||||
options_description all("Allowed options");
|
||||
all.add_options()
|
||||
("help,h", "print usage message")
|
||||
("config,c", value<std::string>(&configFile)->default_value(_TRINITY_BNET_CONFIG), "use <arg> as configuration file")
|
||||
;
|
||||
variables_map variablesMap;
|
||||
try
|
||||
{
|
||||
store(command_line_parser(argc, argv).options(all).allow_unregistered().run(), variablesMap);
|
||||
notify(variablesMap);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
std::cerr << e.what() << "\n";
|
||||
}
|
||||
|
||||
if (variablesMap.count("help")) {
|
||||
std::cout << all << "\n";
|
||||
}
|
||||
|
||||
return variablesMap;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef AchievementPackets_h__
|
||||
#define AchievementPackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
319
src/server/bnetserver/Packets/AuthenticationPackets.cpp
Normal file
319
src/server/bnetserver/Packets/AuthenticationPackets.cpp
Normal file
@@ -0,0 +1,319 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AuthenticationPackets.h"
|
||||
#include "Util.h"
|
||||
|
||||
void Battlenet::Authentication::LogonRequest::Read()
|
||||
{
|
||||
Program = _stream.ReadFourCC();
|
||||
Platform = _stream.ReadFourCC();
|
||||
Locale = _stream.ReadFourCC();
|
||||
|
||||
Components.resize(_stream.Read<uint32>(6));
|
||||
for (size_t i = 0; i < Components.size(); ++i)
|
||||
{
|
||||
Component& component = Components[i];
|
||||
component.Program = _stream.ReadFourCC();
|
||||
component.Platform = _stream.ReadFourCC();
|
||||
component.Build = _stream.Read<uint32>(32);
|
||||
}
|
||||
|
||||
if (_stream.Read<uint32>(1))
|
||||
Login = _stream.ReadString(9, 3);
|
||||
}
|
||||
|
||||
std::string Battlenet::Authentication::LogonRequest::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Authentication::LogonRequest Program: " << Program << ", Platform: " << Platform << ", Locale: " << Locale;
|
||||
for (Component const& component : Components)
|
||||
stream << std::endl << "Battlenet::Component Program: " << component.Program << ", Platform: " << component.Platform << ", Build: " << component.Build;
|
||||
|
||||
if (!Login.empty())
|
||||
stream << std::endl << "Battlenet::Authentication::LogonRequest Login: " << Login;
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::LogonRequest::CallHandler(Session* session) const
|
||||
{
|
||||
session->HandleLogonRequest(*this);
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::ResumeRequest::Read()
|
||||
{
|
||||
Program = _stream.ReadFourCC();
|
||||
Platform = _stream.ReadFourCC();
|
||||
Locale = _stream.ReadFourCC();
|
||||
|
||||
Components.resize(_stream.Read<uint32>(6));
|
||||
for (size_t i = 0; i < Components.size(); ++i)
|
||||
{
|
||||
Component& component = Components[i];
|
||||
component.Program = _stream.ReadFourCC();
|
||||
component.Platform = _stream.ReadFourCC();
|
||||
component.Build = _stream.Read<uint32>(32);
|
||||
}
|
||||
|
||||
Login = _stream.ReadString(9, 3);
|
||||
Region = _stream.Read<uint8>(8);
|
||||
GameAccountName = _stream.ReadString(5, 1);
|
||||
}
|
||||
|
||||
std::string Battlenet::Authentication::ResumeRequest::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Authentication::ResumeRequest Program: " << Program << ", Platform: " << Platform << ", Locale: " << Locale;
|
||||
for (Component const& component : Components)
|
||||
stream << std::endl << "Battlenet::Component Program: " << component.Program << ", Platform: " << component.Platform << ", Build: " << component.Build;
|
||||
|
||||
stream << std::endl << "Login: " << Login;
|
||||
stream << std::endl << "Region: " << uint32(Region);
|
||||
stream << std::endl << "GameAccountName: " << GameAccountName;
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::ResumeRequest::CallHandler(Session* session) const
|
||||
{
|
||||
session->HandleResumeRequest(*this);
|
||||
}
|
||||
|
||||
Battlenet::Authentication::ProofRequest::~ProofRequest()
|
||||
{
|
||||
for (size_t i = 0; i < Modules.size(); ++i)
|
||||
delete Modules[i];
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::ProofRequest::Write()
|
||||
{
|
||||
_stream.Write(Modules.size(), 3);
|
||||
for (ModuleInfo const* info : Modules)
|
||||
{
|
||||
_stream.WriteBytes(info->Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info->Region);
|
||||
_stream.WriteBytes(info->ModuleId, 32);
|
||||
_stream.Write(info->DataSize, 10);
|
||||
_stream.WriteBytes(info->Data, info->DataSize);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Battlenet::Authentication::ProofRequest::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Authentication::ProofRequest modules " << Modules.size();
|
||||
for (ModuleInfo const* module : Modules)
|
||||
stream << std::endl << "Battlenet::ModuleInfo Locale " << module->Region.c_str() << ", ModuleId " << ByteArrayToHexStr(module->ModuleId, 32) << ", DataSize " << module->DataSize << ", Data " << ByteArrayToHexStr(module->Data, module->DataSize);
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
Battlenet::Authentication::ProofResponse::~ProofResponse()
|
||||
{
|
||||
for (size_t i = 0; i < Modules.size(); ++i)
|
||||
delete Modules[i];
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::ProofResponse::Read()
|
||||
{
|
||||
Modules.resize(_stream.Read<uint32>(3));
|
||||
for (size_t i = 0; i < Modules.size(); ++i)
|
||||
{
|
||||
BitStream*& dataStream = Modules[i];
|
||||
dataStream = new BitStream(_stream.Read<uint32>(10));
|
||||
memcpy(dataStream->GetBuffer(), _stream.ReadBytes(dataStream->GetSize()).get(), dataStream->GetSize());
|
||||
}
|
||||
}
|
||||
|
||||
std::string Battlenet::Authentication::ProofResponse::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Authentication::ProofResponse Modules " << Modules.size();
|
||||
for (BitStream* module : Modules)
|
||||
{
|
||||
std::string hexStr = ByteArrayToHexStr(module->GetBuffer(), module->GetSize());
|
||||
stream << std::endl << "Battlenet::Authentication::ProofResponse::ModuleData Size: " << module->GetSize() << ", Data: " << hexStr;
|
||||
}
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::ProofResponse::CallHandler(Session* session) const
|
||||
{
|
||||
session->HandleProofResponse(*this);
|
||||
}
|
||||
|
||||
Battlenet::Authentication::LogonResponse::~LogonResponse()
|
||||
{
|
||||
for (ModuleInfo* m : Modules)
|
||||
delete m;
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::LogonResponse::Write()
|
||||
{
|
||||
_stream.Write(Result.ResultValue != ResponseFailure::UPDATE, 1);
|
||||
if (Result.ResultValue == ResponseFailure::UPDATE)
|
||||
{
|
||||
_stream.Write(Modules.size(), 3);
|
||||
for (size_t i = 0; i < Modules.size(); ++i)
|
||||
{
|
||||
ModuleInfo* info = Modules[i];
|
||||
_stream.WriteBytes(info->Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info->Region);
|
||||
_stream.WriteBytes(info->ModuleId, 32);
|
||||
_stream.Write(info->DataSize, 10);
|
||||
_stream.WriteBytes(info->Data, info->DataSize);
|
||||
}
|
||||
|
||||
_stream.Write(PingTimeout + std::numeric_limits<int32>::min(), 32);
|
||||
_stream.Write(1, 1); // RegulatorRules != NULL (not a pointer for us, always write)
|
||||
// if written == 1
|
||||
{
|
||||
_stream.Write(RegulatorRules.Type == Regulator::LEAKY_BUCKET, 1);
|
||||
if (RegulatorRules.Type == Regulator::LEAKY_BUCKET)
|
||||
{
|
||||
_stream.Write(RegulatorRules.Threshold, 32);
|
||||
_stream.Write(RegulatorRules.Rate, 32);
|
||||
}
|
||||
}
|
||||
|
||||
_stream.WriteString(FirstName, 8); // First name
|
||||
_stream.WriteString(LastName, 8); // Last name - not set for WoW
|
||||
|
||||
_stream.Write(AccountId, 32);
|
||||
_stream.Write(Region, 8);
|
||||
_stream.Write(Flags, 64);
|
||||
|
||||
_stream.Write(GameAccountRegion, 8);
|
||||
_stream.WriteString(GameAccountName, 5, -1);
|
||||
_stream.Write(GameAccountFlags, 64);
|
||||
|
||||
_stream.Write(FailedLogins, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stream.Write(!Modules.empty(), 1);
|
||||
if (!Modules.empty())
|
||||
{
|
||||
ModuleInfo* info = Modules[0];
|
||||
_stream.WriteBytes(info->Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info->Region);
|
||||
_stream.WriteBytes(info->ModuleId, 32);
|
||||
}
|
||||
|
||||
_stream.Write(Result.ResultValue, 2);
|
||||
if (Result.ResultValue == ResponseFailure::FAILURE)
|
||||
{
|
||||
_stream.Write(Result.Error, 16);
|
||||
_stream.Write(Result.Wait + std::numeric_limits<int32>::min(), 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string Battlenet::Authentication::LogonResponse::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Authentication::LogonResponse AuthResult " << Result.Error << " PingTimeout " << PingTimeout
|
||||
<< " RegulatorRules.Threshold " << RegulatorRules.Threshold << " RegulatorRules.Rate " << RegulatorRules.Rate
|
||||
<< " FirstName " << FirstName << " LastName " << LastName << " AccountId " << AccountId << " Region " << uint32(Region) << " GameAccountName " << GameAccountName
|
||||
<< " GameAccountFlags " << GameAccountFlags << " FailedLogins " << FailedLogins << " Modules " << Modules.size();
|
||||
|
||||
for (ModuleInfo const* module : Modules)
|
||||
stream << std::endl << "Battlenet::ModuleInfo Locale " << module->Region.c_str() << ", ModuleId " << ByteArrayToHexStr(module->ModuleId, 32) << ", DataSize " << module->DataSize << ", Data " << ByteArrayToHexStr(module->Data, module->DataSize);
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::LogonResponse::SetAuthResult(AuthResult result)
|
||||
{
|
||||
Result.ResultValue = result != AUTH_OK ? ResponseFailure::FAILURE : ResponseFailure::UPDATE;
|
||||
Result.Error = result;
|
||||
}
|
||||
|
||||
Battlenet::Authentication::ResumeResponse::~ResumeResponse()
|
||||
{
|
||||
for (ModuleInfo* m : Modules)
|
||||
delete m;
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::ResumeResponse::Write()
|
||||
{
|
||||
_stream.Write(Result.ResultValue != ResponseFailure::UPDATE, 1);
|
||||
if (Result.ResultValue == ResponseFailure::UPDATE)
|
||||
{
|
||||
_stream.Write(Modules.size(), 3);
|
||||
for (size_t i = 0; i < Modules.size(); ++i)
|
||||
{
|
||||
ModuleInfo* info = Modules[i];
|
||||
_stream.WriteBytes(info->Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info->Region);
|
||||
_stream.WriteBytes(info->ModuleId, 32);
|
||||
_stream.Write(info->DataSize, 10);
|
||||
_stream.WriteBytes(info->Data, info->DataSize);
|
||||
}
|
||||
|
||||
_stream.Write(PingTimeout + std::numeric_limits<int32>::min(), 32);
|
||||
_stream.Write(1, 1); // RegulatorRules != NULL (not a pointer for us, always write)
|
||||
// if written == 1
|
||||
{
|
||||
_stream.Write(RegulatorRules.Type == Regulator::LEAKY_BUCKET, 1);
|
||||
if (RegulatorRules.Type == Regulator::LEAKY_BUCKET)
|
||||
{
|
||||
_stream.Write(RegulatorRules.Threshold, 32);
|
||||
_stream.Write(RegulatorRules.Rate, 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_stream.Write(!Modules.empty(), 1);
|
||||
if (!Modules.empty())
|
||||
{
|
||||
ModuleInfo* info = Modules[0];
|
||||
_stream.WriteBytes(info->Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info->Region);
|
||||
_stream.WriteBytes(info->ModuleId, 32);
|
||||
}
|
||||
|
||||
_stream.Write(Result.ResultValue, 2);
|
||||
if (Result.ResultValue == ResponseFailure::FAILURE)
|
||||
{
|
||||
_stream.Write(Result.Error, 16);
|
||||
_stream.Write(Result.Wait + std::numeric_limits<int32>::min(), 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string Battlenet::Authentication::ResumeResponse::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Authentication::ResumeResponse AuthResult " << Result.Error << " PingTimeout " << PingTimeout
|
||||
<< " RegulatorRules.Threshold " << RegulatorRules.Threshold << " RegulatorRules.Rate " << RegulatorRules.Rate
|
||||
<< " Modules " << Modules.size();
|
||||
|
||||
for (ModuleInfo const* module : Modules)
|
||||
stream << std::endl << "Battlenet::ModuleInfo Locale " << module->Region.c_str() << ", ModuleId " << ByteArrayToHexStr(module->ModuleId, 32) << ", DataSize " << module->DataSize << ", Data " << ByteArrayToHexStr(module->Data, module->DataSize);
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void Battlenet::Authentication::ResumeResponse::SetAuthResult(AuthResult result)
|
||||
{
|
||||
Result.ResultValue = result != AUTH_OK ? ResponseFailure::FAILURE : ResponseFailure::UPDATE;
|
||||
Result.Error = result;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef AuthenticationPackets_h__
|
||||
#define AuthenticationPackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -15,7 +15,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlenetBitStream.h"
|
||||
#include "BitStream.h"
|
||||
|
||||
template<>
|
||||
bool Battlenet::BitStream::Read<bool>(uint32 /*bitCount*/)
|
||||
@@ -15,8 +15,8 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BATTLENETBITSTREAM_H__
|
||||
#define __BATTLENETBITSTREAM_H__
|
||||
#ifndef BitStream_h__
|
||||
#define BitStream_h__
|
||||
|
||||
#include "Common.h"
|
||||
#include "ByteConverter.h"
|
||||
@@ -240,4 +240,4 @@ namespace Battlenet
|
||||
void BitStream::Write<bool>(bool value, uint32 bitCount);
|
||||
}
|
||||
|
||||
#endif // __BATTLENETBITSTREAM_H__
|
||||
#endif // BitStream_h__
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef CachePackets_h__
|
||||
#define CachePackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef ChatPackets_h__
|
||||
#define ChatPackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -15,7 +15,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlenetSession.h"
|
||||
#include "Session.h"
|
||||
#include "ConnectionPackets.h"
|
||||
|
||||
std::string Battlenet::Connection::Ping::ToString() const
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef ConnectionPackets_h__
|
||||
#define ConnectionPackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -15,7 +15,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlenetSession.h"
|
||||
#include "Session.h"
|
||||
#include "FriendsPackets.h"
|
||||
|
||||
void Battlenet::Friends::SocialnetworkCheckConnected::Read()
|
||||
@@ -50,7 +50,7 @@ std::string Battlenet::Friends::SocialnetworkConnect::ToString() const
|
||||
|
||||
void Battlenet::Friends::SocialnetworkConnect::CallHandler(Session* session) const
|
||||
{
|
||||
|
||||
session->LogUnhandledPacket(*this);
|
||||
}
|
||||
|
||||
std::string Battlenet::Friends::SocialNetworkConnectResult::ToString() const
|
||||
@@ -60,7 +60,6 @@ std::string Battlenet::Friends::SocialNetworkConnectResult::ToString() const
|
||||
|
||||
void Battlenet::Friends::SocialNetworkConnectResult::Write()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string Battlenet::Friends::SocialNetworkCheckConnectedResult::ToString() const
|
||||
@@ -89,7 +88,7 @@ std::string Battlenet::Friends::GetFriendsOfFriend::ToString() const
|
||||
|
||||
void Battlenet::Friends::GetFriendsOfFriend::CallHandler(Session* session) const
|
||||
{
|
||||
|
||||
session->LogUnhandledPacket(*this);
|
||||
}
|
||||
|
||||
void Battlenet::Friends::RealIdFriendInvite::Read()
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef FriendsPackets_h__
|
||||
#define FriendsPackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -15,10 +15,10 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BattlenetPacketFactory_h__
|
||||
#define BattlenetPacketFactory_h__
|
||||
#ifndef PacketFactory_h__
|
||||
#define PacketFactory_h__
|
||||
|
||||
#include "BattlenetPackets.h"
|
||||
#include "Packets.h"
|
||||
#include <map>
|
||||
|
||||
namespace Battlenet
|
||||
@@ -60,12 +60,12 @@ namespace Battlenet
|
||||
_creators[PacketHeader(WoWRealm::CMSG_JOIN_REQUEST_V2, WOWREALM)] = &New<WoWRealm::JoinRequestV2>;
|
||||
|
||||
_creators[PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CHECK_CONNECTED, FRIENDS)] = &New<Friends::SocialnetworkCheckConnected>;
|
||||
// _creators[PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CONNECT, FRIENDS)] = &New<Friends::SocialnetworkConnect>;
|
||||
// _creators[PacketHeader(Friends::CMSG_GET_FRIENDS_OF_FRIEND, FRIENDS)] = &New<Friends::GetFriendsOfFriend>;
|
||||
_creators[PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CONNECT, FRIENDS)] = &New<Friends::SocialnetworkConnect>;
|
||||
_creators[PacketHeader(Friends::CMSG_GET_FRIENDS_OF_FRIEND, FRIENDS)] = &New<Friends::GetFriendsOfFriend>;
|
||||
_creators[PacketHeader(Friends::CMSG_REALID_FRIEND_INVITE, FRIENDS)] = &New<Friends::RealIdFriendInvite>;
|
||||
|
||||
// _creators[PacketHeader(Presence::CMSG_UPDATE_REQUEST, PRESENCE)] = &New<Presence::UpdateRequest>;
|
||||
// _creators[PacketHeader(Presence::CMSG_STATISTIC_SUBSCRIBE, PRESENCE)] = &New<Presence::StatisticSubscribe>;
|
||||
_creators[PacketHeader(Presence::CMSG_UPDATE_REQUEST, PRESENCE)] = &New<Presence::UpdateRequest>;
|
||||
_creators[PacketHeader(Presence::CMSG_STATISTIC_SUBSCRIBE, PRESENCE)] = &New<Presence::StatisticSubscribe>;
|
||||
}
|
||||
|
||||
template<class PacketType>
|
||||
@@ -78,6 +78,6 @@ namespace Battlenet
|
||||
};
|
||||
}
|
||||
|
||||
#define sBattlenetPacketFactory Battlenet::PacketFactory::Instance()
|
||||
#define sPacketFactory Battlenet::PacketFactory::Instance()
|
||||
|
||||
#endif // BattlenetPacketFactory_h__
|
||||
#endif // PacketFactory_h__
|
||||
@@ -15,8 +15,8 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BattlenetPackets_h__
|
||||
#define BattlenetPackets_h__
|
||||
#ifndef Packets_h__
|
||||
#define Packets_h__
|
||||
|
||||
#include "AuthenticationPackets.h"
|
||||
#include "ConnectionPackets.h"
|
||||
@@ -29,4 +29,4 @@
|
||||
#include "CachePackets.h"
|
||||
#include "ProfilePackets.h"
|
||||
|
||||
#endif // BattlenetPackets_h__
|
||||
#endif // Packets_h__
|
||||
@@ -15,7 +15,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlenetPackets.h"
|
||||
#include "Packets.h"
|
||||
#include <sstream>
|
||||
|
||||
std::string Battlenet::PacketHeader::ToString() const
|
||||
@@ -15,12 +15,11 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BattlenetPacketsBase_h__
|
||||
#define BattlenetPacketsBase_h__
|
||||
#ifndef PacketsBase_h__
|
||||
#define PacketsBase_h__
|
||||
|
||||
#include "AuthCodes.h"
|
||||
#include "BattlenetBitStream.h"
|
||||
#include "BattlenetManager.h"
|
||||
#include "BitStream.h"
|
||||
#include "Define.h"
|
||||
#include "Errors.h"
|
||||
#include <string>
|
||||
@@ -118,4 +117,4 @@ namespace Battlenet
|
||||
};
|
||||
}
|
||||
|
||||
#endif // BattlenetPacketsBase_h__
|
||||
#endif // PacketsBase_h__
|
||||
@@ -15,10 +15,9 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlenetSession.h"
|
||||
#include "Session.h"
|
||||
#include "PresencePackets.h"
|
||||
|
||||
|
||||
void Battlenet::Presence::UpdateRequest::Read()
|
||||
{
|
||||
|
||||
@@ -31,12 +30,11 @@ std::string Battlenet::Presence::UpdateRequest::ToString() const
|
||||
|
||||
void Battlenet::Presence::UpdateRequest::CallHandler(Session* session) const
|
||||
{
|
||||
|
||||
session->LogUnhandledPacket(*this);
|
||||
}
|
||||
|
||||
void Battlenet::Presence::StatisticSubscribe::Read()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string Battlenet::Presence::StatisticSubscribe::ToString() const
|
||||
@@ -46,5 +44,5 @@ std::string Battlenet::Presence::StatisticSubscribe::ToString() const
|
||||
|
||||
void Battlenet::Presence::StatisticSubscribe::CallHandler(Session* session) const
|
||||
{
|
||||
|
||||
session->LogUnhandledPacket(*this);
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef PresencePackets_h__
|
||||
#define PresencePackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef ProfilePackets_h__
|
||||
#define ProfilePackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef SupportPackets_h__
|
||||
#define SupportPackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "WoWRealmPackets.h"
|
||||
#include "BattlenetSession.h"
|
||||
#include "Session.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#ifndef WoWRealmPackets_h__
|
||||
#define WoWRealmPackets_h__
|
||||
|
||||
#include "BattlenetPacketsBase.h"
|
||||
#include "PacketsBase.h"
|
||||
#include "RealmList.h"
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
1
src/server/bnetserver/PrecompiledHeaders/bnetPCH.cpp
Normal file
1
src/server/bnetserver/PrecompiledHeaders/bnetPCH.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "bnetPCH.h"
|
||||
10
src/server/bnetserver/PrecompiledHeaders/bnetPCH.h
Normal file
10
src/server/bnetserver/PrecompiledHeaders/bnetPCH.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "Common.h"
|
||||
#include "Configuration/Config.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "Log.h"
|
||||
#include "ComponentManager.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "RealmList.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "Packets.h"
|
||||
#include "Session.h"
|
||||
207
src/server/bnetserver/Realms/RealmList.cpp
Normal file
207
src/server/bnetserver/Realms/RealmList.cpp
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include "Common.h"
|
||||
#include "RealmList.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "Util.h"
|
||||
|
||||
ip::tcp::endpoint Realm::GetAddressForClient(ip::address const& clientAddr) const
|
||||
{
|
||||
ip::address realmIp;
|
||||
|
||||
// Attempt to send best address for client
|
||||
if (clientAddr.is_loopback())
|
||||
{
|
||||
// Try guessing if realm is also connected locally
|
||||
if (LocalAddress.is_loopback() || ExternalAddress.is_loopback())
|
||||
realmIp = clientAddr;
|
||||
else
|
||||
{
|
||||
// Assume that user connecting from the machine that authserver is located on
|
||||
// has all realms available in his local network
|
||||
realmIp = LocalAddress;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clientAddr.is_v4() &&
|
||||
(clientAddr.to_v4().to_ulong() & LocalSubnetMask.to_v4().to_ulong()) ==
|
||||
(LocalAddress.to_v4().to_ulong() & LocalSubnetMask.to_v4().to_ulong()))
|
||||
{
|
||||
realmIp = LocalAddress;
|
||||
}
|
||||
else
|
||||
realmIp = ExternalAddress;
|
||||
}
|
||||
|
||||
ip::tcp::endpoint endpoint(realmIp, port);
|
||||
|
||||
// Return external IP
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)), _resolver(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
RealmList::~RealmList()
|
||||
{
|
||||
delete _resolver;
|
||||
}
|
||||
|
||||
// Load the realm list from the database
|
||||
void RealmList::Initialize(boost::asio::io_service& ioService, uint32 updateInterval)
|
||||
{
|
||||
_resolver = new boost::asio::ip::tcp::resolver(ioService);
|
||||
m_UpdateInterval = updateInterval;
|
||||
|
||||
// Get the content of the realmlist table in the database
|
||||
UpdateRealms(true);
|
||||
}
|
||||
|
||||
void RealmList::UpdateRealm(uint32 id, const std::string& name, ip::address const& address, ip::address const& localAddr,
|
||||
ip::address const& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population, uint32 build, uint8 region, uint8 battlegroup)
|
||||
{
|
||||
// Create new if not exist or update existed
|
||||
Realm& realm = m_realms[name];
|
||||
|
||||
realm.m_ID = id;
|
||||
realm.name = name;
|
||||
realm.icon = icon;
|
||||
realm.flag = flag;
|
||||
realm.timezone = timezone;
|
||||
realm.allowedSecurityLevel = allowedSecurityLevel;
|
||||
realm.populationLevel = population;
|
||||
|
||||
// Append port to IP address.
|
||||
|
||||
realm.ExternalAddress = address;
|
||||
realm.LocalAddress = localAddr;
|
||||
realm.LocalSubnetMask = localSubmask;
|
||||
realm.port = port;
|
||||
realm.gamebuild = build;
|
||||
realm.Region = region;
|
||||
realm.Battlegroup = battlegroup;
|
||||
}
|
||||
|
||||
void RealmList::UpdateIfNeed()
|
||||
{
|
||||
// maybe disabled or updated recently
|
||||
if (!m_UpdateInterval || m_NextUpdateTime > time(NULL))
|
||||
return;
|
||||
|
||||
m_NextUpdateTime = time(NULL) + m_UpdateInterval;
|
||||
|
||||
// Clears Realm list
|
||||
m_realms.clear();
|
||||
|
||||
// Get the content of the realmlist table in the database
|
||||
UpdateRealms();
|
||||
}
|
||||
|
||||
void RealmList::UpdateRealms(bool init)
|
||||
{
|
||||
TC_LOG_INFO("server.authserver", "Updating Realm List...");
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_REALMLIST);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
// Circle through results and add them to the realm map
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
uint32 realmId = fields[0].GetUInt32();
|
||||
std::string name = fields[1].GetString();
|
||||
boost::asio::ip::tcp::resolver::query externalAddressQuery(ip::tcp::v4(), fields[2].GetString(), "");
|
||||
|
||||
boost::system::error_code ec;
|
||||
boost::asio::ip::tcp::resolver::iterator endPoint = _resolver->resolve(externalAddressQuery, ec);
|
||||
if (endPoint == end || ec)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Could not resolve address %s", fields[2].GetString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
ip::address externalAddress = (*endPoint).endpoint().address();
|
||||
|
||||
boost::asio::ip::tcp::resolver::query localAddressQuery(ip::tcp::v4(), fields[3].GetString(), "");
|
||||
endPoint = _resolver->resolve(localAddressQuery, ec);
|
||||
if (endPoint == end || ec)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Could not resolve address %s", fields[3].GetString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
ip::address localAddress = (*endPoint).endpoint().address();
|
||||
|
||||
boost::asio::ip::tcp::resolver::query localSubmaskQuery(ip::tcp::v4(), fields[4].GetString(), "");
|
||||
endPoint = _resolver->resolve(localSubmaskQuery, ec);
|
||||
if (endPoint == end || ec)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Could not resolve address %s", fields[4].GetString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
ip::address localSubmask = (*endPoint).endpoint().address();
|
||||
|
||||
uint16 port = fields[5].GetUInt16();
|
||||
uint8 icon = fields[6].GetUInt8();
|
||||
RealmFlags flag = RealmFlags(fields[7].GetUInt8());
|
||||
uint8 timezone = fields[8].GetUInt8();
|
||||
uint8 allowedSecurityLevel = fields[9].GetUInt8();
|
||||
float pop = fields[10].GetFloat();
|
||||
uint32 build = fields[11].GetUInt32();
|
||||
uint8 region = fields[12].GetUInt8();
|
||||
uint8 battlegroup = fields[13].GetUInt8();
|
||||
|
||||
UpdateRealm(realmId, name, externalAddress, localAddress, localSubmask, port, icon, flag, timezone,
|
||||
(allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build, region, battlegroup);
|
||||
|
||||
if (init)
|
||||
TC_LOG_INFO("server.authserver", "Added realm \"%s\" at %s:%u.", name.c_str(), m_realms[name].ExternalAddress.to_string().c_str(), port);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Realmlist::UpdateRealms has thrown an exception: %s", ex.what());
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
||||
Realm const* RealmList::GetRealm(Battlenet::RealmId const& id) const
|
||||
{
|
||||
auto itr = std::find_if(m_realms.begin(), m_realms.end(), [id](RealmMap::value_type const& pair)
|
||||
{
|
||||
return pair.second.Region == id.Region && pair.second.Battlegroup == id.Battlegroup && pair.second.m_ID == id.Index;
|
||||
});
|
||||
|
||||
if (itr != m_realms.end())
|
||||
return &itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
113
src/server/bnetserver/Realms/RealmList.h
Normal file
113
src/server/bnetserver/Realms/RealmList.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _REALMLIST_H
|
||||
#define _REALMLIST_H
|
||||
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include "Common.h"
|
||||
|
||||
using namespace boost::asio;
|
||||
|
||||
enum RealmFlags
|
||||
{
|
||||
REALM_FLAG_NONE = 0x00,
|
||||
REALM_FLAG_INVALID = 0x01,
|
||||
REALM_FLAG_OFFLINE = 0x02,
|
||||
REALM_FLAG_SPECIFYBUILD = 0x04,
|
||||
REALM_FLAG_UNK1 = 0x08,
|
||||
REALM_FLAG_UNK2 = 0x10,
|
||||
REALM_FLAG_RECOMMENDED = 0x20,
|
||||
REALM_FLAG_NEW = 0x40,
|
||||
REALM_FLAG_FULL = 0x80
|
||||
};
|
||||
|
||||
// Storage object for a realm
|
||||
struct Realm
|
||||
{
|
||||
ip::address ExternalAddress;
|
||||
ip::address LocalAddress;
|
||||
ip::address LocalSubnetMask;
|
||||
uint16 port;
|
||||
std::string name;
|
||||
uint8 icon;
|
||||
RealmFlags flag;
|
||||
uint8 timezone;
|
||||
uint32 m_ID;
|
||||
AccountTypes allowedSecurityLevel;
|
||||
float populationLevel;
|
||||
uint32 gamebuild;
|
||||
uint8 Region;
|
||||
uint8 Battlegroup;
|
||||
|
||||
ip::tcp::endpoint GetAddressForClient(ip::address const& clientAddr) const;
|
||||
};
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
struct RealmId
|
||||
{
|
||||
uint8 Region;
|
||||
uint8 Battlegroup;
|
||||
uint32 Index;
|
||||
uint32 Build;
|
||||
};
|
||||
}
|
||||
|
||||
/// Storage object for the list of realms on the server
|
||||
class RealmList
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, Realm> RealmMap;
|
||||
|
||||
static RealmList* instance()
|
||||
{
|
||||
static RealmList instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
~RealmList();
|
||||
|
||||
void Initialize(boost::asio::io_service& ioService, uint32 updateInterval);
|
||||
|
||||
void UpdateIfNeed();
|
||||
|
||||
void AddRealm(const Realm& NewRealm) { m_realms[NewRealm.name] = NewRealm; }
|
||||
|
||||
RealmMap::const_iterator begin() const { return m_realms.begin(); }
|
||||
RealmMap::const_iterator end() const { return m_realms.end(); }
|
||||
uint32 size() const { return m_realms.size(); }
|
||||
Realm const* GetRealm(Battlenet::RealmId const& id) const;
|
||||
|
||||
private:
|
||||
RealmList();
|
||||
|
||||
void UpdateRealms(bool init = false);
|
||||
void UpdateRealm(uint32 id, const std::string& name, ip::address const& address, ip::address const& localAddr,
|
||||
ip::address const& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population, uint32 build, uint8 region, uint8 battlegroup);
|
||||
|
||||
RealmMap m_realms;
|
||||
uint32 m_UpdateInterval;
|
||||
time_t m_NextUpdateTime;
|
||||
boost::asio::ip::tcp::resolver* _resolver;
|
||||
};
|
||||
|
||||
#define sRealmList RealmList::instance()
|
||||
#endif
|
||||
55
src/server/bnetserver/Server/ComponentManager.cpp
Normal file
55
src/server/bnetserver/Server/ComponentManager.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ComponentManager.h"
|
||||
#include "DatabaseEnv.h"
|
||||
|
||||
Battlenet::ComponentMgr::~ComponentMgr()
|
||||
{
|
||||
for (Component* component : _components)
|
||||
delete component;
|
||||
}
|
||||
|
||||
void Battlenet::ComponentMgr::Load()
|
||||
{
|
||||
QueryResult result = LoginDatabase.Query("SELECT Program, Platform, Build FROM battlenet_components");
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
Component* component = new Component();
|
||||
component->Program = fields[0].GetString();
|
||||
component->Platform = fields[1].GetString();
|
||||
component->Build = fields[2].GetUInt32();
|
||||
|
||||
_components.insert(component);
|
||||
_programs.insert(component->Program);
|
||||
_platforms.insert(component->Platform);
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
||||
bool Battlenet::ComponentMgr::HasComponent(Battlenet::Component const* component) const
|
||||
{
|
||||
for (Component const* c : _components)
|
||||
if (component->Program == c->Program && component->Platform == c->Platform && component->Build == c->Build)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
61
src/server/bnetserver/Server/ComponentManager.h
Normal file
61
src/server/bnetserver/Server/ComponentManager.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ComponentManager_h__
|
||||
#define ComponentManager_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
struct Component
|
||||
{
|
||||
std::string Program;
|
||||
std::string Platform;
|
||||
uint32 Build;
|
||||
};
|
||||
|
||||
class ComponentMgr
|
||||
{
|
||||
ComponentMgr() { }
|
||||
~ComponentMgr();
|
||||
|
||||
public:
|
||||
void Load();
|
||||
bool HasComponent(Component const* component) const;
|
||||
bool HasProgram(std::string const& program) const { return _programs.count(program) != 0; }
|
||||
bool HasPlatform(std::string const& platform) const { return _platforms.count(platform) != 0; }
|
||||
|
||||
static ComponentMgr* instance()
|
||||
{
|
||||
static ComponentMgr instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
private:
|
||||
std::set<Component*> _components;
|
||||
std::set<std::string> _programs;
|
||||
std::set<std::string> _platforms;
|
||||
};
|
||||
}
|
||||
|
||||
#define sComponentMgr Battlenet::ComponentMgr::instance()
|
||||
|
||||
#endif // ComponentManager_h__
|
||||
@@ -15,46 +15,16 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlenetManager.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "DatabaseEnv.h"
|
||||
|
||||
BattlenetMgr::~BattlenetMgr()
|
||||
Battlenet::ModuleManager::~ModuleManager()
|
||||
{
|
||||
for (Battlenet::Component* component : _components)
|
||||
delete component;
|
||||
|
||||
for (auto const& m : _modules)
|
||||
delete m.second;
|
||||
}
|
||||
|
||||
void BattlenetMgr::Load()
|
||||
{
|
||||
LoadComponents();
|
||||
LoadModules();
|
||||
}
|
||||
|
||||
void BattlenetMgr::LoadComponents()
|
||||
{
|
||||
QueryResult result = LoginDatabase.Query("SELECT Program, Platform, Build FROM battlenet_components");
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
Battlenet::Component* component = new Battlenet::Component();
|
||||
component->Program = fields[0].GetString();
|
||||
component->Platform = fields[1].GetString();
|
||||
component->Build = fields[2].GetUInt32();
|
||||
|
||||
_components.insert(component);
|
||||
_programs.insert(component->Program);
|
||||
_platforms.insert(component->Platform);
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
||||
void BattlenetMgr::LoadModules()
|
||||
void Battlenet::ModuleManager::Load()
|
||||
{
|
||||
QueryResult result = LoginDatabase.Query("SELECT `Hash`, `Name`, `Type`, `System`, `Data` FROM battlenet_modules");
|
||||
if (result)
|
||||
@@ -62,7 +32,7 @@ void BattlenetMgr::LoadModules()
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
Battlenet::ModuleInfo* module = new Battlenet::ModuleInfo();
|
||||
ModuleInfo* module = new ModuleInfo();
|
||||
module->Type = fields[2].GetString();
|
||||
HexStrToByteArray(fields[0].GetString(), module->ModuleId);
|
||||
std::string data = fields[4].GetString();
|
||||
@@ -78,19 +48,10 @@ void BattlenetMgr::LoadModules()
|
||||
}
|
||||
}
|
||||
|
||||
bool BattlenetMgr::HasComponent(Battlenet::Component const* component) const
|
||||
Battlenet::ModuleInfo* Battlenet::ModuleManager::CreateModule(std::string const& os, std::string const& name) const
|
||||
{
|
||||
for (Battlenet::Component const* c : _components)
|
||||
if (component->Program == c->Program && component->Platform == c->Platform && component->Build == c->Build)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Battlenet::ModuleInfo* BattlenetMgr::CreateModule(std::string const& os, std::string const& name) const
|
||||
{
|
||||
Battlenet::ModuleKey key { os, name };
|
||||
ModuleKey key { os, name };
|
||||
ASSERT(_modules.count(key));
|
||||
|
||||
return new Battlenet::ModuleInfo(*_modules.at(key));
|
||||
return new ModuleInfo(*_modules.at(key));
|
||||
}
|
||||
@@ -15,24 +15,16 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BATTLENETMANAGER_H__
|
||||
#define __BATTLENETMANAGER_H__
|
||||
#ifndef ModuleManager_h__
|
||||
#define ModuleManager_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
struct Component
|
||||
{
|
||||
std::string Program;
|
||||
std::string Platform;
|
||||
uint32 Build;
|
||||
};
|
||||
|
||||
struct ModuleKey
|
||||
{
|
||||
std::string Platform;
|
||||
@@ -74,43 +66,29 @@ namespace Battlenet
|
||||
uint8* Data;
|
||||
};
|
||||
|
||||
struct RealmId
|
||||
class ModuleManager
|
||||
{
|
||||
uint8 Region;
|
||||
uint8 Battlegroup;
|
||||
uint32 Index;
|
||||
uint32 Build;
|
||||
ModuleManager() { }
|
||||
~ModuleManager();
|
||||
|
||||
public:
|
||||
void Load();
|
||||
ModuleInfo* CreateModule(std::string const& os, std::string const& name) const;
|
||||
|
||||
static ModuleManager* instance()
|
||||
{
|
||||
static ModuleManager instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
private:
|
||||
void LoadComponents();
|
||||
void LoadModules();
|
||||
|
||||
std::map<ModuleKey, ModuleInfo*> _modules;
|
||||
};
|
||||
}
|
||||
|
||||
class BattlenetMgr
|
||||
{
|
||||
BattlenetMgr() { }
|
||||
~BattlenetMgr();
|
||||
#define sModuleMgr Battlenet::ModuleManager::instance()
|
||||
|
||||
public:
|
||||
void Load();
|
||||
bool HasComponent(Battlenet::Component const* component) const;
|
||||
bool HasProgram(std::string const& program) const { return _programs.count(program) != 0; }
|
||||
bool HasPlatform(std::string const& platform) const { return _platforms.count(platform) != 0; }
|
||||
Battlenet::ModuleInfo* CreateModule(std::string const& os, std::string const& name) const;
|
||||
|
||||
static BattlenetMgr* instance()
|
||||
{
|
||||
static BattlenetMgr instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
private:
|
||||
void LoadComponents();
|
||||
void LoadModules();
|
||||
|
||||
std::set<Battlenet::Component*> _components;
|
||||
std::set<std::string> _programs;
|
||||
std::set<std::string> _platforms;
|
||||
std::map<Battlenet::ModuleKey, Battlenet::ModuleInfo*> _modules;
|
||||
};
|
||||
|
||||
#define sBattlenetMgr BattlenetMgr::instance()
|
||||
|
||||
#endif // __BATTLENETMANAGER_H__
|
||||
#endif // ModuleManager_h__
|
||||
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
#include "AuthCodes.h"
|
||||
#include "BattlenetBitStream.h"
|
||||
#include "BattlenetPacketFactory.h"
|
||||
#include "BattlenetSessionManager.h"
|
||||
#include "BitStream.h"
|
||||
#include "PacketFactory.h"
|
||||
#include "SessionManager.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "HmacHash.h"
|
||||
#include "Log.h"
|
||||
@@ -63,7 +63,7 @@ Battlenet::Session::Session(tcp::socket&& socket) : Socket(std::move(socket)), _
|
||||
|
||||
Battlenet::Session::~Session()
|
||||
{
|
||||
sBattlenetSessionMgr.RemoveSession(this);
|
||||
sSessionMgr.RemoveSession(this);
|
||||
TC_LOG_TRACE("server.battlenet", "Battlenet::Session::OnClose");
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
Authentication::LogonResponse* complete = new Authentication::LogonResponse();
|
||||
complete->SetAuthResult(LOGIN_BANNED);
|
||||
AsyncWrite(complete);
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Banned ip '%s:%d' tries to login!", ip_address.c_str(), GetRemotePort());
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Banned ip '%s:%d' tries to login!", ip_address.c_str(), GetRemotePort());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sBattlenetMgr->HasPlatform(info.Platform))
|
||||
if (!sComponentMgr->HasPlatform(info.Platform))
|
||||
{
|
||||
Authentication::LogonResponse* complete = new Authentication::LogonResponse();
|
||||
complete->SetAuthResult(AUTH_INVALID_OS);
|
||||
@@ -127,7 +127,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sBattlenetMgr->HasPlatform(info.Locale))
|
||||
if (!sComponentMgr->HasPlatform(info.Locale))
|
||||
{
|
||||
Authentication::LogonResponse* complete = new Authentication::LogonResponse();
|
||||
complete->SetAuthResult(AUTH_UNSUPPORTED_LANGUAGE);
|
||||
@@ -137,12 +137,12 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
|
||||
for (Component const& component : info.Components)
|
||||
{
|
||||
if (!sBattlenetMgr->HasComponent(&component))
|
||||
if (!sComponentMgr->HasComponent(&component))
|
||||
{
|
||||
Authentication::LogonResponse* complete = new Authentication::LogonResponse();
|
||||
if (!sBattlenetMgr->HasProgram(component.Program))
|
||||
if (!sComponentMgr->HasProgram(component.Program))
|
||||
complete->SetAuthResult(AUTH_INVALID_PROGRAM);
|
||||
else if (!sBattlenetMgr->HasPlatform(component.Platform))
|
||||
else if (!sComponentMgr->HasPlatform(component.Platform))
|
||||
complete->SetAuthResult(AUTH_INVALID_OS);
|
||||
else
|
||||
{
|
||||
@@ -184,7 +184,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
// If the IP is 'locked', check that the player comes indeed from the correct IP address
|
||||
if (fields[2].GetUInt8() == 1) // if ip is locked
|
||||
{
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is locked to IP - '%s' is logging in from '%s'", _accountName.c_str(), fields[4].GetCString(), ip_address.c_str());
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Account '%s' is locked to IP - '%s' is logging in from '%s'", _accountName.c_str(), fields[4].GetCString(), ip_address.c_str());
|
||||
|
||||
if (strcmp(fields[4].GetCString(), ip_address.c_str()) != 0)
|
||||
{
|
||||
@@ -196,10 +196,10 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is not locked to ip", _accountName.c_str());
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Account '%s' is not locked to ip", _accountName.c_str());
|
||||
std::string accountCountry = fields[3].GetString();
|
||||
if (accountCountry.empty() || accountCountry == "00")
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is not locked to country", _accountName.c_str());
|
||||
TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Account '%s' is not locked to country", _accountName.c_str());
|
||||
else if (!accountCountry.empty())
|
||||
{
|
||||
uint32 ip = inet_addr(ip_address.c_str());
|
||||
@@ -237,7 +237,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
Authentication::LogonResponse* complete = new Authentication::LogonResponse();
|
||||
complete->SetAuthResult(LOGIN_BANNED);
|
||||
AsyncWrite(complete);
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::LogonRequest] Banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -245,7 +245,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
Authentication::LogonResponse* complete = new Authentication::LogonResponse();
|
||||
complete->SetAuthResult(LOGIN_SUSPENDED);
|
||||
AsyncWrite(complete);
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Temporarily banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::LogonRequest] Temporarily banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -256,8 +256,8 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
|
||||
|
||||
I.SetBinary(sha.GetDigest(), sha.GetLength());
|
||||
|
||||
ModuleInfo* password = sBattlenetMgr->CreateModule(_os, "Password");
|
||||
ModuleInfo* thumbprint = sBattlenetMgr->CreateModule(_os, "Thumbprint");
|
||||
ModuleInfo* password = sModuleMgr->CreateModule(_os, "Password");
|
||||
ModuleInfo* thumbprint = sModuleMgr->CreateModule(_os, "Thumbprint");
|
||||
|
||||
std::string pStr = fields[0].GetString();
|
||||
|
||||
@@ -327,8 +327,8 @@ void Battlenet::Session::HandleResumeRequest(Authentication::ResumeRequest const
|
||||
_gameAccountId = fields[2].GetUInt32();
|
||||
_gameAccountName = reconnect.GameAccountName;
|
||||
|
||||
ModuleInfo* thumbprint = sBattlenetMgr->CreateModule(_os, "Thumbprint");
|
||||
ModuleInfo* resume = sBattlenetMgr->CreateModule(_os, "Resume");
|
||||
ModuleInfo* thumbprint = sModuleMgr->CreateModule(_os, "Thumbprint");
|
||||
ModuleInfo* resume = sModuleMgr->CreateModule(_os, "Resume");
|
||||
BitStream resumeData;
|
||||
uint8 state = 0;
|
||||
_reconnectProof.SetRand(16 * 8);
|
||||
@@ -419,19 +419,15 @@ void Battlenet::Session::HandleListSubscribeRequest(WoWRealm::ListSubscribeReque
|
||||
{
|
||||
Realm const& realm = i->second;
|
||||
|
||||
uint32 flag = realm.flag;
|
||||
uint32 flag = realm.flag & ~REALM_FLAG_SPECIFYBUILD;
|
||||
RealmBuildInfo const* buildInfo = AuthHelper::GetBuildInfo(realm.gamebuild);
|
||||
if (realm.gamebuild != _build)
|
||||
{
|
||||
if (!buildInfo)
|
||||
continue;
|
||||
|
||||
flag |= REALM_FLAG_OFFLINE | REALM_FLAG_SPECIFYBUILD; // tell the client what build the realm is for
|
||||
flag |= REALM_FLAG_INVALID;
|
||||
if (buildInfo)
|
||||
flag |= REALM_FLAG_SPECIFYBUILD; // tell the client what build the realm is for
|
||||
}
|
||||
|
||||
if (!buildInfo)
|
||||
flag &= ~REALM_FLAG_SPECIFYBUILD;
|
||||
|
||||
WoWRealm::ListUpdate* update = new WoWRealm::ListUpdate();
|
||||
update->Timezone = realm.timezone;
|
||||
update->Population = realm.populationLevel;
|
||||
@@ -523,7 +519,7 @@ void Battlenet::Session::ReadHandler()
|
||||
return;
|
||||
}
|
||||
|
||||
if (ClientPacket* packet = sBattlenetPacketFactory.Create(header, stream))
|
||||
if (ClientPacket* packet = sPacketFactory.Create(header, stream))
|
||||
{
|
||||
TC_LOG_TRACE("server.battlenet", "Battlenet::Session::ReadDataHandler %s", packet->ToString().c_str());
|
||||
packet->CallHandler(this);
|
||||
@@ -724,7 +720,7 @@ bool Battlenet::Session::HandlePasswordModule(BitStream* dataStream, ServerPacke
|
||||
serverProof.SetRand(128 * 8); // just send garbage, server signature check is patched out in client
|
||||
|
||||
BitStream stream;
|
||||
ModuleInfo* password = sBattlenetMgr->CreateModule(_os, "Password");
|
||||
ModuleInfo* password = sModuleMgr->CreateModule(_os, "Password");
|
||||
uint8 state = 3;
|
||||
|
||||
stream.WriteBytes(&state, 1);
|
||||
@@ -757,7 +753,7 @@ bool Battlenet::Session::HandlePasswordModule(BitStream* dataStream, ServerPacke
|
||||
accounts.WriteString(name.str(), 8);
|
||||
} while (result->NextRow());
|
||||
|
||||
ModuleInfo* selectGameAccount = sBattlenetMgr->CreateModule(_os, "SelectGameAccount");
|
||||
ModuleInfo* selectGameAccount = sModuleMgr->CreateModule(_os, "SelectGameAccount");
|
||||
selectGameAccount->DataSize = accounts.GetSize();
|
||||
selectGameAccount->Data = new uint8[selectGameAccount->DataSize];
|
||||
memcpy(selectGameAccount->Data, accounts.GetBuffer(), selectGameAccount->DataSize);
|
||||
@@ -774,12 +770,12 @@ bool Battlenet::Session::HandlePasswordModule(BitStream* dataStream, ServerPacke
|
||||
if (fields[2].GetUInt32() == fields[3].GetUInt32())
|
||||
{
|
||||
complete->SetAuthResult(LOGIN_BANNED);
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::Password] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
complete->SetAuthResult(LOGIN_SUSPENDED);
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
|
||||
TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::Password] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
|
||||
}
|
||||
|
||||
ReplaceResponse(response, complete);
|
||||
@@ -789,7 +785,7 @@ bool Battlenet::Session::HandlePasswordModule(BitStream* dataStream, ServerPacke
|
||||
_gameAccountId = fields[0].GetUInt32();
|
||||
_gameAccountName = fields[1].GetString();
|
||||
|
||||
request->Modules.push_back(sBattlenetMgr->CreateModule(_os, "RiskFingerprint"));
|
||||
request->Modules.push_back(sModuleMgr->CreateModule(_os, "RiskFingerprint"));
|
||||
_modulesWaitingForData.push(MODULE_RISK_FINGERPRINT);
|
||||
}
|
||||
|
||||
@@ -862,7 +858,7 @@ bool Battlenet::Session::HandleSelectGameAccountModule(BitStream* dataStream, Se
|
||||
_gameAccountName = fields[1].GetString();
|
||||
|
||||
Authentication::ProofRequest* request = new Authentication::ProofRequest();
|
||||
request->Modules.push_back(sBattlenetMgr->CreateModule(_os, "RiskFingerprint"));
|
||||
request->Modules.push_back(sModuleMgr->CreateModule(_os, "RiskFingerprint"));
|
||||
ReplaceResponse(response, request);
|
||||
|
||||
_modulesWaitingForData.push(MODULE_RISK_FINGERPRINT);
|
||||
@@ -900,7 +896,7 @@ bool Battlenet::Session::HandleRiskFingerprintModule(BitStream* dataStream, Serv
|
||||
LoginDatabase.CommitTransaction(trans);
|
||||
|
||||
_authed = true;
|
||||
sBattlenetSessionMgr.AddSession(this);
|
||||
sSessionMgr.AddSession(this);
|
||||
}
|
||||
else
|
||||
complete->SetAuthResult(AUTH_BAD_VERSION_HASH);
|
||||
@@ -976,7 +972,7 @@ bool Battlenet::Session::HandleResumeModule(BitStream* dataStream, ServerPacket*
|
||||
serverProof.UpdateData(clientChallenge.get(), 16);
|
||||
serverProof.Finalize();
|
||||
|
||||
ModuleInfo* resume = sBattlenetMgr->CreateModule(_os, "Resume");
|
||||
ModuleInfo* resume = sModuleMgr->CreateModule(_os, "Resume");
|
||||
|
||||
BitStream resumeData;
|
||||
uint8 state = 2;
|
||||
@@ -991,7 +987,7 @@ bool Battlenet::Session::HandleResumeModule(BitStream* dataStream, ServerPacket*
|
||||
result->Modules.push_back(resume);
|
||||
ReplaceResponse(response, result);
|
||||
_authed = true;
|
||||
sBattlenetSessionMgr.AddSession(this);
|
||||
sSessionMgr.AddSession(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _BATTLENETSOCKET_H
|
||||
#define _BATTLENETSOCKET_H
|
||||
#ifndef Session_h__
|
||||
#define Session_h__
|
||||
|
||||
#include "BattlenetPackets.h"
|
||||
#include "Packets.h"
|
||||
#include "BattlenetPacketCrypt.h"
|
||||
#include "Socket.h"
|
||||
#include "BigNumber.h"
|
||||
@@ -125,4 +125,4 @@ namespace Battlenet
|
||||
|
||||
}
|
||||
|
||||
#endif // _BATTLENETSOCKET_H
|
||||
#endif // Session_h__
|
||||
@@ -15,7 +15,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlenetSessionManager.h"
|
||||
#include "SessionManager.h"
|
||||
|
||||
bool Battlenet::SessionManager::StartNetwork(boost::asio::io_service& service, std::string const& bindIp, uint16 port)
|
||||
{
|
||||
@@ -33,5 +33,5 @@ NetworkThread<Battlenet::Session>* Battlenet::SessionManager::CreateThreads() co
|
||||
|
||||
void Battlenet::SessionManager::OnSocketAccept(tcp::socket&& sock)
|
||||
{
|
||||
sBattlenetSessionMgr.OnSocketOpen(std::forward<tcp::socket>(sock));
|
||||
sSessionMgr.OnSocketOpen(std::forward<tcp::socket>(sock));
|
||||
}
|
||||
@@ -15,10 +15,10 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BattlenetSessionManager_h__
|
||||
#define BattlenetSessionManager_h__
|
||||
#ifndef SessionManager_h__
|
||||
#define SessionManager_h__
|
||||
|
||||
#include "BattlenetSession.h"
|
||||
#include "Session.h"
|
||||
#include "SocketMgr.h"
|
||||
|
||||
namespace Battlenet
|
||||
@@ -66,6 +66,6 @@ namespace Battlenet
|
||||
};
|
||||
}
|
||||
|
||||
#define sBattlenetSessionMgr Battlenet::SessionManager::Instance()
|
||||
#define sSessionMgr Battlenet::SessionManager::Instance()
|
||||
|
||||
#endif // BattlenetSessionManager_h__
|
||||
#endif // SessionManager_h__
|
||||
257
src/server/bnetserver/bnetserver.conf.dist
Normal file
257
src/server/bnetserver/bnetserver.conf.dist
Normal file
@@ -0,0 +1,257 @@
|
||||
###############################################
|
||||
# Trinity Core Auth Server configuration file #
|
||||
###############################################
|
||||
[authserver]
|
||||
|
||||
###################################################################################################
|
||||
# SECTION INDEX
|
||||
#
|
||||
# EXAMPLE CONFIG
|
||||
# AUTH SERVER SETTINGS
|
||||
# MYSQL SETTINGS
|
||||
# LOGGING SYSTEM SETTINGS
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
# EXAMPLE CONFIG
|
||||
#
|
||||
# Variable
|
||||
# Description: Brief description what the variable is doing.
|
||||
# Important: Annotation for important things about this variable.
|
||||
# Example: "Example, i.e. if the value is a string"
|
||||
# Default: 10 - (Enabled|Comment|Variable name in case of grouped config options)
|
||||
# 0 - (Disabled|Comment|Variable name in case of grouped config options)
|
||||
#
|
||||
# Note to developers:
|
||||
# - Copy this example to keep the formatting.
|
||||
# - Line breaks should be at column 100.
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
# AUTH SERVER SETTINGS
|
||||
#
|
||||
# LogsDir
|
||||
# Description: Logs directory setting.
|
||||
# Important: LogsDir needs to be quoted, as the string might contain space characters.
|
||||
# Logs directory must exists, or log file creation will be disabled.
|
||||
# Default: "" - (Log files will be stored in the current path)
|
||||
|
||||
LogsDir = ""
|
||||
|
||||
#
|
||||
# MaxPingTime
|
||||
# Description: Time (in minutes) between database pings.
|
||||
# Default: 30
|
||||
|
||||
MaxPingTime = 30
|
||||
|
||||
#
|
||||
# RealmServerPort
|
||||
# Description: TCP port to reach the auth server.
|
||||
# Default: 3724
|
||||
|
||||
RealmServerPort = 3724
|
||||
|
||||
#
|
||||
# BattlenetPort
|
||||
# Description: TCP port to reach the auth server for battle.net connections.
|
||||
# Default: 1119
|
||||
|
||||
BattlenetPort = 1119
|
||||
|
||||
#
|
||||
#
|
||||
# BindIP
|
||||
# Description: Bind auth server to IP/hostname
|
||||
# Default: "0.0.0.0" - (Bind to all IPs on the system)
|
||||
|
||||
BindIP = "0.0.0.0"
|
||||
|
||||
#
|
||||
# PidFile
|
||||
# Description: Auth server PID file.
|
||||
# Example: "./authserver.pid" - (Enabled)
|
||||
# Default: "" - (Disabled)
|
||||
|
||||
PidFile = ""
|
||||
|
||||
#
|
||||
# UseProcessors
|
||||
# Description: Processors mask for Windows and Linux based multi-processor systems.
|
||||
# Example: A computer with 2 CPUs:
|
||||
# 1 - 1st CPU only, 2 - 2nd CPU only, 3 - 1st and 2nd CPU, because 1 | 2 is 3
|
||||
# Default: 0 - (Selected by OS)
|
||||
# 1+ - (Bit mask value of selected processors)
|
||||
|
||||
UseProcessors = 0
|
||||
|
||||
#
|
||||
# ProcessPriority
|
||||
# Description: Process priority setting for Windows and Linux based systems.
|
||||
# Details: On Linux, a nice value of -15 is used. (requires superuser). On Windows, process is set to HIGH class.
|
||||
# Default: 0 - (Normal)
|
||||
# 1 - (High)
|
||||
|
||||
ProcessPriority = 0
|
||||
|
||||
#
|
||||
# RealmsStateUpdateDelay
|
||||
# Description: Time (in seconds) between realm list updates.
|
||||
# Default: 20 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
|
||||
RealmsStateUpdateDelay = 20
|
||||
|
||||
#
|
||||
# WrongPass.MaxCount
|
||||
# Description: Number of login attemps with wrong password before the account or IP will be
|
||||
# banned.
|
||||
# Default: 0 - (Disabled)
|
||||
# 1+ - (Enabled)
|
||||
|
||||
WrongPass.MaxCount = 0
|
||||
|
||||
#
|
||||
# WrongPass.BanTime
|
||||
# Description: Time (in seconds) for banning account or IP for invalid login attempts.
|
||||
# Default: 600 - (10 minutes)
|
||||
# 0 - (Permanent ban)
|
||||
|
||||
WrongPass.BanTime = 600
|
||||
|
||||
#
|
||||
# WrongPass.BanType
|
||||
# Description: Ban type for invalid login attempts.
|
||||
# Default: 0 - (Ban IP)
|
||||
# 1 - (Ban Account)
|
||||
|
||||
WrongPass.BanType = 0
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
# MYSQL SETTINGS
|
||||
#
|
||||
# LoginDatabaseInfo
|
||||
# Description: Database connection settings for the realm server.
|
||||
# Example: "hostname;port;username;password;database"
|
||||
# ".;somenumber;username;password;database" - (Use named pipes on Windows
|
||||
# "enable-named-pipe" to [mysqld]
|
||||
# section my.ini)
|
||||
# ".;/path/to/unix_socket;username;password;database" - (use Unix sockets on
|
||||
# Unix/Linux)
|
||||
# Default: "127.0.0.1;3306;trinity;trinity;auth"
|
||||
|
||||
LoginDatabaseInfo = "127.0.0.1;3306;trinity;trinity;auth"
|
||||
|
||||
#
|
||||
# LoginDatabase.WorkerThreads
|
||||
# Description: The amount of worker threads spawned to handle asynchronous (delayed) MySQL
|
||||
# statements. Each worker thread is mirrored with its own connection to the
|
||||
# Default: 1
|
||||
|
||||
LoginDatabase.WorkerThreads = 1
|
||||
|
||||
#
|
||||
# Wrong.Password.Login.Logging
|
||||
# Description: Additionally log attempted wrong password logging
|
||||
# Default: 0 - (Disabled)
|
||||
# 1 - (Enabled)
|
||||
|
||||
Wrong.Password.Login.Logging = 0
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
#
|
||||
# LOGGING SYSTEM SETTINGS
|
||||
#
|
||||
# Appender config values: Given a appender "name"
|
||||
# Appender.name
|
||||
# Description: Defines 'where to log'
|
||||
# Format: Type,LogLevel,Flags,optional1,optional2,optional3
|
||||
#
|
||||
# Type
|
||||
# 0 - (None)
|
||||
# 1 - (Console)
|
||||
# 2 - (File)
|
||||
# 3 - (DB)
|
||||
#
|
||||
# LogLevel
|
||||
# 0 - (Disabled)
|
||||
# 1 - (Trace)
|
||||
# 2 - (Debug)
|
||||
# 3 - (Info)
|
||||
# 4 - (Warn)
|
||||
# 5 - (Error)
|
||||
# 6 - (Fatal)
|
||||
#
|
||||
# Flags:
|
||||
# 0 - None
|
||||
# 1 - Prefix Timestamp to the text
|
||||
# 2 - Prefix Log Level to the text
|
||||
# 4 - Prefix Log Filter type to the text
|
||||
# 8 - Append timestamp to the log file name. Format: YYYY-MM-DD_HH-MM-SS (Only used with Type = 2)
|
||||
# 16 - Make a backup of existing file before overwrite (Only used with Mode = w)
|
||||
#
|
||||
# Colors (read as optional1 if Type = Console)
|
||||
# Format: "fatal error warn info debug trace"
|
||||
# 0 - BLACK
|
||||
# 1 - RED
|
||||
# 2 - GREEN
|
||||
# 3 - BROWN
|
||||
# 4 - BLUE
|
||||
# 5 - MAGENTA
|
||||
# 6 - CYAN
|
||||
# 7 - GREY
|
||||
# 8 - YELLOW
|
||||
# 9 - LRED
|
||||
# 10 - LGREEN
|
||||
# 11 - LBLUE
|
||||
# 12 - LMAGENTA
|
||||
# 13 - LCYAN
|
||||
# 14 - WHITE
|
||||
# Example: "13 11 9 5 3 1"
|
||||
#
|
||||
# File: Name of the file (read as optional1 if Type = File)
|
||||
# Allows to use one "%s" to create dynamic files
|
||||
#
|
||||
# Mode: Mode to open the file (read as optional2 if Type = File)
|
||||
# a - (Append)
|
||||
# w - (Overwrite)
|
||||
#
|
||||
# MaxFileSize: Maximum file size of the log file before creating a new log file
|
||||
# (read as optional3 if Type = File)
|
||||
# Size is measured in bytes expressed in a 64-bit unsigned integer.
|
||||
# Maximum value is 4294967295 (4 gb). Leave blank for no limit.
|
||||
# NOTE: Does not work with dynamic filenames.
|
||||
# Example: 536870912 (512 mb)
|
||||
#
|
||||
|
||||
Appender.Console=1,2,0
|
||||
Appender.Auth=2,2,0,Auth.log,w
|
||||
|
||||
# Logger config values: Given a logger "name"
|
||||
# Logger.name
|
||||
# Description: Defines 'What to log'
|
||||
# Format: LogLevel,AppenderList
|
||||
#
|
||||
# LogLevel
|
||||
# 0 - (Disabled)
|
||||
# 1 - (Trace)
|
||||
# 2 - (Debug)
|
||||
# 3 - (Info)
|
||||
# 4 - (Warn)
|
||||
# 5 - (Error)
|
||||
# 6 - (Fatal)
|
||||
#
|
||||
# AppenderList: List of appenders linked to logger
|
||||
# (Using spaces as separator).
|
||||
#
|
||||
|
||||
Logger.root=3,Console Auth
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
BIN
src/server/bnetserver/bnetserver.ico
Normal file
BIN
src/server/bnetserver/bnetserver.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 133 KiB |
94
src/server/bnetserver/bnetserver.rc
Normal file
94
src/server/bnetserver/bnetserver.rc
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "resource.h"
|
||||
#include "revision.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "windows.h" //"afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_APPICON ICON "bnetserver.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Neutre (Par défaut système) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VER_FILEVERSION
|
||||
PRODUCTVERSION VER_PRODUCTVERSION
|
||||
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
|
||||
#ifndef _DEBUG
|
||||
FILEFLAGS 0
|
||||
#else
|
||||
#define VER_PRERELEASE VS_FF_PRERELEASE
|
||||
#define VER_PRIVATEBUILD VS_FF_PRIVATEBUILD
|
||||
#define VER_DEBUG 0
|
||||
FILEFLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
|
||||
#endif
|
||||
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080004b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VER_COMPANYNAME_STR
|
||||
VALUE "FileDescription", "TrinityCore Battle.net Server Daemon"
|
||||
VALUE "FileVersion", VER_FILEVERSION_STR
|
||||
VALUE "InternalName", "bnetserver"
|
||||
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
|
||||
VALUE "OriginalFilename", "bnetserver.exe"
|
||||
VALUE "ProductName", "TrinityCore Battle.net Server"
|
||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x800, 1200
|
||||
END
|
||||
END
|
||||
#endif
|
||||
15
src/server/bnetserver/resource.h
Normal file
15
src/server/bnetserver/resource.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by TrinityCore.rc
|
||||
//
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user