mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[World API] Input Validation (#4904)
* [World API] Input Validation * Update eqemu_api_world_data_service.cpp * Add db ping to player events processor, move back into main thread
This commit is contained in:
parent
cb866cba31
commit
53cc2de459
@ -15,9 +15,9 @@ const uint32 PROCESS_RETENTION_TRUNCATION_TIMER_INTERVAL = 60 * 60 * 1000; // 1
|
||||
// general initialization routine
|
||||
void PlayerEventLogs::Init()
|
||||
{
|
||||
|
||||
m_process_batch_events_timer.SetTimer(RuleI(Logging, BatchPlayerEventProcessIntervalSeconds) * 1000);
|
||||
m_process_retention_truncation_timer.SetTimer(PROCESS_RETENTION_TRUNCATION_TIMER_INTERVAL);
|
||||
m_database_ping_timer.SetTimer(10 * 1000); // 10 seconds
|
||||
|
||||
ValidateDatabaseConnection();
|
||||
|
||||
@ -916,6 +916,10 @@ std::string PlayerEventLogs::GetDiscordPayloadFromEvent(const PlayerEvent::Playe
|
||||
// general process function, used in world or QS depending on rule Logging:PlayerEventsQSProcess
|
||||
void PlayerEventLogs::Process()
|
||||
{
|
||||
if (m_database_ping_timer.Check()) {
|
||||
m_database->ping();
|
||||
}
|
||||
|
||||
if (m_process_batch_events_timer.Check() ||
|
||||
m_record_batch_queue.size() >= RuleI(Logging, BatchPlayerEventProcessChunkSize)) {
|
||||
ProcessBatchQueue();
|
||||
|
||||
@ -113,6 +113,7 @@ private:
|
||||
std::map<PlayerEvent::EventType, EtlSettings> m_etl_settings{};
|
||||
|
||||
// timers
|
||||
Timer m_database_ping_timer; // database ping timer
|
||||
Timer m_process_batch_events_timer; // events processing timer
|
||||
Timer m_process_retention_truncation_timer; // timer for truncating events based on retention settings
|
||||
|
||||
|
||||
@ -95,9 +95,22 @@ void ConsoleApi(
|
||||
BenchTimer timer;
|
||||
timer.reset();
|
||||
|
||||
EQEmuApiWorldDataService::get(response, args);
|
||||
std::string method = args.empty() ? "" : args[0];
|
||||
|
||||
std::string method = args[0];
|
||||
if (method.empty()) {
|
||||
root["execution_time"] = std::to_string(timer.elapsed());
|
||||
root["method"] = method;
|
||||
root["data"] = response;
|
||||
root["error"] = "No method specified";
|
||||
|
||||
std::stringstream payload;
|
||||
payload << root;
|
||||
connection->SendLine(payload.str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Safe to call now that args[0] is known to exist
|
||||
EQEmuApiWorldDataService::get(response, args);
|
||||
|
||||
root["execution_time"] = std::to_string(timer.elapsed());
|
||||
root["method"] = method;
|
||||
@ -105,7 +118,6 @@ void ConsoleApi(
|
||||
|
||||
std::stringstream payload;
|
||||
payload << root;
|
||||
|
||||
connection->SendLine(payload.str());
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,10 @@ void callGetZoneList(Json::Value &response)
|
||||
for (auto &zone: zoneserver_list.getZoneServerList()) {
|
||||
Json::Value row;
|
||||
|
||||
if (!zone) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!zone->IsConnected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -182,7 +182,8 @@ int main(int argc, char **argv)
|
||||
EQTimeTimer.Start(600000);
|
||||
Timer parcel_prune_timer(86400000);
|
||||
parcel_prune_timer.Start(86400000);
|
||||
|
||||
Timer player_event_log_process(1000);
|
||||
player_event_log_process.Start(1000);
|
||||
|
||||
// global loads
|
||||
LogInfo("Loading launcher list");
|
||||
@ -385,15 +386,6 @@ int main(int argc, char **argv)
|
||||
player_event_logs.Init();
|
||||
}
|
||||
|
||||
auto event_log_processor = std::jthread([](const std::stop_token& stoken) {
|
||||
while (!stoken.stop_requested()) {
|
||||
if (!RuleB(Logging, PlayerEventsQSProcess)) {
|
||||
player_event_logs.Process();
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
});
|
||||
|
||||
auto loop_fn = [&](EQ::Timer* t) {
|
||||
Timer::SetCurrentTime();
|
||||
|
||||
@ -487,6 +479,12 @@ int main(int argc, char **argv)
|
||||
shared_task_manager.Process();
|
||||
dynamic_zone_manager.Process();
|
||||
|
||||
if (!RuleB(Logging, PlayerEventsQSProcess)) {
|
||||
if (player_event_log_process.Check()) {
|
||||
player_event_logs.Process();
|
||||
}
|
||||
}
|
||||
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
@ -506,8 +504,6 @@ int main(int argc, char **argv)
|
||||
|
||||
EQ::EventLoop::Get().Run();
|
||||
|
||||
event_log_processor.request_stop();
|
||||
|
||||
LogInfo("World main loop completed");
|
||||
LogInfo("Shutting down zone connections (if any)");
|
||||
zoneserver_list.KillAll();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user