mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Generalise XLine stats numerics using RPL_STATS from aircd.
This commit is contained in:
parent
5ddbcd3f56
commit
2e0cc3684d
@ -50,6 +50,7 @@ enum
|
|||||||
RPL_ENDMAP = 17, // ircu
|
RPL_ENDMAP = 17, // ircu
|
||||||
RPL_MAPUSERS = 18, // insp-specific
|
RPL_MAPUSERS = 18, // insp-specific
|
||||||
|
|
||||||
|
RPL_STATS = 210, // From aircd.
|
||||||
RPL_UMODEIS = 221,
|
RPL_UMODEIS = 221,
|
||||||
|
|
||||||
RPL_LUSERCLIENT = 251,
|
RPL_LUSERCLIENT = 251,
|
||||||
|
@ -529,14 +529,15 @@ class CoreExport XLineManager
|
|||||||
*/
|
*/
|
||||||
void ApplyLines();
|
void ApplyLines();
|
||||||
|
|
||||||
/** Handle /STATS for a given type.
|
/** DEPRECATED: use the `bool InvokeStats(const std::string&, Stats::Context&)` overload instead. */
|
||||||
* NOTE: Any items in the list for this particular line type which have expired
|
DEPRECATED_METHOD(void InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats));
|
||||||
* will be expired and removed before the list is displayed.
|
|
||||||
* @param type The type of stats to show
|
/** Generates a /STATS response for the given X-line type.
|
||||||
* @param numeric The numeric to give to each result line
|
* @param type The type of X-line to look up.
|
||||||
* @param stats Stats context
|
* @param context The stats context to respond with.
|
||||||
|
* @return True if a response was sent; otherwise, false.
|
||||||
*/
|
*/
|
||||||
void InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats);
|
bool InvokeStats(const std::string& type, Stats::Context& context);
|
||||||
|
|
||||||
/** Expire X-lines which were added by the server configuration and have been removed. */
|
/** Expire X-lines which were added by the server configuration and have been removed. */
|
||||||
void ExpireRemovedConfigLines(const std::string& type, const insp::flat_set<std::string>& configlines);
|
void ExpireRemovedConfigLines(const std::string& type, const insp::flat_set<std::string>& configlines);
|
||||||
|
@ -195,19 +195,19 @@ void CommandStats::DoStats(Stats::Context& stats)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
ServerInstance->XLines->InvokeStats("K",216,stats);
|
ServerInstance->XLines->InvokeStats("K", stats);
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
ServerInstance->XLines->InvokeStats("G",223,stats);
|
ServerInstance->XLines->InvokeStats("G", stats);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
ServerInstance->XLines->InvokeStats("Q",217,stats);
|
ServerInstance->XLines->InvokeStats("Q", stats);
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
ServerInstance->XLines->InvokeStats("Z",223,stats);
|
ServerInstance->XLines->InvokeStats("Z", stats);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
ServerInstance->XLines->InvokeStats("E",223,stats);
|
ServerInstance->XLines->InvokeStats("E", stats);
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
{
|
{
|
||||||
|
@ -188,7 +188,7 @@ class ModuleCBan : public Module, public Stats::EventListener
|
|||||||
if (stats.GetSymbol() != 'C')
|
if (stats.GetSymbol() != 'C')
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
|
|
||||||
ServerInstance->XLines->InvokeStats("CBAN", 210, stats);
|
ServerInstance->XLines->InvokeStats("CBAN", stats);
|
||||||
return MOD_RES_DENY;
|
return MOD_RES_DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ class ModuleRLine : public Module, public Stats::EventListener
|
|||||||
if (stats.GetSymbol() != 'R')
|
if (stats.GetSymbol() != 'R')
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
|
|
||||||
ServerInstance->XLines->InvokeStats("R", 223, stats);
|
ServerInstance->XLines->InvokeStats("R", stats);
|
||||||
return MOD_RES_DENY;
|
return MOD_RES_DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ class ModuleShun : public Module, public Stats::EventListener
|
|||||||
if (stats.GetSymbol() != 'H')
|
if (stats.GetSymbol() != 'H')
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
|
|
||||||
ServerInstance->XLines->InvokeStats("SHUN", 223, stats);
|
ServerInstance->XLines->InvokeStats("SHUN", stats);
|
||||||
return MOD_RES_DENY;
|
return MOD_RES_DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ class ModuleSVSHold : public Module, public Stats::EventListener
|
|||||||
if (stats.GetSymbol() != 'S')
|
if (stats.GetSymbol() != 'S')
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
|
|
||||||
ServerInstance->XLines->InvokeStats("SVSHOLD", 210, stats);
|
ServerInstance->XLines->InvokeStats("SVSHOLD", stats);
|
||||||
return MOD_RES_DENY;
|
return MOD_RES_DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,13 +498,36 @@ void XLineManager::InvokeStats(const std::string& type, unsigned int numeric, St
|
|||||||
ExpireLine(n, i);
|
ExpireLine(n, i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
stats.AddRow(numeric, i->second->Displayable()+" "+
|
stats.AddRow(numeric, i->second->Displayable(), i->second->set_time, i->second->duration, i->second->source, i->second->reason);
|
||||||
ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+i->second->source+" :"+i->second->reason);
|
|
||||||
i = safei;
|
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()
|
XLineManager::XLineManager()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user