Closes #1427.
* @param t The line type, should be set by the derived class constructor
*/
XLine(time_t s_time, long d, std::string src, std::string re, const std::string &t)
- : set_time(s_time), duration(d), source(src), reason(re), type(t)
+ : set_time(s_time)
+ , duration(d)
+ , source(src)
+ , reason(re)
+ , type(t)
+ , from_config(false)
{
expiry = set_time + duration;
}
*/
const std::string type;
+ // Whether this XLine was loaded from the server config.
+ bool from_config;
+
virtual bool IsBurstable();
};
* @param stats Stats context
*/
void InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats);
+
+ /** Clears any XLines which were added by the server configuration. */
+ void ClearConfigLines();
};
throw CoreException("<"+tag+":"+key+"> missing at " + ctag->getTagLocation());
std::string reason = ctag->getString("reason", "<Config>");
XLine* xl = make->Generate(ServerInstance->Time(), 0, "<Config>", reason, mask);
+ xl->from_config = true;
if (!ServerInstance->XLines->AddLine(xl, NULL))
delete xl;
}
SocketEngine::Close(socktest);
}
+ ServerInstance->XLines->ClearConfigLines();
ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z"));
ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q"));
ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
bool XLine::IsBurstable()
{
- return true;
+ return !from_config;
}
void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
return n->second;
}
+
+void XLineManager::ClearConfigLines()
+{
+ // Nothing to do.
+ if (lookup_lines.empty())
+ return;
+
+ ServerInstance->SNO->WriteToSnoMask('x', "Server rehashing; expiring lines defined in the server config ...");
+ for (ContainerIter type = lookup_lines.begin(); type != lookup_lines.end(); ++type)
+ {
+ for (LookupIter xline = type->second.begin(); xline != type->second.end(); )
+ {
+ // We cache this to avoid iterator invalidation.
+ LookupIter cachedxline = xline++;
+ if (cachedxline->second->from_config)
+ {
+ ExpireLine(type, cachedxline);
+ }
+ }
+ }
+}