diff options
| author | 2026-03-01 15:10:03 +0000 | |
|---|---|---|
| committer | 2026-03-01 15:15:14 +0000 | |
| commit | 4007ad9164bd7f41ca615af2fa55de25ddfdd69c (patch) | |
| tree | 723a08cb2d8e3fcf3d4e40b9bc164f6b242fdd9b /src/modules/m_messageflood.cpp | |
| parent | Bump actions/upload-artifact from 6 to 7 (diff) | |
Store users by uuid in the messageflood counter map.
This prevents weird behaviour caused by address reuse.
Reported by @progval.
Diffstat (limited to 'src/modules/m_messageflood.cpp')
| -rw-r--r-- | src/modules/m_messageflood.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 2b22d5e29..31099083d 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -51,7 +51,7 @@ struct MsgFloodData final class MsgFloodSettings final { private: - using CounterMap = insp::flat_map<User*, MsgFloodData>; + using CounterMap = insp::flat_map<std::string, MsgFloodData>; CounterMap counters; public: @@ -71,7 +71,7 @@ public: { auto it = Find(who); if (it == counters.end()) - it = counters.emplace(who, MsgFloodData(period)).first; + it = counters.emplace(who->uuid, MsgFloodData(period)).first; it->second.messages += weight; return (it->second.messages >= this->messages); @@ -79,10 +79,9 @@ public: void Clear(User* who) { - counters.erase(who); + counters.erase(who->uuid); } - CounterMap::iterator Find(User* who) { auto found = false; @@ -93,7 +92,7 @@ public: it = counters.erase(it); else { - if (it->first == who) + if (it->first == who->uuid) { found = true; ret = it; |
