diff --git a/docs/conf/inspircd.example.conf b/docs/conf/inspircd.example.conf index 1a3598b78..92684fec7 100644 --- a/docs/conf/inspircd.example.conf +++ b/docs/conf/inspircd.example.conf @@ -938,7 +938,6 @@ # This tag lets you define the behaviour of the /WHOWAS command of # # your server. # # # - . @@ -953,7 +952,12 @@ # before being pruned. Time may be specified in seconds, # or in the following format: 1y2w3d4h5m6s. Minimum is # 1 hour. - maxkeep="3d"> + maxkeep="3d" + + # nickupdate: Whether to update the WHOWAS database on nick + # change as well as quit. This can significantly increase the + # memory usage of your IRC server. + nickupdate="no"> #-#-#-#-#-#-#-#-#-#-#-#-#-#- BAN OPTIONS -#-#-#-#-#-#-#-#-#-#-#-#-#-# # # diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index 8acdff084..cd671db7c 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -112,7 +112,7 @@ namespace WhoWas /** Add a user to the whowas database. Called when a user quits. * @param user The user to add to the database */ - void Add(User* user); + void Add(User* user, const std::string& nickname); /** Retrieves statistics about the whowas database * @return Whowas statistics as a WhoWas::Manager::Stats struct @@ -269,14 +269,14 @@ WhoWas::Manager::Stats WhoWas::Manager::GetStats() const return stats; } -void WhoWas::Manager::Add(User* user) +void WhoWas::Manager::Add(User* user, const std::string& nickname) { if (!IsEnabled()) return; // Insert nick if it doesn't exist // 'first' will point to the newly inserted element or to the existing element with an equivalent key - std::pair ret = whowas.emplace(user->nick, nullptr); + std::pair ret = whowas.emplace(nickname, nullptr); if (ret.second) // If inserted { @@ -429,7 +429,9 @@ class ModuleWhoWas final : public Module , public Stats::EventListener { +public: CommandWhowas cmd; + bool nickupdate; public: ModuleWhoWas() @@ -447,7 +449,13 @@ public: void OnUserQuit(User* user, const std::string& message, const std::string& oper_message) override { - cmd.manager.Add(user); + cmd.manager.Add(user, user->nick); + } + + void OnUserPostNick(User* user, const std::string& oldnick) override + { + if (nickupdate) + cmd.manager.Add(user, oldnick); } ModResult OnStats(Stats::Context& stats) override @@ -464,6 +472,7 @@ public: unsigned int NewGroupSize = tag->getNum("groupsize", 10, 0, 10000); unsigned int NewMaxGroups = tag->getNum("maxgroups", 10240, 0, 1000000); unsigned int NewMaxKeep = static_cast(tag->getDuration("maxkeep", 3600, 3600)); + nickupdate = tag->getBool("nickupdate"); cmd.manager.UpdateConfig(NewGroupSize, NewMaxGroups, NewMaxKeep); }