diff options
author | Sadie Powell <sadie@witchery.services> | 2020-02-18 17:49:32 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-02-18 18:56:14 +0000 |
commit | 2e0cc3684df72b2a8de45b354848af43c6b47606 (patch) | |
tree | 5fb6b9f587309746c2311e5e3043062523cdc122 /src | |
parent | 5ddbcd3f56bb79a5dc6b693fc2c6ad7a46ba5a3c (diff) |
Generalise XLine stats numerics using RPL_STATS from aircd.
Diffstat (limited to 'src')
-rw-r--r-- | src/coremods/core_stats.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_cban.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_rline.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_shun.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_svshold.cpp | 2 | ||||
-rw-r--r-- | src/xline.cpp | 27 |
6 files changed, 34 insertions, 11 deletions
diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index b95005c5b..4b30fa5b4 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -195,19 +195,19 @@ void CommandStats::DoStats(Stats::Context& stats) break; case 'k': - ServerInstance->XLines->InvokeStats("K",216,stats); + ServerInstance->XLines->InvokeStats("K", stats); break; case 'g': - ServerInstance->XLines->InvokeStats("G",223,stats); + ServerInstance->XLines->InvokeStats("G", stats); break; case 'q': - ServerInstance->XLines->InvokeStats("Q",217,stats); + ServerInstance->XLines->InvokeStats("Q", stats); break; case 'Z': - ServerInstance->XLines->InvokeStats("Z",223,stats); + ServerInstance->XLines->InvokeStats("Z", stats); break; case 'e': - ServerInstance->XLines->InvokeStats("E",223,stats); + ServerInstance->XLines->InvokeStats("E", stats); break; case 'E': { diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 22382bdb3..ff99ae5bd 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -188,7 +188,7 @@ class ModuleCBan : public Module, public Stats::EventListener if (stats.GetSymbol() != 'C') return MOD_RES_PASSTHRU; - ServerInstance->XLines->InvokeStats("CBAN", 210, stats); + ServerInstance->XLines->InvokeStats("CBAN", stats); return MOD_RES_DENY; } diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index cb6c507f1..1876604c4 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -307,7 +307,7 @@ class ModuleRLine : public Module, public Stats::EventListener if (stats.GetSymbol() != 'R') return MOD_RES_PASSTHRU; - ServerInstance->XLines->InvokeStats("R", 223, stats); + ServerInstance->XLines->InvokeStats("R", stats); return MOD_RES_DENY; } diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 3ffe553b0..99ff05c30 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -187,7 +187,7 @@ class ModuleShun : public Module, public Stats::EventListener if (stats.GetSymbol() != 'H') return MOD_RES_PASSTHRU; - ServerInstance->XLines->InvokeStats("SHUN", 223, stats); + ServerInstance->XLines->InvokeStats("SHUN", stats); return MOD_RES_DENY; } diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index 9cdc307b9..0c5578492 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -203,7 +203,7 @@ class ModuleSVSHold : public Module, public Stats::EventListener if (stats.GetSymbol() != 'S') return MOD_RES_PASSTHRU; - ServerInstance->XLines->InvokeStats("SVSHOLD", 210, stats); + ServerInstance->XLines->InvokeStats("SVSHOLD", stats); return MOD_RES_DENY; } diff --git a/src/xline.cpp b/src/xline.cpp index 13ea2f97c..04ac67f68 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -498,13 +498,36 @@ void XLineManager::InvokeStats(const std::string& type, unsigned int numeric, St ExpireLine(n, i); } else - stats.AddRow(numeric, i->second->Displayable()+" "+ - ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+i->second->source+" :"+i->second->reason); + stats.AddRow(numeric, i->second->Displayable(), i->second->set_time, i->second->duration, i->second->source, i->second->reason); i = safei; } } } +bool XLineManager::InvokeStats(const std::string& type, Stats::Context& context) +{ + ContainerIter citer = lookup_lines.find(type); + if (citer == lookup_lines.end()) + return false; + + for (LookupIter liter = citer->second.begin(); liter != citer->second.end(); ) + { + // We might be about to expire the XLine so we have to increment the + // iterator early to avoid doing that causing iterator invalidation. + LookupIter current = liter++; + + XLine* xline = current->second; + if (xline->duration && xline->expiry <= ServerInstance->Time()) + { + // This XLine has expired so remove and skip it. + ExpireLine(citer, current); + continue; + } + + context.AddRow(RPL_STATS, context.GetSymbol(), xline->Displayable(), xline->set_time, xline->duration, xline->source, xline->reason); + } + return true; +} XLineManager::XLineManager() { |