summaryrefslogtreecommitdiff
path: root/bouncer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bouncer/client.cpp2
-rw-r--r--bouncer/core.h3
-rw-r--r--bouncer/netcore.cpp19
3 files changed, 18 insertions, 6 deletions
diff --git a/bouncer/client.cpp b/bouncer/client.cpp
index ab133b6..deb3e7f 100644
--- a/bouncer/client.cpp
+++ b/bouncer/client.cpp
@@ -87,7 +87,7 @@ void Client::close() {
SocketRWCommon::close();
if (authState == AS_AUTHED)
- deadTime = time(NULL) + SESSION_KEEPALIVE;
+ deadTime = time(NULL) + netCore->sessionKeepalive;
else
deadTime = time(NULL) - 1; // kill instantly
}
diff --git a/bouncer/core.h b/bouncer/core.h
index 4bb266e..40f5b98 100644
--- a/bouncer/core.h
+++ b/bouncer/core.h
@@ -32,8 +32,6 @@
#define CLIENT_LIMIT 100
#define SERVER_LIMIT 20
-#define SESSION_KEEPALIVE 30
-
#define SESSION_KEY_SIZE 16
#define PROTOCOL_VERSION 1
@@ -398,6 +396,7 @@ public:
std::string bouncerPassword;
int maxWindowMessageCount;
+ int sessionKeepalive;
int execute();
diff --git a/bouncer/netcore.cpp b/bouncer/netcore.cpp
index 7c2305e..bc87f8f 100644
--- a/bouncer/netcore.cpp
+++ b/bouncer/netcore.cpp
@@ -326,15 +326,25 @@ void NetCore::sendToClients(Packet::Type type, const Buffer &data) {
void NetCore::loadConfig() {
+ // Make default config
+ int v;
+
+ maxWindowMessageCount = 1000;
+ sessionKeepalive = 600;
+
auto sections = INI::load("config.ini");
for (auto &section : sections) {
if (section.title == "Header") {
bouncerPassword = section.data["password"];
- maxWindowMessageCount = atoi(section.data["maxBufferSize"].c_str());
- if (maxWindowMessageCount < 5 || maxWindowMessageCount > 2000)
- maxWindowMessageCount = 1000;
+ v = atoi(section.data["maxBufferSize"].c_str());
+ if (v >= 5 && v <= 2000)
+ maxWindowMessageCount = v;
+
+ v = atoi(section.data["sessionKeepalive"].c_str());
+ if (v >= 1 && v <= 3600)
+ sessionKeepalive = v;
}
if (section.title == "Server" && serverCount < SERVER_LIMIT) {
@@ -356,8 +366,11 @@ void NetCore::saveConfig() {
header.data["password"] = bouncerPassword;
char conv[50];
+
sprintf(conv, "%d", maxWindowMessageCount);
header.data["maxWindowMessageCount"] = conv;
+ sprintf(conv, "%d", sessionKeepalive);
+ header.data["sessionKeepalive"] = conv;
sections.push_back(header);