mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Bnet: Add new loggers to config file template, fixed request/response content logging and fixed setting keep_alive on responses
This commit is contained in:
@@ -26,8 +26,6 @@
|
||||
#include "ProtobufJSON.h"
|
||||
#include "Resolver.h"
|
||||
#include "Util.h"
|
||||
#include <boost/uuid/string_generator.hpp>
|
||||
#include <fmt/chrono.h>
|
||||
|
||||
namespace Battlenet
|
||||
{
|
||||
@@ -78,7 +76,7 @@ bool LoginRESTService::StartNetwork(Trinity::Asio::IoContext& ioContext, std::st
|
||||
Optional<boost::asio::ip::tcp::endpoint> externalAddress = resolver.Resolve(boost::asio::ip::tcp::v4(), _hostnames[0], std::to_string(_port));
|
||||
if (!externalAddress)
|
||||
{
|
||||
TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.ExternalAddress {}", _hostnames[0]);
|
||||
TC_LOG_ERROR("server.http.login", "Could not resolve LoginREST.ExternalAddress {}", _hostnames[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -88,7 +86,7 @@ bool LoginRESTService::StartNetwork(Trinity::Asio::IoContext& ioContext, std::st
|
||||
Optional<boost::asio::ip::tcp::endpoint> localAddress = resolver.Resolve(boost::asio::ip::tcp::v4(), _hostnames[1], std::to_string(_port));
|
||||
if (!localAddress)
|
||||
{
|
||||
TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.LocalAddress {}", _hostnames[1]);
|
||||
TC_LOG_ERROR("server.http.login", "Could not resolve LoginREST.LocalAddress {}", _hostnames[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -288,7 +286,7 @@ LoginRESTService::RequestHandlerResult LoginRESTService::HandlePostLogin(std::sh
|
||||
uint32 maxWrongPassword = uint32(sConfigMgr->GetIntDefault("WrongPass.MaxCount", 0));
|
||||
|
||||
if (sConfigMgr->GetBoolDefault("WrongPass.Logging", false))
|
||||
TC_LOG_DEBUG("server.rest", "[{}, Account {}, Id {}] Attempted to connect with wrong password!", ip_address, login, accountId);
|
||||
TC_LOG_DEBUG("server.http.login", "[{}, Account {}, Id {}] Attempted to connect with wrong password!", ip_address, login, accountId);
|
||||
|
||||
if (maxWrongPassword)
|
||||
{
|
||||
@@ -299,7 +297,7 @@ LoginRESTService::RequestHandlerResult LoginRESTService::HandlePostLogin(std::sh
|
||||
|
||||
++failedLogins;
|
||||
|
||||
TC_LOG_DEBUG("server.rest", "MaxWrongPass : {}, failed_login : {}", maxWrongPassword, accountId);
|
||||
TC_LOG_DEBUG("server.http.login", "MaxWrongPass : {}, failed_login : {}", maxWrongPassword, accountId);
|
||||
|
||||
if (failedLogins >= maxWrongPassword)
|
||||
{
|
||||
|
||||
@@ -434,6 +434,10 @@ Appender.Bnet=2,2,0,Bnet.log,w
|
||||
|
||||
Logger.root=3,Console Bnet
|
||||
Logger.realmlist=3,Console Bnet
|
||||
Logger.server.http=3,Console Bnet
|
||||
Logger.server.http.login=3,Console Bnet
|
||||
Logger.server.http.dispatcher.login=3,Console Bnet
|
||||
Logger.server.http.session.login=3,Console Bnet
|
||||
Logger.session=3,Console Bnet
|
||||
Logger.session.packets=3,Console Bnet
|
||||
Logger.sql.updates=3,Console Bnet
|
||||
|
||||
@@ -126,9 +126,9 @@ public:
|
||||
ToStdStringView(context.request.target()), context.response.result_int());
|
||||
if (sLog->ShouldLog("server.http", LOG_LEVEL_TRACE))
|
||||
{
|
||||
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Request: ", this->GetClientInfo(),
|
||||
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Request: {}", this->GetClientInfo(),
|
||||
CanLogRequestContent(context) ? SerializeRequest(context.request) : "<REDACTED>");
|
||||
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Response: ", this->GetClientInfo(),
|
||||
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Response: {}", this->GetClientInfo(),
|
||||
CanLogResponseContent(context) ? std::string_view(reinterpret_cast<char const*>(buffer.GetBasePointer()), buffer.GetActiveSize()) : "<REDACTED>");
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ RequestHandlerResult DispatcherService::HandleRequest(std::shared_ptr<AbstractSo
|
||||
SystemTimePoint responseDate = SystemTimePoint::clock::now();
|
||||
context.response.set(boost::beast::http::field::date, StringFormat("{:%a, %d %b %Y %T GMT}", responseDate - Timezone::GetSystemZoneOffsetAt(responseDate)));
|
||||
context.response.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
context.response.keep_alive(context.response.keep_alive());
|
||||
context.response.keep_alive(context.request.keep_alive());
|
||||
|
||||
if (!context.handler)
|
||||
return HandlePathNotFound(std::move(session), context);
|
||||
@@ -192,12 +192,15 @@ std::shared_ptr<SessionState> SessionService::FindAndRefreshSessionState(std::st
|
||||
|
||||
void SessionService::MarkSessionInactive(boost::uuids::uuid const& id)
|
||||
{
|
||||
bool wasActive = true;
|
||||
{
|
||||
std::unique_lock inactiveSessionsLock{ _inactiveSessionsMutex };
|
||||
_inactiveSessions.insert(id);
|
||||
wasActive = _inactiveSessions.insert(id).second;
|
||||
}
|
||||
|
||||
if (wasActive)
|
||||
{
|
||||
std::shared_lock lock{ _sessionsMutex };
|
||||
auto itr = _sessions.find(id);
|
||||
if (itr != _sessions.end())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user