aboutsummaryrefslogtreecommitdiff
path: root/server/src/client/blacklist.h
diff options
context:
space:
mode:
authorauth <[email protected]>2020-07-13 23:05:20 +0200
committerauth <[email protected]>2020-07-13 23:05:20 +0200
commite177151308cbdfb2b96119389cf5bf7c2659b94e (patch)
tree7e5737aca17322bf3d39ee5643b3ae2d5deea8f3 /server/src/client/blacklist.h
parentSmall changes. (diff)
downloadloader-e177151308cbdfb2b96119389cf5bf7c2659b94e.tar.xz
loader-e177151308cbdfb2b96119389cf5bf7c2659b94e.zip
Forum integration.
Added separate packet ids for login request/response. Added login responses. Small code changes.
Diffstat (limited to 'server/src/client/blacklist.h')
-rw-r--r--server/src/client/blacklist.h100
1 files changed, 47 insertions, 53 deletions
diff --git a/server/src/client/blacklist.h b/server/src/client/blacklist.h
index 397dc6c..70f5c7a 100644
--- a/server/src/client/blacklist.h
+++ b/server/src/client/blacklist.h
@@ -1,60 +1,54 @@
#pragma once
-namespace tcp {
-
struct blacklist_data {
- std::string ip;
- std::string hwid;
+ std::string ip;
+ std::string hwid;
};
class blacklist {
-
-nlohmann::json m_data;
-std::string m_name;
-
-public:
- void init(const std::string_view file = "blacklist") {
- m_name = file;
-
- std::string data;
- if(!io::read_file(file, data))
- return;
-
- if(!nlohmann::json::accept(data)) {
- io::logger->error("blacklist file isnt valid json.");
- return;
- }
-
- m_data = nlohmann::json::parse(data);
- }
-
- void add(const blacklist_data &data) {
- m_data["ips"].emplace_back(data.ip);
- m_data["hwids"].emplace_back(data.hwid);
-
- save();
- }
-
- void save() {
- std::ofstream o(m_name, std::ios::trunc);
- o << std::setw(4) << m_data;
- o.close();
- }
-
- bool find(const std::string &key) {
- for(auto &item : m_data["ips"]) {
- if(item.get<std::string>() == key) {
- return true;
- }
- }
-
- for(auto &item : m_data["hwids"]) {
- if(item.get<std::string>() == key) {
- return true;
- }
- }
- return false;
- }
+ nlohmann::json m_data;
+ std::string m_name;
+
+ public:
+ void init(const std::string_view file = "blacklist") {
+ m_name = file;
+
+ std::string data;
+ if (!io::read_file(file, data)) return;
+
+ if (!nlohmann::json::accept(data)) {
+ io::logger->error("blacklist file isnt valid json.");
+ return;
+ }
+
+ m_data = nlohmann::json::parse(data);
+ }
+
+ void add(const blacklist_data &data) {
+ m_data["ips"].emplace_back(data.ip);
+ m_data["hwids"].emplace_back(data.hwid);
+
+ save();
+ }
+
+ void save() {
+ std::ofstream o(m_name, std::ios::trunc);
+ o << std::setw(4) << m_data;
+ o.close();
+ }
+
+ bool find(const std::string &key) {
+ for (auto &item : m_data["ips"]) {
+ if (item.get<std::string>() == key) {
+ return true;
+ }
+ }
+
+ for (auto &item : m_data["hwids"]) {
+ if (item.get<std::string>() == key) {
+ return true;
+ }
+ }
+ return false;
+ }
};
-
-}; \ No newline at end of file