aboutsummaryrefslogtreecommitdiff
path: root/client/src
diff options
context:
space:
mode:
authorauth <[email protected]>2020-07-14 16:16:02 +0200
committerauth <[email protected]>2020-07-14 16:16:02 +0200
commit275010eaa0a46012fec547efdd76256b25e47f54 (patch)
tree00d9e0a19424c3e3d81e2ed74d7986da987123d1 /client/src
parentForum integration. (diff)
downloadloader-275010eaa0a46012fec547efdd76256b25e47f54.tar.xz
loader-275010eaa0a46012fec547efdd76256b25e47f54.zip
Client login handling on server.
More error handling for forum responses.
Diffstat (limited to 'client/src')
-rw-r--r--client/src/client/client.h3
-rw-r--r--client/src/client/packet.h2
-rw-r--r--client/src/main.cpp38
3 files changed, 38 insertions, 5 deletions
diff --git a/client/src/client/client.h b/client/src/client/client.h
index 8bf3743..4239651 100644
--- a/client/src/client/client.h
+++ b/client/src/client/client.h
@@ -19,7 +19,8 @@ enum login_result {
login_fail = 15494,
hwid_mismatch = 11006,
login_success = 61539,
- banned = 28618
+ banned = 28618,
+ server_error = 98679
};
class client {
diff --git a/client/src/client/packet.h b/client/src/client/packet.h
index db24ac2..aba5783 100644
--- a/client/src/client/packet.h
+++ b/client/src/client/packet.h
@@ -9,7 +9,7 @@ constexpr size_t message_len = 512;
enum packet_type { write = 0, read };
-enum packet_id { message = 0, hwid, session, login_req, login_resp, process_list };
+enum packet_id { message = 0, hwid, session, login_req, login_resp, process_list, ban };
struct packet_t {
std::string message;
diff --git a/client/src/main.cpp b/client/src/main.cpp
index 83804dd..cef083f 100644
--- a/client/src/main.cpp
+++ b/client/src/main.cpp
@@ -44,8 +44,9 @@ int main(int argc, char* argv[]) {
client.write(tcp::packet_t("hwid", tcp::packet_type::write,
client.session_id, tcp::packet_id::hwid));
if (ret <= 0) {
- io::logger->error("failed to send hwid.");
+ io::logger->error("internal error.");
client.shutdown();
+ return;
}
}
@@ -53,12 +54,43 @@ int main(int argc, char* argv[]) {
auto j = nlohmann::json::parse(message);
auto res = j["result"].get<int>();
+
if (res == tcp::login_result::banned) {
io::logger->error("your account is banned.");
client.shutdown();
+ return;
+ }
+
+ if (res == tcp::login_result::login_fail) {
+ io::logger->error("please check your username or password.");
+ client.shutdown();
+ return;
+ }
+
+ if (res == tcp::login_result::hwid_mismatch) {
+ io::logger->error("please reset your hwid on the forums.");
+ client.shutdown();
+ return;
}
- io::logger->info("res {}", res);
+ if (res == tcp::login_result::server_error) {
+ io::logger->error("internal server error, please contact a developer.");
+ client.shutdown();
+ return;
+ }
+
+ if (res == tcp::login_result::login_success) {
+ client.state = tcp::client_state::waiting;
+
+ io::logger->info("logged in.");
+ }
+ }
+
+ if (id == tcp::packet_id::ban) {
+ io::logger->error(
+ "your computer is blacklisted, please contact a developer.");
+ client.shutdown();
+ return;
}
io::logger->info("{}:{}->{} {}", packet.seq, packet.session_id, message,
@@ -79,7 +111,7 @@ int main(int argc, char* argv[]) {
tcp::packet_id::login_req));
if (ret <= 0) {
- return 0;
+ break;
}
}
}