diff options
author | Treeki <treeki@gmail.com> | 2014-02-15 10:11:57 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2014-02-15 10:11:57 +0100 |
commit | 848c96b0df5282a9089bd4259e3e6ae3620f3ec9 (patch) | |
tree | 6343900bef4dd1d5c74836b639028678acd32316 /bouncer | |
parent | 878a0c157b772a7ed04d4cc395059087f964b823 (diff) | |
download | bounce4-848c96b0df5282a9089bd4259e3e6ae3620f3ec9.tar.gz bounce4-848c96b0df5282a9089bd4259e3e6ae3620f3ec9.zip |
add limiting of the amount of messages in a window
Diffstat (limited to 'bouncer')
-rw-r--r-- | bouncer/core.h | 1 | ||||
-rw-r--r-- | bouncer/netcore.cpp | 8 | ||||
-rw-r--r-- | bouncer/window.cpp | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/bouncer/core.h b/bouncer/core.h index a8f5d9b..4bb266e 100644 --- a/bouncer/core.h +++ b/bouncer/core.h @@ -397,6 +397,7 @@ public: bool quitFlag; std::string bouncerPassword; + int maxWindowMessageCount; int execute(); diff --git a/bouncer/netcore.cpp b/bouncer/netcore.cpp index 98f13a1..7c2305e 100644 --- a/bouncer/netcore.cpp +++ b/bouncer/netcore.cpp @@ -331,6 +331,10 @@ void NetCore::loadConfig() { for (auto §ion : sections) { if (section.title == "Header") { bouncerPassword = section.data["password"]; + + maxWindowMessageCount = atoi(section.data["maxBufferSize"].c_str()); + if (maxWindowMessageCount < 5 || maxWindowMessageCount > 2000) + maxWindowMessageCount = 1000; } if (section.title == "Server" && serverCount < SERVER_LIMIT) { @@ -351,6 +355,10 @@ void NetCore::saveConfig() { header.data["password"] = bouncerPassword; + char conv[50]; + sprintf(conv, "%d", maxWindowMessageCount); + header.data["maxWindowMessageCount"] = conv; + sections.push_back(header); for (int i = 0; i < serverCount; i++) { diff --git a/bouncer/window.cpp b/bouncer/window.cpp index 1f6aa4a..04689f5 100644 --- a/bouncer/window.cpp +++ b/bouncer/window.cpp @@ -31,6 +31,8 @@ void Window::notifyWindowRename() { } void Window::pushMessage(const char *str, int priority) { + if (messages.size() >= core->maxWindowMessageCount) + messages.pop_front(); messages.push_back(str); bool createdPacket = false; |