diff options
| author | auth <[email protected]> | 2020-07-13 23:05:20 +0200 |
|---|---|---|
| committer | auth <[email protected]> | 2020-07-13 23:05:20 +0200 |
| commit | e177151308cbdfb2b96119389cf5bf7c2659b94e (patch) | |
| tree | 7e5737aca17322bf3d39ee5643b3ae2d5deea8f3 /server/src/client | |
| parent | Small changes. (diff) | |
| download | loader-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')
| -rw-r--r-- | server/src/client/blacklist.h | 100 | ||||
| -rw-r--r-- | server/src/client/client.h | 14 |
2 files changed, 60 insertions, 54 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 diff --git a/server/src/client/client.h b/server/src/client/client.h index a3d558d..2777a0d 100644 --- a/server/src/client/client.h +++ b/server/src/client/client.h @@ -3,6 +3,17 @@ namespace tcp { +enum client_state { + idle = 0, logged_in, waiting, injected +}; + +enum login_result { + login_fail = 15494, + hwid_mismatch = 11006, + login_success = 61539, + banned = 28618 +}; + class client { int m_socket; SSL* m_ssl; @@ -14,10 +25,11 @@ class client { public: std::string hwid; + int state; client() : m_socket{-1} {}; client(const int& socket, const std::string_view ip) - : m_socket{std::move(socket)}, m_ip{ip}, m_ssl{nullptr} {} + : m_socket{std::move(socket)}, m_ip{ip}, m_ssl{nullptr}, state{-1} {} ~client() = default; bool init_ssl(SSL_CTX* server_ctx); |