From fc8232f94305e1921f0ee513ddee445a3eea3288 Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 12 Sep 2017 20:24:50 +0800 Subject: [PATCH] [Master] Add ban/unban functions --- apps/master/MasterServer.cpp | 12 ++++++++++++ apps/master/MasterServer.hpp | 3 +++ 2 files changed, 15 insertions(+) diff --git a/apps/master/MasterServer.cpp b/apps/master/MasterServer.cpp index f52841317..c5b460dfe 100644 --- a/apps/master/MasterServer.cpp +++ b/apps/master/MasterServer.cpp @@ -234,3 +234,15 @@ MasterServer::ServerMap *MasterServer::GetServers() { return &servers; } + +void MasterServer::ban(const std::string &addr) +{ + banned.push_back(addr); +} + +void MasterServer::unban(const std::string &addr) +{ + auto it = find(banned.begin(), banned.end(), addr); + if (it != banned.end()) + banned.erase(it); +} diff --git a/apps/master/MasterServer.hpp b/apps/master/MasterServer.hpp index 47d214dbd..55bc4aa07 100644 --- a/apps/master/MasterServer.hpp +++ b/apps/master/MasterServer.hpp @@ -31,6 +31,9 @@ public: ServerMap* GetServers(); + void ban(const std::string &addr); + void unban(const std::string &addr); + private: void Thread();