summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2014-02-15 17:41:51 +0100
committerTreeki <treeki@gmail.com>2014-02-15 17:41:51 +0100
commit05568c427eff856d3049d4a18a707f1b0b358bd2 (patch)
treebc85fa13989c0f3c497612ecde599aa0fff663ce
parentfce9ae6cb332bd2525d5e9e113f9e779ca214c64 (diff)
downloadbounce4-05568c427eff856d3049d4a18a707f1b0b358bd2.tar.gz
bounce4-05568c427eff856d3049d4a18a707f1b0b358bd2.zip
make session keepalive timeout configurable in config.ini
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);