aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-07-15 00:43:19 +0200
committerShauren <shauren.trinity@gmail.com>2023-07-15 00:43:19 +0200
commitcdfaecda52e165bb04381e1677108ff87b8bdf13 (patch)
tree297a9418ee09a5fcac2cbbada9ad0dc486586fbc /src
parentfce667b738f52e57918082c8e14edd01345d870c (diff)
Core/Network: Cleanup asio using directives
Diffstat (limited to 'src')
-rw-r--r--src/server/bnetserver/Main.cpp1
-rw-r--r--src/server/bnetserver/Server/Session.cpp2
-rw-r--r--src/server/bnetserver/Server/Session.h4
-rw-r--r--src/server/bnetserver/Server/SessionManager.cpp4
-rw-r--r--src/server/bnetserver/Server/SessionManager.h2
-rw-r--r--src/server/game/Server/WorldSocket.cpp4
-rw-r--r--src/server/game/Server/WorldSocketMgr.cpp8
-rw-r--r--src/server/game/Server/WorldSocketMgr.h2
-rw-r--r--src/server/shared/Networking/AsyncAcceptor.h18
-rw-r--r--src/server/shared/Networking/NetworkThread.h6
-rw-r--r--src/server/shared/Networking/Socket.h8
-rw-r--r--src/server/shared/Networking/SocketMgr.h6
-rw-r--r--src/server/shared/Networking/SslSocket.h9
-rw-r--r--src/server/worldserver/RemoteAccess/RASession.cpp2
-rw-r--r--src/server/worldserver/RemoteAccess/RASession.h14
15 files changed, 36 insertions, 54 deletions
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp
index 591f68e5343..a1b93920489 100644
--- a/src/server/bnetserver/Main.cpp
+++ b/src/server/bnetserver/Main.cpp
@@ -51,7 +51,6 @@
#include "Hacks/boost_program_options_with_filesystem_path.h"
-using boost::asio::ip::tcp;
using namespace boost::program_options;
namespace fs = boost::filesystem;
diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp
index 4a65de30f1d..806b371f79d 100644
--- a/src/server/bnetserver/Server/Session.cpp
+++ b/src/server/bnetserver/Server/Session.cpp
@@ -69,7 +69,7 @@ void Battlenet::Session::GameAccountInfo::LoadResult(Field* fields)
DisplayName = Name;
}
-Battlenet::Session::Session(tcp::socket&& socket) : BattlenetSocket(std::move(socket)), _accountInfo(new AccountInfo()), _gameAccountInfo(nullptr), _locale(),
+Battlenet::Session::Session(boost::asio::ip::tcp::socket&& socket) : BattlenetSocket(std::move(socket)), _accountInfo(new AccountInfo()), _gameAccountInfo(nullptr), _locale(),
_os(), _build(0), _ipCountry(), _authed(false), _requestToken(0)
{
_headerLengthBuffer.Resize(2);
diff --git a/src/server/bnetserver/Server/Session.h b/src/server/bnetserver/Server/Session.h
index 4809b7d894d..fd375b3a19a 100644
--- a/src/server/bnetserver/Server/Session.h
+++ b/src/server/bnetserver/Server/Session.h
@@ -28,8 +28,6 @@
#include <google/protobuf/message.h>
#include <memory>
-using boost::asio::ip::tcp;
-
namespace pb = google::protobuf;
class ServiceBase;
@@ -111,7 +109,7 @@ namespace Battlenet
std::unordered_map<uint32, GameAccountInfo> GameAccounts;
};
- explicit Session(tcp::socket&& socket);
+ explicit Session(boost::asio::ip::tcp::socket&& socket);
~Session();
void Start() override;
diff --git a/src/server/bnetserver/Server/SessionManager.cpp b/src/server/bnetserver/Server/SessionManager.cpp
index a0a0ff7aa47..dd5f73a788f 100644
--- a/src/server/bnetserver/Server/SessionManager.cpp
+++ b/src/server/bnetserver/Server/SessionManager.cpp
@@ -35,9 +35,9 @@ NetworkThread<Battlenet::Session>* Battlenet::SessionManager::CreateThreads() co
return new NetworkThread<Session>[GetNetworkThreadCount()];
}
-void Battlenet::SessionManager::OnSocketAccept(tcp::socket&& sock, uint32 threadIndex)
+void Battlenet::SessionManager::OnSocketAccept(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex)
{
- sSessionMgr.OnSocketOpen(std::forward<tcp::socket>(sock), threadIndex);
+ sSessionMgr.OnSocketOpen(std::forward<boost::asio::ip::tcp::socket>(sock), threadIndex);
}
Battlenet::SessionManager& Battlenet::SessionManager::Instance()
diff --git a/src/server/bnetserver/Server/SessionManager.h b/src/server/bnetserver/Server/SessionManager.h
index f2c3c19fa64..c635122c977 100644
--- a/src/server/bnetserver/Server/SessionManager.h
+++ b/src/server/bnetserver/Server/SessionManager.h
@@ -36,7 +36,7 @@ namespace Battlenet
NetworkThread<Session>* CreateThreads() const override;
private:
- static void OnSocketAccept(tcp::socket&& sock, uint32 threadIndex);
+ static void OnSocketAccept(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex);
};
}
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index 08c972cc12f..c92b8d03c8f 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -47,8 +47,6 @@ struct CompressedWorldPacket
#pragma pack(pop)
-using boost::asio::ip::tcp;
-
std::string const WorldSocket::ServerConnectionInitialize("WORLD OF WARCRAFT CONNECTION - SERVER TO CLIENT - V2");
std::string const WorldSocket::ClientConnectionInitialize("WORLD OF WARCRAFT CONNECTION - CLIENT TO SERVER - V2");
uint32 const WorldSocket::MinSizeForCompression = 0x400;
@@ -58,7 +56,7 @@ uint8 const WorldSocket::SessionKeySeed[16] = { 0x58, 0xCB, 0xCF, 0x40, 0xFE, 0x
uint8 const WorldSocket::ContinuedSessionSeed[16] = { 0x16, 0xAD, 0x0C, 0xD4, 0x46, 0xF9, 0x4F, 0xB2, 0xEF, 0x7D, 0xEA, 0x2A, 0x17, 0x66, 0x4D, 0x2F };
uint8 const WorldSocket::EncryptionKeySeed[16] = { 0xE9, 0x75, 0x3C, 0x50, 0x90, 0x93, 0x61, 0xDA, 0x3B, 0x07, 0xEE, 0xFA, 0xFF, 0x9D, 0x41, 0xB8 };
-WorldSocket::WorldSocket(tcp::socket&& socket) : Socket(std::move(socket)),
+WorldSocket::WorldSocket(boost::asio::ip::tcp::socket&& socket) : Socket(std::move(socket)),
_type(CONNECTION_TYPE_REALM), _key(0), _OverSpeedPings(0),
_worldSession(nullptr), _authed(false), _canRequestHotfixes(true), _sendBufferSize(4096), _compressionStream(nullptr)
{
diff --git a/src/server/game/Server/WorldSocketMgr.cpp b/src/server/game/Server/WorldSocketMgr.cpp
index 37f3d2ddda3..e53bcb698a0 100644
--- a/src/server/game/Server/WorldSocketMgr.cpp
+++ b/src/server/game/Server/WorldSocketMgr.cpp
@@ -22,9 +22,9 @@
#include "WorldSocket.h"
#include <boost/system/error_code.hpp>
-static void OnSocketAccept(tcp::socket&& sock, uint32 threadIndex)
+static void OnSocketAccept(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex)
{
- sWorldSocketMgr.OnSocketOpen(std::forward<tcp::socket>(sock), threadIndex);
+ sWorldSocketMgr.OnSocketOpen(std::forward<boost::asio::ip::tcp::socket>(sock), threadIndex);
}
class WorldSocketThread : public NetworkThread<WorldSocket>
@@ -120,7 +120,7 @@ void WorldSocketMgr::StopNetwork()
sScriptMgr->OnNetworkStop();
}
-void WorldSocketMgr::OnSocketOpen(tcp::socket&& sock, uint32 threadIndex)
+void WorldSocketMgr::OnSocketOpen(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex)
{
// set some options here
if (_socketSystemSendBufferSize >= 0)
@@ -148,7 +148,7 @@ void WorldSocketMgr::OnSocketOpen(tcp::socket&& sock, uint32 threadIndex)
//sock->m_OutBufferSize = static_cast<size_t> (m_SockOutUBuff);
- BaseSocketMgr::OnSocketOpen(std::forward<tcp::socket>(sock), threadIndex);
+ BaseSocketMgr::OnSocketOpen(std::forward<boost::asio::ip::tcp::socket>(sock), threadIndex);
}
NetworkThread<WorldSocket>* WorldSocketMgr::CreateThreads() const
diff --git a/src/server/game/Server/WorldSocketMgr.h b/src/server/game/Server/WorldSocketMgr.h
index 264dd9f73ad..7049a6fff46 100644
--- a/src/server/game/Server/WorldSocketMgr.h
+++ b/src/server/game/Server/WorldSocketMgr.h
@@ -44,7 +44,7 @@ public:
/// Stops all network threads, It will wait for all running threads .
void StopNetwork() override;
- void OnSocketOpen(tcp::socket&& sock, uint32 threadIndex) override;
+ void OnSocketOpen(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex) override;
std::size_t GetApplicationSendBufferSize() const { return _socketApplicationSendBufferSize; }
diff --git a/src/server/shared/Networking/AsyncAcceptor.h b/src/server/shared/Networking/AsyncAcceptor.h
index 782fa26f879..24a5c7d4b0e 100644
--- a/src/server/shared/Networking/AsyncAcceptor.h
+++ b/src/server/shared/Networking/AsyncAcceptor.h
@@ -25,14 +25,12 @@
#include <atomic>
#include <functional>
-using boost::asio::ip::tcp;
-
#define TRINITY_MAX_LISTEN_CONNECTIONS boost::asio::socket_base::max_listen_connections
class AsyncAcceptor
{
public:
- typedef void(*AcceptCallback)(tcp::socket&& newSocket, uint32 threadIndex);
+ typedef void(*AcceptCallback)(boost::asio::ip::tcp::socket&& newSocket, uint32 threadIndex);
AsyncAcceptor(Trinity::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port) :
_acceptor(ioContext), _endpoint(Trinity::Net::make_address(bindIp), port),
@@ -48,7 +46,7 @@ public:
{
auto [tmpSocket, tmpThreadIndex] = _socketFactory();
// TODO: get rid of temporary variables (clang 15 cannot handle variables from structured bindings as lambda captures)
- tcp::socket* socket = tmpSocket;
+ boost::asio::ip::tcp::socket* socket = tmpSocket;
uint32 threadIndex = tmpThreadIndex;
_acceptor.async_accept(*socket, [this, socket, threadIndex](boost::system::error_code error)
{
@@ -116,16 +114,16 @@ public:
_acceptor.close(err);
}
- void SetSocketFactory(std::function<std::pair<tcp::socket*, uint32>()> func) { _socketFactory = func; }
+ void SetSocketFactory(std::function<std::pair<boost::asio::ip::tcp::socket*, uint32>()> func) { _socketFactory = func; }
private:
- std::pair<tcp::socket*, uint32> DefeaultSocketFactory() { return std::make_pair(&_socket, 0); }
+ std::pair<boost::asio::ip::tcp::socket*, uint32> DefeaultSocketFactory() { return std::make_pair(&_socket, 0); }
- tcp::acceptor _acceptor;
- tcp::endpoint _endpoint;
- tcp::socket _socket;
+ boost::asio::ip::tcp::acceptor _acceptor;
+ boost::asio::ip::tcp::endpoint _endpoint;
+ boost::asio::ip::tcp::socket _socket;
std::atomic<bool> _closed;
- std::function<std::pair<tcp::socket*, uint32>()> _socketFactory;
+ std::function<std::pair<boost::asio::ip::tcp::socket*, uint32>()> _socketFactory;
};
template<class T>
diff --git a/src/server/shared/Networking/NetworkThread.h b/src/server/shared/Networking/NetworkThread.h
index 40af233831e..69d62403249 100644
--- a/src/server/shared/Networking/NetworkThread.h
+++ b/src/server/shared/Networking/NetworkThread.h
@@ -29,8 +29,6 @@
#include <mutex>
#include <thread>
-using boost::asio::ip::tcp;
-
template<class SocketType>
class NetworkThread
{
@@ -88,7 +86,7 @@ public:
SocketAdded(sock);
}
- tcp::socket* GetSocketForAccept() { return &_acceptSocket; }
+ boost::asio::ip::tcp::socket* GetSocketForAccept() { return &_acceptSocket; }
protected:
virtual void SocketAdded(std::shared_ptr<SocketType> /*sock*/) { }
@@ -169,7 +167,7 @@ private:
SocketContainer _newSockets;
Trinity::Asio::IoContext _ioContext;
- tcp::socket _acceptSocket;
+ boost::asio::ip::tcp::socket _acceptSocket;
Trinity::Asio::DeadlineTimer _updateTimer;
};
diff --git a/src/server/shared/Networking/Socket.h b/src/server/shared/Networking/Socket.h
index f86b116e5c7..2856fcfeb35 100644
--- a/src/server/shared/Networking/Socket.h
+++ b/src/server/shared/Networking/Socket.h
@@ -27,8 +27,6 @@
#include <type_traits>
#include <boost/asio/ip/tcp.hpp>
-using boost::asio::ip::tcp;
-
#define READ_BLOCK_SIZE 4096
#ifdef BOOST_ASIO_HAS_IOCP
#define TC_SOCKET_USE_IOCP
@@ -61,11 +59,11 @@ using boost::asio::ip::tcp;
tcp::socket::endpoint_type remote_endpoint() const;
*/
-template<class T, class Stream = tcp::socket>
+template<class T, class Stream = boost::asio::ip::tcp::socket>
class Socket : public std::enable_shared_from_this<T>
{
public:
- explicit Socket(tcp::socket&& socket) : _socket(std::move(socket)), _remoteAddress(_socket.remote_endpoint().address()),
+ explicit Socket(boost::asio::ip::tcp::socket&& socket) : _socket(std::move(socket)), _remoteAddress(_socket.remote_endpoint().address()),
_remotePort(_socket.remote_endpoint().port()), _readBuffer(), _closed(false), _closing(false), _isWritingAsync(false)
{
_readBuffer.Resize(READ_BLOCK_SIZE);
@@ -185,7 +183,7 @@ protected:
void SetNoDelay(bool enable)
{
boost::system::error_code err;
- _socket.set_option(tcp::no_delay(enable), err);
+ _socket.set_option(boost::asio::ip::tcp::no_delay(enable), err);
if (err)
TC_LOG_DEBUG("network", "Socket::SetNoDelay: failed to set_option(boost::asio::ip::tcp::no_delay) for {} - {} ({})",
GetRemoteIpAddress().to_string(), err.value(), err.message());
diff --git a/src/server/shared/Networking/SocketMgr.h b/src/server/shared/Networking/SocketMgr.h
index 31ec4e6390b..0b2d03e0944 100644
--- a/src/server/shared/Networking/SocketMgr.h
+++ b/src/server/shared/Networking/SocketMgr.h
@@ -24,8 +24,6 @@
#include <boost/asio/ip/tcp.hpp>
#include <memory>
-using boost::asio::ip::tcp;
-
template<class SocketType>
class SocketMgr
{
@@ -95,7 +93,7 @@ public:
_threads[i].Wait();
}
- virtual void OnSocketOpen(tcp::socket&& sock, uint32 threadIndex)
+ virtual void OnSocketOpen(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex)
{
try
{
@@ -123,7 +121,7 @@ public:
return min;
}
- std::pair<tcp::socket*, uint32> GetSocketForAccept()
+ std::pair<boost::asio::ip::tcp::socket*, uint32> GetSocketForAccept()
{
uint32 threadIndex = SelectThreadWithMinConnections();
return std::make_pair(_threads[threadIndex].GetSocketForAccept(), threadIndex);
diff --git a/src/server/shared/Networking/SslSocket.h b/src/server/shared/Networking/SslSocket.h
index 48979860232..3ab76d235dd 100644
--- a/src/server/shared/Networking/SslSocket.h
+++ b/src/server/shared/Networking/SslSocket.h
@@ -22,14 +22,13 @@
#include <boost/asio/ssl/stream.hpp>
#include <boost/system/error_code.hpp>
-using boost::asio::ip::tcp;
namespace boostssl = boost::asio::ssl;
template<class SslContext>
class SslSocket
{
public:
- explicit SslSocket(tcp::socket&& socket) : _socket(std::move(socket)), _sslSocket(_socket, SslContext::instance())
+ explicit SslSocket(boost::asio::ip::tcp::socket&& socket) : _socket(std::move(socket)), _sslSocket(_socket, SslContext::instance())
{
_sslSocket.set_verify_mode(boostssl::verify_none);
}
@@ -70,7 +69,7 @@ public:
_socket.set_option(option, error);
}
- tcp::socket::endpoint_type remote_endpoint() const
+ boost::asio::ip::tcp::socket::endpoint_type remote_endpoint() const
{
return _socket.remote_endpoint();
}
@@ -83,8 +82,8 @@ public:
}
private:
- tcp::socket _socket;
- boostssl::stream<tcp::socket&> _sslSocket;
+ boost::asio::ip::tcp::socket _socket;
+ boostssl::stream<boost::asio::ip::tcp::socket&> _sslSocket;
};
#endif // SslSocket_h__
diff --git a/src/server/worldserver/RemoteAccess/RASession.cpp b/src/server/worldserver/RemoteAccess/RASession.cpp
index 09075a1f282..ff2d23a815a 100644
--- a/src/server/worldserver/RemoteAccess/RASession.cpp
+++ b/src/server/worldserver/RemoteAccess/RASession.cpp
@@ -28,8 +28,6 @@
#include <memory>
#include <thread>
-using boost::asio::ip::tcp;
-
void RASession::Start()
{
// wait 1 second for active connections to send negotiation request
diff --git a/src/server/worldserver/RemoteAccess/RASession.h b/src/server/worldserver/RemoteAccess/RASession.h
index 65ef6b414be..cfb3177e4b5 100644
--- a/src/server/worldserver/RemoteAccess/RASession.h
+++ b/src/server/worldserver/RemoteAccess/RASession.h
@@ -18,27 +18,25 @@
#ifndef __RASESSION_H__
#define __RASESSION_H__
-#include <memory>
+#include "Define.h"
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/streambuf.hpp>
-
#include <future>
-
-using boost::asio::ip::tcp;
+#include <memory>
const size_t bufferSize = 4096;
class RASession : public std::enable_shared_from_this <RASession>
{
public:
- RASession(tcp::socket&& socket) : _socket(std::move(socket)), _commandExecuting(nullptr)
+ RASession(boost::asio::ip::tcp::socket&& socket) : _socket(std::move(socket)), _commandExecuting(nullptr)
{
}
void Start();
- const std::string GetRemoteIpAddress() const { return _socket.remote_endpoint().address().to_string(); }
- unsigned short GetRemotePort() const { return _socket.remote_endpoint().port(); }
+ std::string GetRemoteIpAddress() const { return _socket.remote_endpoint().address().to_string(); }
+ uint16 GetRemotePort() const { return _socket.remote_endpoint().port(); }
private:
int Send(std::string_view data);
@@ -50,7 +48,7 @@ private:
static void CommandPrint(void* callbackArg, std::string_view text);
static void CommandFinished(void* callbackArg, bool);
- tcp::socket _socket;
+ boost::asio::ip::tcp::socket _socket;
boost::asio::streambuf _readBuffer;
boost::asio::streambuf _writeBuffer;
std::promise<void>* _commandExecuting;