feat(Core): replace ACE network with Boost.Asio (#6574)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
|
||||
*/
|
||||
|
||||
#include "Realm.h"
|
||||
#include "IpAddress.h"
|
||||
#include "IpNetwork.h"
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
boost::asio::ip::tcp_endpoint Realm::GetAddressForClient(boost::asio::ip::address const& clientAddr) const
|
||||
{
|
||||
boost::asio::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 bnetserver is located on
|
||||
// has all realms available in his local network
|
||||
realmIp = *LocalAddress;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clientAddr.is_v4() && Acore::Net::IsInNetwork(LocalAddress->to_v4(), LocalSubnetMask->to_v4(), clientAddr.to_v4()))
|
||||
{
|
||||
realmIp = *LocalAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
realmIp = *ExternalAddress;
|
||||
}
|
||||
}
|
||||
|
||||
// Return external IP
|
||||
return boost::asio::ip::tcp_endpoint(realmIp, Port);
|
||||
}
|
||||
Reference in New Issue
Block a user