aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2014-07-07 14:25:17 -0500
committerSubv <subv2112@gmail.com>2014-07-07 14:25:17 -0500
commit110396447f2f414f8834c1b86c764d97704537b7 (patch)
tree177f9dc0f504e0fe64784d955166835646f6287f /src
parenteeb272040101f246d191e81c9eab9ee0c70462da (diff)
Fixed the authserver not accepting clients.
Fixed using hostnames in the realmlist table.
Diffstat (limited to 'src')
-rw-r--r--src/server/authserver/Main.cpp2
-rw-r--r--src/server/authserver/Realms/RealmList.cpp45
-rw-r--r--src/server/authserver/Realms/RealmList.h7
-rw-r--r--src/server/authserver/Server/AuthSession.cpp7
4 files changed, 50 insertions, 11 deletions
diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp
index 39ad4b60dfe..1286e261a47 100644
--- a/src/server/authserver/Main.cpp
+++ b/src/server/authserver/Main.cpp
@@ -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)
{
diff --git a/src/server/authserver/Realms/RealmList.cpp b/src/server/authserver/Realms/RealmList.cpp
index 392d86b5621..4dd2ab96dd9 100644
--- a/src/server/authserver/Realms/RealmList.cpp
+++ b/src/server/authserver/Realms/RealmList.cpp
@@ -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());
diff --git a/src/server/authserver/Realms/RealmList.h b/src/server/authserver/Realms/RealmList.h
index e8e94376c20..b1c77d5a4b5 100644
--- a/src/server/authserver/Realms/RealmList.h
+++ b/src/server/authserver/Realms/RealmList.h
@@ -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()
diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp
index df90339222d..f518dc7593b 100644
--- a/src/server/authserver/Server/AuthSession.cpp
+++ b/src/server/authserver/Server/AuthSession.cpp
@@ -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)
{