feat(Core/Network): Add Proxy Protocol v2 support. (#18839)

* feat(Core/Network): Add Proxy Protocol v2 support.

* Fix codestyle and build.

* Another codestyle fix.

* One more missing include.
This commit is contained in:
Anton Popovichenko
2024-05-04 18:38:32 +02:00
committed by GitHub
parent 715b290cb7
commit 9815025341
7 changed files with 247 additions and 12 deletions

View File

@@ -20,6 +20,7 @@
#include "AuthSession.h"
#include "SocketMgr.h"
#include "Config.h"
class AuthSocketMgr : public SocketMgr<AuthSession>
{
@@ -44,7 +45,13 @@ public:
protected:
NetworkThread<AuthSession>* CreateThreads() const override
{
return new NetworkThread<AuthSession>[1];
NetworkThread<AuthSession>* threads = new NetworkThread<AuthSession>[1];
bool proxyProtocolEnabled = sConfigMgr->GetOption<bool>("EnableProxyProtocol", false, true);
if (proxyProtocolEnabled)
threads[0].EnableProxyProtocol();
return threads;
}
static void OnSocketAccept(tcp::socket&& sock, uint32 threadIndex)

View File

@@ -64,6 +64,16 @@ RealmServerPort = 3724
BindIP = "0.0.0.0"
#
# EnableProxyProtocol
# Description: Enables Proxy Protocol v2. When your server is behind a proxy,
# load balancer, or similar component, you need to enable Proxy Protocol v2 on both
# this server and the proxy/load balancer to track the real IP address of players.
# Example: 1 - (Enabled)
# Default: 0 - (Disabled)
EnableProxyProtocol = 0
#
# PidFile
# Description: Auth server PID file.