diff options
| author | Subv <subv2112@gmail.com> | 2014-07-07 14:25:17 -0500 |
|---|---|---|
| committer | Subv <subv2112@gmail.com> | 2014-07-07 14:25:17 -0500 |
| commit | 110396447f2f414f8834c1b86c764d97704537b7 (patch) | |
| tree | 177f9dc0f504e0fe64784d955166835646f6287f /src/server/authserver/Realms | |
| parent | eeb272040101f246d191e81c9eab9ee0c70462da (diff) | |
Fixed the authserver not accepting clients.
Fixed using hostnames in the realmlist table.
Diffstat (limited to 'src/server/authserver/Realms')
| -rw-r--r-- | src/server/authserver/Realms/RealmList.cpp | 45 | ||||
| -rw-r--r-- | src/server/authserver/Realms/RealmList.h | 7 |
2 files changed, 46 insertions, 6 deletions
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() |
