Fixed the authserver not accepting clients.
Fixed using hostnames in the realmlist table.
This commit is contained in:
1 parent
eeb2720401
commit
110396447f
4 files changed
+50
-11
No files matched your search
@@ -109,7 +109,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
|
||||
// Get the list of realms for the server
|
||||
sRealmList.Initialize(sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
sRealmList.Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
|
||||
if (sRealmList.size() == 0)
|
||||
{
|
||||
|
||||
@@ -16,17 +16,23 @@
|
||||
* 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"
|
||||
|
||||
namespace boost { namespace asio { namespace ip { class address; } } }
|
||||
|
||||
RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)) { }
|
||||
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(uint32 updateInterval)
|
||||
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
|
||||
@@ -85,12 +91,41 @@ void RealmList::UpdateRealms(bool init)
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
uint32 realmId = fields[0].GetUInt32();
|
||||
std::string name = fields[1].GetString();
|
||||
ip::address externalAddress = ip::address::from_string(fields[2].GetString());
|
||||
ip::address localAddress = ip::address::from_string(fields[3].GetString());
|
||||
ip::address localSubmask = ip::address::from_string(fields[4].GetString());
|
||||
boost::asio::ip::tcp::resolver::query externalAddressQuery(fields[2].GetString(), "");
|
||||
boost::asio::ip::tcp::resolver::iterator endPoint = _resolver->resolve(externalAddressQuery);
|
||||
if (endPoint == end)
|
||||
{
|
||||
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(fields[3].GetString(), "");
|
||||
endPoint = _resolver->resolve(localAddressQuery);
|
||||
if (endPoint == end)
|
||||
{
|
||||
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(fields[4].GetString(), "");
|
||||
endPoint = _resolver->resolve(localSubmaskQuery);
|
||||
if (endPoint == end)
|
||||
{
|
||||
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());
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#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;
|
||||
@@ -65,8 +67,10 @@ public:
|
||||
static RealmList *instance = new RealmList();
|
||||
return *instance;
|
||||
}
|
||||
|
||||
~RealmList();
|
||||
|
||||
void Initialize(uint32 updateInterval);
|
||||
void Initialize(boost::asio::io_service& ioService, uint32 updateInterval);
|
||||
|
||||
void UpdateIfNeed();
|
||||
|
||||
@@ -86,6 +90,7 @@ private:
|
||||
RealmMap m_realms;
|
||||
uint32 m_UpdateInterval;
|
||||
time_t m_NextUpdateTime;
|
||||
boost::asio::ip::tcp::resolver* _resolver;
|
||||
};
|
||||
|
||||
#define sRealmList RealmList::instance()
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <memory>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <AuthSession.h>
|
||||
#include <Log.h>
|
||||
#include "ByteBuffer.h"
|
||||
@@ -137,7 +136,7 @@ void AuthSession::AsyncReadHeader()
|
||||
{
|
||||
auto self(shared_from_this());
|
||||
|
||||
boost::asio::async_read(_socket, boost::asio::buffer(_readBuffer, 1), [this, self](boost::system::error_code error, size_t transferedBytes)
|
||||
_socket.async_read_some(boost::asio::buffer(_readBuffer, 1), [this, self](boost::system::error_code error, size_t transferedBytes)
|
||||
{
|
||||
if (!error && transferedBytes == 1)
|
||||
{
|
||||
@@ -148,7 +147,7 @@ void AuthSession::AsyncReadHeader()
|
||||
// Handle dynamic size packet
|
||||
if (_readBuffer[0] == AUTH_LOGON_CHALLENGE)
|
||||
{
|
||||
boost::asio::read(_socket, boost::asio::buffer(&_readBuffer[1], sizeof(uint8) + sizeof(uint16))); //error + size
|
||||
_socket.read_some(boost::asio::buffer(&_readBuffer[1], sizeof(uint8) + sizeof(uint16))); //error + size
|
||||
|
||||
AsyncReadData(entry.handler, *reinterpret_cast<uint16*>(&_readBuffer[2]), sizeof(uint8) + sizeof(uint8) + sizeof(uint16)); // cmd + error + size
|
||||
}
|
||||
@@ -171,7 +170,7 @@ void AuthSession::AsyncReadData(bool (AuthSession::*handler)(), size_t dataSize,
|
||||
{
|
||||
auto self(shared_from_this());
|
||||
|
||||
boost::asio::async_read(_socket, boost::asio::buffer(&_readBuffer[bufferOffSet], dataSize), [handler, this, self](boost::system::error_code error, size_t transferedBytes)
|
||||
_socket.async_read_some(boost::asio::buffer(&_readBuffer[bufferOffSet], dataSize), [handler, this, self](boost::system::error_code error, size_t transferedBytes)
|
||||
{
|
||||
if (!error && transferedBytes > 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user