mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
Removed local realmd repo and added universal realmd submodule
This universal repo is based on the original Four realmd
This commit is contained in:
parent
8d61f83e7c
commit
0a2da0817e
16 changed files with 4 additions and 2937 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "src/realmd"]
|
||||||
|
path = src/realmd
|
||||||
|
url = https://github.com/mangos/realmd.git
|
||||||
1
src/realmd
Submodule
1
src/realmd
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 548d6fca80a3fe3e276cf4e7d240eeb8fb99c6d6
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
\ingroup realmd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _AUTHCODES_H
|
|
||||||
#define _AUTHCODES_H
|
|
||||||
|
|
||||||
enum eAuthCmd
|
|
||||||
{
|
|
||||||
CMD_AUTH_LOGON_CHALLENGE = 0x00,
|
|
||||||
CMD_AUTH_LOGON_PROOF = 0x01,
|
|
||||||
CMD_AUTH_RECONNECT_CHALLENGE = 0x02,
|
|
||||||
CMD_AUTH_RECONNECT_PROOF = 0x03,
|
|
||||||
CMD_REALM_LIST = 0x10,
|
|
||||||
CMD_XFER_INITIATE = 0x30,
|
|
||||||
CMD_XFER_DATA = 0x31,
|
|
||||||
// these opcodes no longer exist in currently supported client
|
|
||||||
CMD_XFER_ACCEPT = 0x32,
|
|
||||||
CMD_XFER_RESUME = 0x33,
|
|
||||||
CMD_XFER_CANCEL = 0x34
|
|
||||||
};
|
|
||||||
|
|
||||||
// not used by us currently
|
|
||||||
enum eAuthSrvCmd
|
|
||||||
{
|
|
||||||
CMD_GRUNT_AUTH_CHALLENGE = 0x0,
|
|
||||||
CMD_GRUNT_AUTH_VERIFY = 0x2,
|
|
||||||
CMD_GRUNT_CONN_PING = 0x10,
|
|
||||||
CMD_GRUNT_CONN_PONG = 0x11,
|
|
||||||
CMD_GRUNT_HELLO = 0x20,
|
|
||||||
CMD_GRUNT_PROVESESSION = 0x21,
|
|
||||||
CMD_GRUNT_KICK = 0x24,
|
|
||||||
CMD_GRUNT_PCWARNING = 0x29,
|
|
||||||
CMD_GRUNT_STRINGS = 0x41,
|
|
||||||
CMD_GRUNT_SUNKENUPDATE = 0x44,
|
|
||||||
CMD_GRUNT_SUNKEN_ONLINE = 0x46
|
|
||||||
};
|
|
||||||
|
|
||||||
enum AuthResult
|
|
||||||
{
|
|
||||||
WOW_SUCCESS = 0x00,
|
|
||||||
WOW_FAIL_UNKNOWN0 = 0x01, ///< ? Unable to connect
|
|
||||||
WOW_FAIL_UNKNOWN1 = 0x02, ///< ? Unable to connect
|
|
||||||
WOW_FAIL_BANNED = 0x03, ///< This <game> account has been closed and is no longer available for use. Please go to <site>/banned.html for further information.
|
|
||||||
WOW_FAIL_UNKNOWN_ACCOUNT = 0x04, ///< The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password, see <site> for more information
|
|
||||||
WOW_FAIL_INCORRECT_PASSWORD = 0x05, ///< The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password, see <site> for more information
|
|
||||||
// client reject next login attempts after this error, so in code used WOW_FAIL_UNKNOWN_ACCOUNT for both cases
|
|
||||||
WOW_FAIL_ALREADY_ONLINE = 0x06, ///< This account is already logged into <game>. Please check the spelling and try again.
|
|
||||||
WOW_FAIL_NO_TIME = 0x07, ///< You have used up your prepaid time for this account. Please purchase more to continue playing
|
|
||||||
WOW_FAIL_DB_BUSY = 0x08, ///< Could not log in to <game> at this time. Please try again later.
|
|
||||||
WOW_FAIL_VERSION_INVALID = 0x09, ///< Unable to validate game version. This may be caused by file corruption or interference of another program. Please visit <site> for more information and possible solutions to this issue.
|
|
||||||
WOW_FAIL_VERSION_UPDATE = 0x0A, ///< Downloading
|
|
||||||
WOW_FAIL_INVALID_SERVER = 0x0B, ///< Unable to connect
|
|
||||||
WOW_FAIL_SUSPENDED = 0x0C, ///< This <game> account has been temporarily suspended. Please go to <site>/banned.html for further information
|
|
||||||
WOW_FAIL_FAIL_NOACCESS = 0x0D, ///< Unable to connect
|
|
||||||
WOW_SUCCESS_SURVEY = 0x0E, ///< Connected.
|
|
||||||
WOW_FAIL_PARENTCONTROL = 0x0F, ///< Access to this account has been blocked by parental controls. Your settings may be changed in your account preferences at <site>
|
|
||||||
WOW_FAIL_LOCKED_ENFORCED = 0x10, ///< You have applied a lock to your account. You can change your locked status by calling your account lock phone number.
|
|
||||||
WOW_FAIL_TRIAL_ENDED = 0x11, ///< Your trial subscription has expired. Please visit <site> to upgrade your account.
|
|
||||||
WOW_FAIL_USE_BATTLENET = 0x12, ///< WOW_FAIL_OTHER This account is now attached to a Battle.net account. Please login with your Battle.net account email address and password.
|
|
||||||
// WOW_FAIL_OVERMIND_CONVERTED
|
|
||||||
// WOW_FAIL_ANTI_INDULGENCE
|
|
||||||
// WOW_FAIL_EXPIRED
|
|
||||||
// WOW_FAIL_NO_GAME_ACCOUNT
|
|
||||||
// WOW_FAIL_BILLING_LOCK
|
|
||||||
// WOW_FAIL_IGR_WITHOUT_BNET
|
|
||||||
// WOW_FAIL_AA_LOCK
|
|
||||||
// WOW_FAIL_UNLOCKABLE_LOCK
|
|
||||||
// WOW_FAIL_MUST_USE_BNET
|
|
||||||
// WOW_FAIL_OTHER
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,89 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// \addtogroup realmd
|
|
||||||
/// @{
|
|
||||||
/// \file
|
|
||||||
|
|
||||||
#ifndef _AUTHSOCKET_H
|
|
||||||
#define _AUTHSOCKET_H
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "Auth/BigNumber.h"
|
|
||||||
#include "Auth/Sha1.h"
|
|
||||||
#include "ByteBuffer.h"
|
|
||||||
|
|
||||||
#include "BufferedSocket.h"
|
|
||||||
|
|
||||||
/// Handle login commands
|
|
||||||
class AuthSocket: public BufferedSocket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
const static int s_BYTE_SIZE = 32;
|
|
||||||
|
|
||||||
AuthSocket();
|
|
||||||
~AuthSocket();
|
|
||||||
|
|
||||||
void OnAccept() override;
|
|
||||||
void OnRead() override;
|
|
||||||
void SendProof(Sha1Hash sha);
|
|
||||||
void LoadRealmlist(ByteBuffer& pkt, uint32 acctid);
|
|
||||||
|
|
||||||
bool _HandleLogonChallenge();
|
|
||||||
bool _HandleLogonProof();
|
|
||||||
bool _HandleReconnectChallenge();
|
|
||||||
bool _HandleReconnectProof();
|
|
||||||
bool _HandleRealmList();
|
|
||||||
// data transfer handle for patch
|
|
||||||
|
|
||||||
bool _HandleXferResume();
|
|
||||||
bool _HandleXferCancel();
|
|
||||||
bool _HandleXferAccept();
|
|
||||||
|
|
||||||
void _SetVSFields(const std::string& rI);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
BigNumber N, s, g, v;
|
|
||||||
BigNumber b, B;
|
|
||||||
BigNumber K;
|
|
||||||
BigNumber _reconnectProof;
|
|
||||||
|
|
||||||
bool _authed;
|
|
||||||
|
|
||||||
std::string _login;
|
|
||||||
std::string _safelogin;
|
|
||||||
|
|
||||||
// Since GetLocaleByName() is _NOT_ bijective, we have to store the locale as a string. Otherwise we can't differ
|
|
||||||
// between enUS and enGB, which is important for the patch system
|
|
||||||
std::string _localizationName;
|
|
||||||
uint16 _build;
|
|
||||||
AccountTypes _accountSecurityLevel;
|
|
||||||
|
|
||||||
ACE_HANDLE patch_;
|
|
||||||
|
|
||||||
void InitPatch();
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
/// @}
|
|
||||||
|
|
@ -1,274 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
\ingroup realmd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "BufferedSocket.h"
|
|
||||||
|
|
||||||
#include <ace/OS_NS_string.h>
|
|
||||||
#include <ace/INET_Addr.h>
|
|
||||||
#include <ace/SString.h>
|
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BufferedSocket::BufferedSocket(void):
|
|
||||||
input_buffer_(4096),
|
|
||||||
remote_address_("<unknown>")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*virtual*/ BufferedSocket::~BufferedSocket(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*virtual*/ int BufferedSocket::open(void* arg)
|
|
||||||
{
|
|
||||||
if (Base::open(arg) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
ACE_INET_Addr addr;
|
|
||||||
|
|
||||||
if (peer().get_remote_addr(addr) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
char address[1024];
|
|
||||||
|
|
||||||
addr.get_host_addr(address, 1024);
|
|
||||||
|
|
||||||
this->remote_address_ = address;
|
|
||||||
|
|
||||||
this->OnAccept();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& BufferedSocket::get_remote_address(void) const
|
|
||||||
{
|
|
||||||
return this->remote_address_;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t BufferedSocket::recv_len(void) const
|
|
||||||
{
|
|
||||||
return this->input_buffer_.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BufferedSocket::recv_soft(char* buf, size_t len)
|
|
||||||
{
|
|
||||||
if (this->input_buffer_.length() < len)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ACE_OS::memcpy(buf, this->input_buffer_.rd_ptr(), len);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BufferedSocket::recv(char* buf, size_t len)
|
|
||||||
{
|
|
||||||
bool ret = this->recv_soft(buf, len);
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
this->recv_skip(len);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BufferedSocket::recv_skip(size_t len)
|
|
||||||
{
|
|
||||||
this->input_buffer_.rd_ptr(len);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t BufferedSocket::noblk_send(ACE_Message_Block& message_block)
|
|
||||||
{
|
|
||||||
const size_t len = message_block.length();
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
// Try to send the message directly.
|
|
||||||
ssize_t n = this->peer().send(message_block.rd_ptr(), len, MSG_NOSIGNAL);
|
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
{
|
|
||||||
if (errno == EWOULDBLOCK)
|
|
||||||
// Blocking signal
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
// Error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (n == 0)
|
|
||||||
{
|
|
||||||
// Can this happen ?
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return bytes transmitted
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BufferedSocket::send(const char* buf, size_t len)
|
|
||||||
{
|
|
||||||
if (buf == NULL || len == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
ACE_Data_Block db(
|
|
||||||
len,
|
|
||||||
ACE_Message_Block::MB_DATA,
|
|
||||||
(const char*)buf,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
ACE_Message_Block::DONT_DELETE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
ACE_Message_Block message_block(
|
|
||||||
&db,
|
|
||||||
ACE_Message_Block::DONT_DELETE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
message_block.wr_ptr(len);
|
|
||||||
|
|
||||||
if (this->msg_queue()->is_empty())
|
|
||||||
{
|
|
||||||
// Try to send it directly.
|
|
||||||
ssize_t n = this->noblk_send(message_block);
|
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
return false;
|
|
||||||
else if (n == len)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// adjust how much bytes we sent
|
|
||||||
message_block.rd_ptr((size_t)n);
|
|
||||||
|
|
||||||
// fall down
|
|
||||||
}
|
|
||||||
|
|
||||||
// enqueue the message, note: clone is needed cause we cant enqueue stuff on the stack
|
|
||||||
ACE_Message_Block* mb = message_block.clone();
|
|
||||||
|
|
||||||
if (this->msg_queue()->enqueue_tail(mb, (ACE_Time_Value*) &ACE_Time_Value::zero) == -1)
|
|
||||||
{
|
|
||||||
mb->release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tell reactor to call handle_output() when we can send more data
|
|
||||||
if (this->reactor()->schedule_wakeup(this, ACE_Event_Handler::WRITE_MASK) == -1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*virtual*/ int BufferedSocket::handle_output(ACE_HANDLE /*= ACE_INVALID_HANDLE*/)
|
|
||||||
{
|
|
||||||
ACE_Message_Block* mb = 0;
|
|
||||||
|
|
||||||
if (this->msg_queue()->is_empty())
|
|
||||||
{
|
|
||||||
// if no more data to send, then cancel notification
|
|
||||||
this->reactor()->cancel_wakeup(this, ACE_Event_Handler::WRITE_MASK);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->msg_queue()->dequeue_head(mb, (ACE_Time_Value*) &ACE_Time_Value::zero) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
ssize_t n = this->noblk_send(*mb);
|
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
{
|
|
||||||
mb->release();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (n == mb->length())
|
|
||||||
{
|
|
||||||
mb->release();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mb->rd_ptr(n);
|
|
||||||
|
|
||||||
if (this->msg_queue()->enqueue_head(mb, (ACE_Time_Value*) &ACE_Time_Value::zero) == -1)
|
|
||||||
{
|
|
||||||
mb->release();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ACE_NOTREACHED(return -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*virtual*/ int BufferedSocket::handle_input(ACE_HANDLE /*= ACE_INVALID_HANDLE*/)
|
|
||||||
{
|
|
||||||
const ssize_t space = this->input_buffer_.space();
|
|
||||||
|
|
||||||
ssize_t n = this->peer().recv(this->input_buffer_.wr_ptr(), space);
|
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
{
|
|
||||||
// blocking signal or error
|
|
||||||
return errno == EWOULDBLOCK ? 0 : -1;
|
|
||||||
}
|
|
||||||
else if (n == 0)
|
|
||||||
{
|
|
||||||
// EOF
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->input_buffer_.wr_ptr((size_t)n);
|
|
||||||
|
|
||||||
this->OnRead();
|
|
||||||
|
|
||||||
// move data in the buffer to the beginning of the buffer
|
|
||||||
this->input_buffer_.crunch();
|
|
||||||
|
|
||||||
// return 1 in case there might be more data to read from OS
|
|
||||||
return n == space ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*virtual*/ int BufferedSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask m)
|
|
||||||
{
|
|
||||||
this->OnClose();
|
|
||||||
|
|
||||||
Base::handle_close();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BufferedSocket::close_connection(void)
|
|
||||||
{
|
|
||||||
this->peer().close_reader();
|
|
||||||
this->peer().close_writer();
|
|
||||||
|
|
||||||
reactor()->remove_handler(this, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::ALL_EVENTS_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
\ingroup realmd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BUFFEREDSOCKET_H_
|
|
||||||
#define _BUFFEREDSOCKET_H_
|
|
||||||
|
|
||||||
#include <ace/Basic_Types.h>
|
|
||||||
#include <ace/Synch_Traits.h>
|
|
||||||
#include <ace/Svc_Handler.h>
|
|
||||||
#include <ace/SOCK_Stream.h>
|
|
||||||
#include <ace/Message_Block.h>
|
|
||||||
#include <ace/Basic_Types.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class BufferedSocket: public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> Base;
|
|
||||||
|
|
||||||
virtual void OnRead(void) { }
|
|
||||||
virtual void OnAccept(void) { }
|
|
||||||
virtual void OnClose(void) { }
|
|
||||||
|
|
||||||
public:
|
|
||||||
BufferedSocket(void);
|
|
||||||
virtual ~BufferedSocket(void);
|
|
||||||
|
|
||||||
size_t recv_len(void) const;
|
|
||||||
bool recv_soft(char* buf, size_t len);
|
|
||||||
bool recv(char* buf, size_t len);
|
|
||||||
void recv_skip(size_t len);
|
|
||||||
|
|
||||||
bool send(const char* buf, size_t len);
|
|
||||||
|
|
||||||
const std::string& get_remote_address(void) const;
|
|
||||||
|
|
||||||
virtual int open(void*) override;
|
|
||||||
|
|
||||||
void close_connection(void);
|
|
||||||
|
|
||||||
virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE) override;
|
|
||||||
virtual int handle_output(ACE_HANDLE = ACE_INVALID_HANDLE) override;
|
|
||||||
|
|
||||||
virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE,
|
|
||||||
ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ssize_t noblk_send(ACE_Message_Block& message_block);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ACE_Message_Block input_buffer_;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::string remote_address_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _BUFFEREDSOCKET_H_ */
|
|
||||||
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
|
|
||||||
#
|
|
||||||
# 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, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
set(EXECUTABLE_NAME realmd)
|
|
||||||
|
|
||||||
set(EXECUTABLE_SRCS
|
|
||||||
AuthCodes.h
|
|
||||||
AuthSocket.cpp
|
|
||||||
AuthSocket.h
|
|
||||||
BufferedSocket.cpp
|
|
||||||
BufferedSocket.h
|
|
||||||
Main.cpp
|
|
||||||
PatchHandler.cpp
|
|
||||||
PatchHandler.h
|
|
||||||
RealmList.cpp
|
|
||||||
RealmList.h
|
|
||||||
)
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
# add resource file to windows build
|
|
||||||
set(EXECUTABLE_SRCS ${EXECUTABLE_SRCS} realmd.rc)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
${CMAKE_SOURCE_DIR}/src/shared
|
|
||||||
${CMAKE_SOURCE_DIR}/src/framework
|
|
||||||
${CMAKE_BINARY_DIR}
|
|
||||||
${CMAKE_BINARY_DIR}/src/shared
|
|
||||||
${MYSQL_INCLUDE_DIR}
|
|
||||||
${ACE_INCLUDE_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(${EXECUTABLE_NAME}
|
|
||||||
${EXECUTABLE_SRCS}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_dependencies(${EXECUTABLE_NAME} revision.h)
|
|
||||||
if(NOT ACE_USE_EXTERNAL)
|
|
||||||
add_dependencies(${EXECUTABLE_NAME} ACE_Project)
|
|
||||||
# add_dependencies(${EXECUTABLE_NAME} ace)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${EXECUTABLE_NAME}
|
|
||||||
shared
|
|
||||||
framework
|
|
||||||
${ACE_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries(${EXECUTABLE_NAME}
|
|
||||||
optimized ${MYSQL_LIBRARY}
|
|
||||||
optimized ${OPENSSL_LIBRARIES}
|
|
||||||
debug ${MYSQL_DEBUG_LIBRARY}
|
|
||||||
debug ${OPENSSL_DEBUG_LIBRARIES}
|
|
||||||
)
|
|
||||||
if(PLATFORM MATCHES X86)
|
|
||||||
target_link_libraries(${EXECUTABLE_NAME})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
target_link_libraries(${EXECUTABLE_NAME}
|
|
||||||
${MYSQL_LIBRARY}
|
|
||||||
${OPENSSL_LIBRARIES}
|
|
||||||
${OPENSSL_EXTRA_LIBRARIES}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(EXECUTABLE_LINK_FLAGS "")
|
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
set(EXECUTABLE_LINK_FLAGS "-pthread ${EXECUTABLE_LINK_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
set(EXECUTABLE_LINK_FLAGS "-framework Carbon ${EXECUTABLE_LINK_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS
|
|
||||||
"${EXECUTABLE_LINK_FLAGS}"
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${BIN_DIR})
|
|
||||||
install(FILES realmd.conf.dist.in DESTINATION ${CONF_DIR} RENAME realmd.conf.dist)
|
|
||||||
|
|
||||||
if(WIN32 AND MSVC)
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/\${BUILD_TYPE}/${EXECUTABLE_NAME}.pdb DESTINATION ${BIN_DIR} CONFIGURATIONS Debug)
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,435 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// \addtogroup realmd Realm Daemon
|
|
||||||
/// @{
|
|
||||||
/// \file
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "Database/DatabaseEnv.h"
|
|
||||||
#include "RealmList.h"
|
|
||||||
|
|
||||||
#include "Config/Config.h"
|
|
||||||
#include "Log.h"
|
|
||||||
#include "AuthSocket.h"
|
|
||||||
#include "SystemConfig.h"
|
|
||||||
#include "revision.h"
|
|
||||||
#include "revision_nr.h"
|
|
||||||
#include "revision_sql.h"
|
|
||||||
#include "Util.h"
|
|
||||||
#include <openssl/opensslv.h>
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
|
|
||||||
#include <ace/Get_Opt.h>
|
|
||||||
#include <ace/Dev_Poll_Reactor.h>
|
|
||||||
#include <ace/TP_Reactor.h>
|
|
||||||
#include <ace/ACE.h>
|
|
||||||
#include <ace/Acceptor.h>
|
|
||||||
#include <ace/SOCK_Acceptor.h>
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include "ServiceWin32.h"
|
|
||||||
char serviceName[] = "realmd";
|
|
||||||
char serviceLongName[] = "MaNGOS realmd service";
|
|
||||||
char serviceDescription[] = "Massive Network Game Object Server";
|
|
||||||
/*
|
|
||||||
* -1 - not in service mode
|
|
||||||
* 0 - stopped
|
|
||||||
* 1 - running
|
|
||||||
* 2 - paused
|
|
||||||
*/
|
|
||||||
int m_ServiceStatus = -1;
|
|
||||||
#else
|
|
||||||
#include "PosixDaemon.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool StartDB();
|
|
||||||
void UnhookSignals();
|
|
||||||
void HookSignals();
|
|
||||||
|
|
||||||
bool stopEvent = false; ///< Setting it to true stops the server
|
|
||||||
|
|
||||||
DatabaseType LoginDatabase; ///< Accessor to the realm server database
|
|
||||||
|
|
||||||
/// Print out the usage string for this program on the console.
|
|
||||||
void usage(const char* prog)
|
|
||||||
{
|
|
||||||
sLog.outString("Usage: \n %s [<options>]\n"
|
|
||||||
" -v, --version print version and exist\n\r"
|
|
||||||
" -c config_file use config_file as configuration file\n\r"
|
|
||||||
#ifdef WIN32
|
|
||||||
" Running as service functions:\n\r"
|
|
||||||
" -s run run as service\n\r"
|
|
||||||
" -s install install service\n\r"
|
|
||||||
" -s uninstall uninstall service\n\r"
|
|
||||||
#else
|
|
||||||
" Running as daemon functions:\n\r"
|
|
||||||
" -s run run as daemon\n\r"
|
|
||||||
" -s stop stop daemon\n\r"
|
|
||||||
#endif
|
|
||||||
, prog);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Launch the realm server
|
|
||||||
extern int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
///- Command line parsing
|
|
||||||
char const* cfg_file = REALMD_CONFIG_LOCATION;
|
|
||||||
|
|
||||||
char const* options = ":c:s:";
|
|
||||||
|
|
||||||
ACE_Get_Opt cmd_opts(argc, argv, options);
|
|
||||||
cmd_opts.long_option("version", 'v');
|
|
||||||
|
|
||||||
char serviceDaemonMode = '\0';
|
|
||||||
|
|
||||||
int option;
|
|
||||||
while ((option = cmd_opts()) != EOF)
|
|
||||||
{
|
|
||||||
switch (option)
|
|
||||||
{
|
|
||||||
case 'c':
|
|
||||||
cfg_file = cmd_opts.opt_arg();
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
printf("%s\n", MANGOS_FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID));
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
{
|
|
||||||
const char* mode = cmd_opts.opt_arg();
|
|
||||||
|
|
||||||
if (!strcmp(mode, "run"))
|
|
||||||
serviceDaemonMode = 'r';
|
|
||||||
#ifdef WIN32
|
|
||||||
else if (!strcmp(mode, "install"))
|
|
||||||
serviceDaemonMode = 'i';
|
|
||||||
else if (!strcmp(mode, "uninstall"))
|
|
||||||
serviceDaemonMode = 'u';
|
|
||||||
#else
|
|
||||||
else if (!strcmp(mode, "stop"))
|
|
||||||
serviceDaemonMode = 's';
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);
|
|
||||||
usage(argv[0]);
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ':':
|
|
||||||
sLog.outError("Runtime-Error: -%c option requires an input argument", cmd_opts.opt_opt());
|
|
||||||
usage(argv[0]);
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
default:
|
|
||||||
sLog.outError("Runtime-Error: bad format of commandline arguments");
|
|
||||||
usage(argv[0]);
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32 // windows service command need execute before config read
|
|
||||||
switch (serviceDaemonMode)
|
|
||||||
{
|
|
||||||
case 'i':
|
|
||||||
if (WinServiceInstall())
|
|
||||||
sLog.outString("Installing service");
|
|
||||||
return 1;
|
|
||||||
case 'u':
|
|
||||||
if (WinServiceUninstall())
|
|
||||||
sLog.outString("Uninstalling service");
|
|
||||||
return 1;
|
|
||||||
case 'r':
|
|
||||||
WinServiceRun();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!sConfig.SetSource(cfg_file))
|
|
||||||
{
|
|
||||||
sLog.outError("Could not find configuration file %s.", cfg_file);
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef WIN32 // posix daemon commands need apply after config read
|
|
||||||
switch (serviceDaemonMode)
|
|
||||||
{
|
|
||||||
case 'r':
|
|
||||||
startDaemon();
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
stopDaemon();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sLog.Initialize();
|
|
||||||
|
|
||||||
sLog.outString("%s [realm-daemon]", MANGOS_FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID));
|
|
||||||
sLog.outString("<Ctrl-C> to stop.\n");
|
|
||||||
sLog.outString("Using configuration file %s.", cfg_file);
|
|
||||||
|
|
||||||
///- Check the version of the configuration file
|
|
||||||
uint32 confVersion = sConfig.GetIntDefault("ConfVersion", 0);
|
|
||||||
if (confVersion < REALMD_CONFIG_VERSION)
|
|
||||||
{
|
|
||||||
sLog.outError("*****************************************************************************");
|
|
||||||
sLog.outError(" WARNING: Your realmd.conf version indicates your conf file is out of date!");
|
|
||||||
sLog.outError(" Please check for updates, as your current default values may cause");
|
|
||||||
sLog.outError(" strange behavior.");
|
|
||||||
sLog.outError("*****************************************************************************");
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
}
|
|
||||||
|
|
||||||
DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
|
||||||
if (SSLeay() < 0x009080bfL)
|
|
||||||
{
|
|
||||||
DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");
|
|
||||||
DETAIL_LOG("WARNING: Minimal required version [OpenSSL 0.9.8k]");
|
|
||||||
}
|
|
||||||
|
|
||||||
DETAIL_LOG("Using ACE: %s", ACE_VERSION);
|
|
||||||
|
|
||||||
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
|
|
||||||
ACE_Reactor::instance(new ACE_Reactor(new ACE_Dev_Poll_Reactor(ACE::max_handles(), 1), 1), true);
|
|
||||||
#else
|
|
||||||
ACE_Reactor::instance(new ACE_Reactor(new ACE_TP_Reactor(), true), true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sLog.outBasic("Max allowed open files is %d", ACE::max_handles());
|
|
||||||
|
|
||||||
/// realmd PID file creation
|
|
||||||
std::string pidfile = sConfig.GetStringDefault("PidFile", "");
|
|
||||||
if (!pidfile.empty())
|
|
||||||
{
|
|
||||||
uint32 pid = CreatePIDFile(pidfile);
|
|
||||||
if (!pid)
|
|
||||||
{
|
|
||||||
sLog.outError("Cannot create PID file %s.\n", pidfile.c_str());
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sLog.outString("Daemon PID: %u\n", pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
///- Initialize the database connection
|
|
||||||
if (!StartDB())
|
|
||||||
{
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
///- Get the list of realms for the server
|
|
||||||
sRealmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20));
|
|
||||||
if (sRealmList.size() == 0)
|
|
||||||
{
|
|
||||||
sLog.outError("No valid realms specified.");
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cleanup query
|
|
||||||
// set expired bans to inactive
|
|
||||||
LoginDatabase.BeginTransaction();
|
|
||||||
LoginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
|
||||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
|
||||||
LoginDatabase.CommitTransaction();
|
|
||||||
|
|
||||||
///- Launch the listening network socket
|
|
||||||
ACE_Acceptor<AuthSocket, ACE_SOCK_Acceptor> acceptor;
|
|
||||||
|
|
||||||
uint16 rmport = sConfig.GetIntDefault("RealmServerPort", DEFAULT_REALMSERVER_PORT);
|
|
||||||
std::string bind_ip = sConfig.GetStringDefault("BindIP", "0.0.0.0");
|
|
||||||
|
|
||||||
ACE_INET_Addr bind_addr(rmport, bind_ip.c_str());
|
|
||||||
|
|
||||||
if (acceptor.open(bind_addr, ACE_Reactor::instance(), ACE_NONBLOCK) == -1)
|
|
||||||
{
|
|
||||||
sLog.outError("MaNGOS realmd can not bind to %s:%d", bind_ip.c_str(), rmport);
|
|
||||||
Log::WaitBeforeContinueIfNeed();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
///- Catch termination signals
|
|
||||||
HookSignals();
|
|
||||||
|
|
||||||
///- Handle affinity for multiple processors and process priority on Windows
|
|
||||||
#ifdef WIN32
|
|
||||||
{
|
|
||||||
HANDLE hProcess = GetCurrentProcess();
|
|
||||||
|
|
||||||
uint32 Aff = sConfig.GetIntDefault("UseProcessors", 0);
|
|
||||||
if (Aff > 0)
|
|
||||||
{
|
|
||||||
ULONG_PTR appAff;
|
|
||||||
ULONG_PTR sysAff;
|
|
||||||
|
|
||||||
if (GetProcessAffinityMask(hProcess, &appAff, &sysAff))
|
|
||||||
{
|
|
||||||
ULONG_PTR curAff = Aff & appAff; // remove non accessible processors
|
|
||||||
|
|
||||||
if (!curAff)
|
|
||||||
{
|
|
||||||
sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for realmd. Accessible processors bitmask (hex): %x", Aff, appAff);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (SetProcessAffinityMask(hProcess, curAff))
|
|
||||||
sLog.outString("Using processors (bitmask, hex): %x", curAff);
|
|
||||||
else
|
|
||||||
sLog.outError("Can't set used processors (hex): %x", curAff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sLog.outString();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
|
|
||||||
|
|
||||||
if (Prio)
|
|
||||||
{
|
|
||||||
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
|
|
||||||
sLog.outString("realmd process priority class set to HIGH");
|
|
||||||
else
|
|
||||||
sLog.outError("Can't set realmd process priority class.");
|
|
||||||
sLog.outString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// server has started up successfully => enable async DB requests
|
|
||||||
LoginDatabase.AllowAsyncTransactions();
|
|
||||||
|
|
||||||
// maximum counter for next ping
|
|
||||||
uint32 numLoops = (sConfig.GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000000 / 100000));
|
|
||||||
uint32 loopCounter = 0;
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
detachDaemon();
|
|
||||||
#endif
|
|
||||||
///- Wait for termination signal
|
|
||||||
while (!stopEvent)
|
|
||||||
{
|
|
||||||
// dont move this outside the loop, the reactor will modify it
|
|
||||||
ACE_Time_Value interval(0, 100000);
|
|
||||||
|
|
||||||
if (ACE_Reactor::instance()->run_reactor_event_loop(interval) == -1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if ((++loopCounter) == numLoops)
|
|
||||||
{
|
|
||||||
loopCounter = 0;
|
|
||||||
DETAIL_LOG("Ping MySQL to keep connection alive");
|
|
||||||
LoginDatabase.Ping();
|
|
||||||
}
|
|
||||||
#ifdef WIN32
|
|
||||||
if (m_ServiceStatus == 0) stopEvent = true;
|
|
||||||
while (m_ServiceStatus == 2) Sleep(1000);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
///- Wait for the delay thread to exit
|
|
||||||
LoginDatabase.HaltDelayThread();
|
|
||||||
|
|
||||||
///- Remove signal handling before leaving
|
|
||||||
UnhookSignals();
|
|
||||||
|
|
||||||
sLog.outString("Halting process...");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handle termination signals
|
|
||||||
/** Put the global variable stopEvent to 'true' if a termination signal is caught **/
|
|
||||||
void OnSignal(int s)
|
|
||||||
{
|
|
||||||
switch (s)
|
|
||||||
{
|
|
||||||
case SIGINT:
|
|
||||||
case SIGTERM:
|
|
||||||
stopEvent = true;
|
|
||||||
break;
|
|
||||||
#ifdef _WIN32
|
|
||||||
case SIGBREAK:
|
|
||||||
stopEvent = true;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
signal(s, OnSignal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize connection to the database
|
|
||||||
bool StartDB()
|
|
||||||
{
|
|
||||||
std::string dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", "");
|
|
||||||
if (dbstring.empty())
|
|
||||||
{
|
|
||||||
sLog.outError("Database not specified");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sLog.outString("Login Database total connections: %i", 1 + 1);
|
|
||||||
|
|
||||||
if (!LoginDatabase.Initialize(dbstring.c_str()))
|
|
||||||
{
|
|
||||||
sLog.outError("Cannot connect to database");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!LoginDatabase.CheckRequiredField("realmd_db_version", REVISION_DB_REALMD))
|
|
||||||
{
|
|
||||||
///- Wait for already started DB delay threads to end
|
|
||||||
LoginDatabase.HaltDelayThread();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Define hook 'OnSignal' for all termination signals
|
|
||||||
void HookSignals()
|
|
||||||
{
|
|
||||||
signal(SIGINT, OnSignal);
|
|
||||||
signal(SIGTERM, OnSignal);
|
|
||||||
#ifdef _WIN32
|
|
||||||
signal(SIGBREAK, OnSignal);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Unhook the signals before leaving
|
|
||||||
void UnhookSignals()
|
|
||||||
{
|
|
||||||
signal(SIGINT, 0);
|
|
||||||
signal(SIGTERM, 0);
|
|
||||||
#ifdef _WIN32
|
|
||||||
signal(SIGBREAK, 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
|
|
@ -1,221 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
\ingroup realmd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "PatchHandler.h"
|
|
||||||
#include "AuthCodes.h"
|
|
||||||
#include "Log.h"
|
|
||||||
|
|
||||||
#include <ace/OS_NS_sys_socket.h>
|
|
||||||
#include <ace/OS_NS_dirent.h>
|
|
||||||
#include <ace/OS_NS_errno.h>
|
|
||||||
#include <ace/OS_NS_unistd.h>
|
|
||||||
|
|
||||||
#include <ace/os_include/netinet/os_tcp.h>
|
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined( __GNUC__ )
|
|
||||||
#pragma pack(1)
|
|
||||||
#else
|
|
||||||
#pragma pack(push,1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct Chunk
|
|
||||||
{
|
|
||||||
ACE_UINT8 cmd;
|
|
||||||
ACE_UINT16 data_size;
|
|
||||||
ACE_UINT8 data[4096]; // 4096 - page size on most arch
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined( __GNUC__ )
|
|
||||||
#pragma pack()
|
|
||||||
#else
|
|
||||||
#pragma pack(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PatchHandler::PatchHandler(ACE_HANDLE socket, ACE_HANDLE patch)
|
|
||||||
{
|
|
||||||
reactor(NULL);
|
|
||||||
set_handle(socket);
|
|
||||||
patch_fd_ = patch;
|
|
||||||
}
|
|
||||||
|
|
||||||
PatchHandler::~PatchHandler()
|
|
||||||
{
|
|
||||||
if (patch_fd_ != ACE_INVALID_HANDLE)
|
|
||||||
ACE_OS::close(patch_fd_);
|
|
||||||
}
|
|
||||||
|
|
||||||
int PatchHandler::open(void*)
|
|
||||||
{
|
|
||||||
if (get_handle() == ACE_INVALID_HANDLE || patch_fd_ == ACE_INVALID_HANDLE)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
int nodelay = 0;
|
|
||||||
if (-1 == peer().set_option(ACE_IPPROTO_TCP,
|
|
||||||
TCP_NODELAY,
|
|
||||||
&nodelay,
|
|
||||||
sizeof(nodelay)))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(TCP_CORK)
|
|
||||||
int cork = 1;
|
|
||||||
if (-1 == peer().set_option(ACE_IPPROTO_TCP,
|
|
||||||
TCP_CORK,
|
|
||||||
&cork,
|
|
||||||
sizeof(cork)))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif // TCP_CORK
|
|
||||||
|
|
||||||
(void) peer().disable(ACE_NONBLOCK);
|
|
||||||
|
|
||||||
return activate(THR_NEW_LWP | THR_DETACHED | THR_INHERIT_SCHED);
|
|
||||||
}
|
|
||||||
|
|
||||||
int PatchHandler::svc(void)
|
|
||||||
{
|
|
||||||
// Do 1 second sleep, similar to the one in game/WorldSocket.cpp
|
|
||||||
// Seems client have problems with too fast sends.
|
|
||||||
ACE_OS::sleep(1);
|
|
||||||
|
|
||||||
int flags = MSG_NOSIGNAL;
|
|
||||||
|
|
||||||
Chunk data;
|
|
||||||
data.cmd = CMD_XFER_DATA;
|
|
||||||
|
|
||||||
ssize_t r;
|
|
||||||
|
|
||||||
while ((r = ACE_OS::read(patch_fd_, data.data, sizeof(data.data))) > 0)
|
|
||||||
{
|
|
||||||
data.data_size = (ACE_UINT16)r;
|
|
||||||
|
|
||||||
if (peer().send((const char*)&data,
|
|
||||||
((size_t) r) + sizeof(data) - sizeof(data.data),
|
|
||||||
flags) == -1)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r == -1)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PatchCache::~PatchCache()
|
|
||||||
{
|
|
||||||
for (Patches::iterator i = patches_.begin(); i != patches_.end(); ++i)
|
|
||||||
delete i->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
PatchCache::PatchCache()
|
|
||||||
{
|
|
||||||
LoadPatchesInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
PatchCache* PatchCache::instance()
|
|
||||||
{
|
|
||||||
return ACE_Singleton<PatchCache, ACE_Thread_Mutex>::instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PatchCache::LoadPatchMD5(const char* szFileName)
|
|
||||||
{
|
|
||||||
// Try to open the patch file
|
|
||||||
std::string path = "./patches/";
|
|
||||||
path += szFileName;
|
|
||||||
FILE* pPatch = fopen(path.c_str(), "rb");
|
|
||||||
sLog.outDebug("Loading patch info from %s", path.c_str());
|
|
||||||
|
|
||||||
if (!pPatch)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Calculate the MD5 hash
|
|
||||||
MD5_CTX ctx;
|
|
||||||
MD5_Init(&ctx);
|
|
||||||
|
|
||||||
const size_t check_chunk_size = 4 * 1024;
|
|
||||||
|
|
||||||
ACE_UINT8 buf[check_chunk_size];
|
|
||||||
|
|
||||||
while (!feof(pPatch))
|
|
||||||
{
|
|
||||||
size_t read = fread(buf, 1, check_chunk_size, pPatch);
|
|
||||||
MD5_Update(&ctx, buf, read);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(pPatch);
|
|
||||||
|
|
||||||
// Store the result in the internal patch hash map
|
|
||||||
patches_[path] = new PATCH_INFO;
|
|
||||||
MD5_Final((ACE_UINT8*) & patches_[path]->md5, &ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PatchCache::GetHash(const char* pat, ACE_UINT8 mymd5[MD5_DIGEST_LENGTH])
|
|
||||||
{
|
|
||||||
for (Patches::iterator i = patches_.begin(); i != patches_.end(); ++i)
|
|
||||||
if (!stricmp(pat, i->first.c_str()))
|
|
||||||
{
|
|
||||||
memcpy(mymd5, i->second->md5, MD5_DIGEST_LENGTH);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PatchCache::LoadPatchesInfo()
|
|
||||||
{
|
|
||||||
ACE_DIR* dirp = ACE_OS::opendir(ACE_TEXT("./patches/"));
|
|
||||||
|
|
||||||
if (!dirp)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ACE_DIRENT* dp;
|
|
||||||
|
|
||||||
while ((dp = ACE_OS::readdir(dirp)) != NULL)
|
|
||||||
{
|
|
||||||
int l = strlen(dp->d_name);
|
|
||||||
if (l < 8)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!memcmp(&dp->d_name[l - 4], ".mpq", 4))
|
|
||||||
LoadPatchMD5(dp->d_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
ACE_OS::closedir(dirp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
\ingroup realmd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PATCHHANDLER_H_
|
|
||||||
#define _PATCHHANDLER_H_
|
|
||||||
|
|
||||||
#include <ace/Basic_Types.h>
|
|
||||||
#include <ace/Synch_Traits.h>
|
|
||||||
#include <ace/Svc_Handler.h>
|
|
||||||
#include <ace/SOCK_Stream.h>
|
|
||||||
#include <ace/Message_Block.h>
|
|
||||||
#include <ace/Auto_Ptr.h>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include <openssl/bn.h>
|
|
||||||
#include <openssl/md5.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Caches MD5 hash of client patches present on the server
|
|
||||||
*/
|
|
||||||
class PatchCache
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
~PatchCache();
|
|
||||||
PatchCache();
|
|
||||||
|
|
||||||
static PatchCache* instance();
|
|
||||||
|
|
||||||
struct PATCH_INFO
|
|
||||||
{
|
|
||||||
ACE_UINT8 md5[MD5_DIGEST_LENGTH];
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::map<std::string, PATCH_INFO*> Patches;
|
|
||||||
|
|
||||||
Patches::const_iterator begin() const
|
|
||||||
{
|
|
||||||
return patches_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
Patches::const_iterator end() const
|
|
||||||
{
|
|
||||||
return patches_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadPatchMD5(const char*);
|
|
||||||
bool GetHash(const char* pat, ACE_UINT8 mymd5[MD5_DIGEST_LENGTH]);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void LoadPatchesInfo();
|
|
||||||
Patches patches_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PatchHandler: public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> Base;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PatchHandler(ACE_HANDLE socket, ACE_HANDLE patch);
|
|
||||||
virtual ~PatchHandler();
|
|
||||||
|
|
||||||
int open(void* = 0) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int svc(void) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ACE_HANDLE patch_fd_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _BK_PATCHHANDLER_H__ */
|
|
||||||
|
|
||||||
|
|
@ -1,187 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
\ingroup realmd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "RealmList.h"
|
|
||||||
#include "AuthCodes.h"
|
|
||||||
#include "Util.h" // for Tokens typedef
|
|
||||||
#include "Policies/Singleton.h"
|
|
||||||
#include "Database/DatabaseEnv.h"
|
|
||||||
|
|
||||||
INSTANTIATE_SINGLETON_1(RealmList);
|
|
||||||
|
|
||||||
extern DatabaseType LoginDatabase;
|
|
||||||
|
|
||||||
// will only support WoW 1.12.1/1.12.2/1.12.3, WoW:TBC 2.4.3, WoW:WotLK 3.3.5a and official release for WoW:Cataclysm and later, client builds 15595, 10505, 8606, 6005, 5875
|
|
||||||
// if you need more from old build then add it in cases in realmd sources code
|
|
||||||
// list sorted from high to low build and first build used as low bound for accepted by default range (any > it will accepted by realmd at least)
|
|
||||||
|
|
||||||
static RealmBuildInfo ExpectedRealmdClientBuilds[] =
|
|
||||||
{
|
|
||||||
{15595, 4, 3, 4, ' '}, // highest supported build, also auto accept all above for simplify future supported builds testing
|
|
||||||
{15050, 4, 3, 0, ' '},
|
|
||||||
{13623, 4, 0, 6, 'a'},
|
|
||||||
{12340, 3, 3, 5, 'a'},
|
|
||||||
{11723, 3, 3, 3, 'a'},
|
|
||||||
{11403, 3, 3, 2, ' '},
|
|
||||||
{11159, 3, 3, 0, 'a'},
|
|
||||||
{10505, 3, 2, 2, 'a'},
|
|
||||||
{8606, 2, 4, 3, ' '},
|
|
||||||
{6141, 1, 12, 3, ' '},
|
|
||||||
{6005, 1, 12, 2, ' '},
|
|
||||||
{5875, 1, 12, 1, ' '},
|
|
||||||
{0, 0, 0, 0, ' '} // terminator
|
|
||||||
};
|
|
||||||
|
|
||||||
RealmBuildInfo const* FindBuildInfo(uint16 _build)
|
|
||||||
{
|
|
||||||
// first build is low bound of always accepted range
|
|
||||||
if (_build >= ExpectedRealmdClientBuilds[0].build)
|
|
||||||
return &ExpectedRealmdClientBuilds[0];
|
|
||||||
|
|
||||||
// continue from 1 with explicit equal check
|
|
||||||
for (int i = 1; ExpectedRealmdClientBuilds[i].build; ++i)
|
|
||||||
if (_build == ExpectedRealmdClientBuilds[i].build)
|
|
||||||
return &ExpectedRealmdClientBuilds[i];
|
|
||||||
|
|
||||||
// none appropriate build
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RealmList& sRealmList
|
|
||||||
{
|
|
||||||
static RealmList realmlist;
|
|
||||||
return realmlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Load the realm list from the database
|
|
||||||
void RealmList::Initialize(uint32 updateInterval)
|
|
||||||
{
|
|
||||||
m_UpdateInterval = updateInterval;
|
|
||||||
|
|
||||||
///- Get the content of the realmlist table in the database
|
|
||||||
UpdateRealms(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealmList::UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, RealmFlags realmflags, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, const std::string& builds)
|
|
||||||
{
|
|
||||||
///- Create new if not exist or update existed
|
|
||||||
Realm& realm = m_realms[name];
|
|
||||||
|
|
||||||
realm.m_ID = ID;
|
|
||||||
realm.icon = icon;
|
|
||||||
realm.realmflags = realmflags;
|
|
||||||
realm.timezone = timezone;
|
|
||||||
realm.allowedSecurityLevel = allowedSecurityLevel;
|
|
||||||
realm.populationLevel = popu;
|
|
||||||
|
|
||||||
Tokens tokens = StrSplit(builds, " ");
|
|
||||||
Tokens::iterator iter;
|
|
||||||
|
|
||||||
for (iter = tokens.begin(); iter != tokens.end(); ++iter)
|
|
||||||
{
|
|
||||||
uint32 build = atol((*iter).c_str());
|
|
||||||
realm.realmbuilds.insert(build);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16 first_build = !realm.realmbuilds.empty() ? *realm.realmbuilds.begin() : 0;
|
|
||||||
|
|
||||||
realm.realmBuildInfo.build = first_build;
|
|
||||||
realm.realmBuildInfo.major_version = 0;
|
|
||||||
realm.realmBuildInfo.minor_version = 0;
|
|
||||||
realm.realmBuildInfo.bugfix_version = 0;
|
|
||||||
realm.realmBuildInfo.hotfix_version = ' ';
|
|
||||||
|
|
||||||
if (first_build)
|
|
||||||
if (RealmBuildInfo const* bInfo = FindBuildInfo(first_build))
|
|
||||||
if (bInfo->build == first_build)
|
|
||||||
realm.realmBuildInfo = *bInfo;
|
|
||||||
|
|
||||||
///- Append port to IP address.
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << address << ":" << port;
|
|
||||||
realm.address = ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
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(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealmList::UpdateRealms(bool init)
|
|
||||||
{
|
|
||||||
DETAIL_LOG("Updating Realm List...");
|
|
||||||
|
|
||||||
//// 0 1 2 3 4 5 6 7 8 9
|
|
||||||
QueryResult* result = LoginDatabase.Query("SELECT id, name, address, port, icon, realmflags, timezone, allowedSecurityLevel, population, realmbuilds FROM realmlist WHERE (realmflags & 1) = 0 ORDER BY name");
|
|
||||||
|
|
||||||
///- Circle through results and add them to the realm map
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Field* fields = result->Fetch();
|
|
||||||
|
|
||||||
uint32 Id = fields[0].GetUInt32();
|
|
||||||
std::string name = fields[1].GetCppString();
|
|
||||||
uint8 realmflags = fields[5].GetUInt8();
|
|
||||||
uint8 allowedSecurityLevel = fields[7].GetUInt8();
|
|
||||||
|
|
||||||
if (realmflags & ~(REALM_FLAG_OFFLINE | REALM_FLAG_NEW_PLAYERS | REALM_FLAG_RECOMMENDED | REALM_FLAG_SPECIFYBUILD))
|
|
||||||
{
|
|
||||||
sLog.outError("Realm (id %u, name '%s') can only be flagged as OFFLINE (mask 0x02), NEWPLAYERS (mask 0x20), RECOMMENDED (mask 0x40), or SPECIFICBUILD (mask 0x04) in DB", Id, name.c_str());
|
|
||||||
realmflags &= (REALM_FLAG_OFFLINE | REALM_FLAG_NEW_PLAYERS | REALM_FLAG_RECOMMENDED | REALM_FLAG_SPECIFYBUILD);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateRealm(
|
|
||||||
Id, name, fields[2].GetCppString(), fields[3].GetUInt32(),
|
|
||||||
fields[4].GetUInt8(), RealmFlags(realmflags), fields[6].GetUInt8(),
|
|
||||||
(allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR),
|
|
||||||
fields[8].GetFloat(), fields[9].GetCppString());
|
|
||||||
|
|
||||||
if (init)
|
|
||||||
sLog.outString("Added realm id %u, name '%s'", Id, name.c_str());
|
|
||||||
}
|
|
||||||
while (result->NextRow());
|
|
||||||
delete result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
/**
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// \addtogroup realmd
|
|
||||||
/// @{
|
|
||||||
/// \file
|
|
||||||
|
|
||||||
#ifndef _REALMLIST_H
|
|
||||||
#define _REALMLIST_H
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
|
|
||||||
struct RealmBuildInfo
|
|
||||||
{
|
|
||||||
int build;
|
|
||||||
int major_version;
|
|
||||||
int minor_version;
|
|
||||||
int bugfix_version;
|
|
||||||
int hotfix_version;
|
|
||||||
};
|
|
||||||
|
|
||||||
RealmBuildInfo const* FindBuildInfo(uint16 _build);
|
|
||||||
|
|
||||||
typedef std::set<uint32> RealmBuilds;
|
|
||||||
|
|
||||||
/// Storage object for a realm
|
|
||||||
struct Realm
|
|
||||||
{
|
|
||||||
std::string address;
|
|
||||||
uint8 icon;
|
|
||||||
RealmFlags realmflags; // realmflags
|
|
||||||
uint8 timezone;
|
|
||||||
uint32 m_ID;
|
|
||||||
AccountTypes allowedSecurityLevel; // current allowed join security level (show as locked for not fit accounts)
|
|
||||||
float populationLevel;
|
|
||||||
RealmBuilds realmbuilds; // list of supported builds (updated in DB by mangosd)
|
|
||||||
RealmBuildInfo realmBuildInfo; // build info for show version in list
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Storage object for the list of realms on the server
|
|
||||||
class RealmList
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef std::map<std::string, Realm> RealmMap;
|
|
||||||
|
|
||||||
static RealmList& Instance();
|
|
||||||
|
|
||||||
RealmList();
|
|
||||||
~RealmList() {}
|
|
||||||
|
|
||||||
void Initialize(uint32 updateInterval);
|
|
||||||
|
|
||||||
void UpdateIfNeed();
|
|
||||||
|
|
||||||
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(); }
|
|
||||||
private:
|
|
||||||
void UpdateRealms(bool init);
|
|
||||||
void UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, RealmFlags realmflags, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, const std::string& builds);
|
|
||||||
private:
|
|
||||||
RealmMap m_realms; ///< Internal map of realms
|
|
||||||
uint32 m_UpdateInterval;
|
|
||||||
time_t m_NextUpdateTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define sRealmList RealmList::Instance()
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/// @}
|
|
||||||
|
|
@ -1,128 +0,0 @@
|
||||||
############################################
|
|
||||||
# MaNGOS realmd configuration file #
|
|
||||||
############################################
|
|
||||||
|
|
||||||
[RealmdConf]
|
|
||||||
ConfVersion=2010062001
|
|
||||||
|
|
||||||
###################################################################################################################
|
|
||||||
# REALMD SETTINGS
|
|
||||||
#
|
|
||||||
# LoginDatabaseInfo
|
|
||||||
# Database connection settings for the realm server.
|
|
||||||
# Default: hostname;port;username;password;database
|
|
||||||
# .;somenumber;username;password;database - use named pipes at Windows
|
|
||||||
# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini
|
|
||||||
# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux
|
|
||||||
# Unix sockets: experimental, not tested
|
|
||||||
#
|
|
||||||
# LogsDir
|
|
||||||
# Logs directory setting.
|
|
||||||
# Important: Logs dir must exists, or all logs be disable
|
|
||||||
# Default: "" - no log directory prefix. if used log names aren't absolute paths
|
|
||||||
# then logs will be stored in the current directory of the running program.
|
|
||||||
#
|
|
||||||
# MaxPingTime
|
|
||||||
# Settings for maximum database-ping interval (minutes between pings)
|
|
||||||
#
|
|
||||||
# RealmServerPort
|
|
||||||
# Port on which the server will listen
|
|
||||||
#
|
|
||||||
# BindIP
|
|
||||||
# Bind Realm Server to IP/hostname
|
|
||||||
# This option is useful for running multiple worldd/realmd instances
|
|
||||||
# on different IP addresses using default ports.
|
|
||||||
# DO NOT CHANGE THIS UNLESS YOU _REALLY_ KNOW WHAT YOU'RE DOING
|
|
||||||
#
|
|
||||||
# PidFile
|
|
||||||
# Realmd daemon PID file
|
|
||||||
# Default: "" - do not create PID file
|
|
||||||
# "./realmd.pid" - create PID file (recommended name)
|
|
||||||
#
|
|
||||||
# LogLevel
|
|
||||||
# Server console level of logging
|
|
||||||
# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug
|
|
||||||
# Default: 0
|
|
||||||
#
|
|
||||||
# LogTime
|
|
||||||
# Include time in server console output [hh:mm:ss]
|
|
||||||
# Default: 0 (no time)
|
|
||||||
# 1 (print time)
|
|
||||||
#
|
|
||||||
# LogFile
|
|
||||||
# Logfile name
|
|
||||||
# Default: "Realmd.log"
|
|
||||||
# "" - empty name disable creating log file
|
|
||||||
#
|
|
||||||
# LogTimestamp
|
|
||||||
# Logfile with timestamp of server start in name
|
|
||||||
# Default: 0 - no timestamp in name
|
|
||||||
# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext
|
|
||||||
#
|
|
||||||
# LogFileLevel
|
|
||||||
# Server file level of logging
|
|
||||||
# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug
|
|
||||||
# Default: 0
|
|
||||||
#
|
|
||||||
# LogColors
|
|
||||||
# Color for messages (format "normal_color details_color debug_color error_color)
|
|
||||||
# Colors: 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
|
|
||||||
# Default: "" - none colors
|
|
||||||
# "13 7 11 9" - for example :)
|
|
||||||
#
|
|
||||||
# UseProcessors
|
|
||||||
# Used processors mask for multi-processors system (Used only at Windows)
|
|
||||||
# Default: 0 (selected by OS)
|
|
||||||
# number (bitmask value of selected processors)
|
|
||||||
#
|
|
||||||
# ProcessPriority
|
|
||||||
# Process proirity setting (Used only at Windows)
|
|
||||||
# Default: 1 (HIGH)
|
|
||||||
# 0 (Normal)
|
|
||||||
#
|
|
||||||
# WaitAtStartupError
|
|
||||||
# After startup error report wait <Enter> or some time before continue (and possible close console window)
|
|
||||||
# -1 (wait until <Enter> press)
|
|
||||||
# Default: 0 (not wait)
|
|
||||||
# N (>0, wait N secs)
|
|
||||||
#
|
|
||||||
# RealmsStateUpdateDelay
|
|
||||||
# Realm list Update up delay (updated at realm list request if delay expired).
|
|
||||||
# Default: 20
|
|
||||||
# 0 (Disabled)
|
|
||||||
#
|
|
||||||
# WrongPass.MaxCount
|
|
||||||
# Number of login attemps with wrong password before the account or IP is banned
|
|
||||||
# Default: 0 (Never ban)
|
|
||||||
#
|
|
||||||
# WrongPass.BanTime
|
|
||||||
# Duration of the ban in seconds (0 means permanent ban)
|
|
||||||
# Default: 600
|
|
||||||
#
|
|
||||||
# WrongPass.BanType
|
|
||||||
# Ban the IP or account on which login is attempted
|
|
||||||
# Default: 0 (Ban IP)
|
|
||||||
# 1 (Ban Account)
|
|
||||||
#
|
|
||||||
###################################################################################################################
|
|
||||||
|
|
||||||
LoginDatabaseInfo = "127.0.0.1;3306;mangos;mangos;realmd"
|
|
||||||
LogsDir = ""
|
|
||||||
MaxPingTime = 30
|
|
||||||
RealmServerPort = 3724
|
|
||||||
BindIP = "0.0.0.0"
|
|
||||||
PidFile = ""
|
|
||||||
LogLevel = 0
|
|
||||||
LogTime = 0
|
|
||||||
LogFile = "Realmd.log"
|
|
||||||
LogTimestamp = 0
|
|
||||||
LogFileLevel = 0
|
|
||||||
LogColors = ""
|
|
||||||
UseProcessors = 0
|
|
||||||
ProcessPriority = 1
|
|
||||||
WaitAtStartupError = 0
|
|
||||||
RealmsStateUpdateDelay = 20
|
|
||||||
WrongPass.MaxCount = 0
|
|
||||||
WrongPass.BanTime = 600
|
|
||||||
WrongPass.BanType = 0
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
|
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
|
||||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
|
||||||
*
|
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
|
||||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
IDI_APPICON ICON DISCARDABLE "realmd.ico"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue