diff options
author | Treeki <treeki@gmail.com> | 2014-02-15 10:01:21 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2014-02-15 10:01:21 +0100 |
commit | 878a0c157b772a7ed04d4cc395059087f964b823 (patch) | |
tree | 623ad18853c846b6498ebbc56eb436a792f32ad3 /bouncer | |
parent | 04cf34e30aa6541568660dfe9e77b2b2c0a9db88 (diff) | |
download | bounce4-878a0c157b772a7ed04d4cc395059087f964b823.tar.gz bounce4-878a0c157b772a7ed04d4cc395059087f964b823.zip |
implement rudimentary password authentication
Diffstat (limited to '')
-rw-r--r-- | bouncer/client.cpp | 6 | ||||
-rw-r--r-- | bouncer/core.h | 2 | ||||
-rw-r--r-- | bouncer/netcore.cpp | 11 |
3 files changed, 18 insertions, 1 deletions
diff --git a/bouncer/client.cpp b/bouncer/client.cpp index 79e97a2..ab133b6 100644 --- a/bouncer/client.cpp +++ b/bouncer/client.cpp @@ -150,10 +150,14 @@ void Client::handlePacket(Packet::Type type, char *data, int size) { uint32_t lastReceivedByClient = pkt.readU32(); + char pwBuf[512] = ""; + pkt.readStr(pwBuf, sizeof(pwBuf)); + if (strcmp(pwBuf, netCore->bouncerPassword.c_str()) != 0) + error = 3; + if (!pkt.readRemains(SESSION_KEY_SIZE)) error = 2; - // Authentication goes here at some point, too if (error != 0) { diff --git a/bouncer/core.h b/bouncer/core.h index 28db1e8..a8f5d9b 100644 --- a/bouncer/core.h +++ b/bouncer/core.h @@ -396,6 +396,8 @@ public: bool quitFlag; + std::string bouncerPassword; + int execute(); Client *findClientWithSessionKey(uint8_t *key) const; diff --git a/bouncer/netcore.cpp b/bouncer/netcore.cpp index f8c484e..98f13a1 100644 --- a/bouncer/netcore.cpp +++ b/bouncer/netcore.cpp @@ -329,6 +329,10 @@ void NetCore::loadConfig() { auto sections = INI::load("config.ini"); for (auto §ion : sections) { + if (section.title == "Header") { + bouncerPassword = section.data["password"]; + } + if (section.title == "Server" && serverCount < SERVER_LIMIT) { Server *s = constructServer(section.data["type"].c_str()); if (s) { @@ -342,6 +346,13 @@ void NetCore::loadConfig() { void NetCore::saveConfig() { std::list<INI::Section> sections; + INI::Section header; + header.title = "Header"; + + header.data["password"] = bouncerPassword; + + sections.push_back(header); + for (int i = 0; i < serverCount; i++) { INI::Section section; section.title = "Server"; |