aboutsummaryrefslogtreecommitdiff
path: root/server/src/main.cpp
diff options
context:
space:
mode:
authorauth12 <[email protected]>2020-08-03 21:08:06 +0100
committerauth12 <[email protected]>2020-08-03 21:08:06 +0100
commitad8cf7c80590b96ad4e61f3f4eb397704a22ee4b (patch)
treef376bc6ce8b7ababd4bcc67bee748c6e1d672b0c /server/src/main.cpp
parentStarted security. (diff)
downloadloader-ad8cf7c80590b96ad4e61f3f4eb397704a22ee4b.tar.xz
loader-ad8cf7c80590b96ad4e61f3f4eb397704a22ee4b.zip
Added ui.
Diffstat (limited to 'server/src/main.cpp')
-rw-r--r--server/src/main.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/server/src/main.cpp b/server/src/main.cpp
index 80dbe62..4f531da 100644
--- a/server/src/main.cpp
+++ b/server/src/main.cpp
@@ -3,7 +3,7 @@
#include "util/commands.h"
#include "server/server.h"
-constexpr std::string_view version{"0.1.0"};
+constexpr std::string_view version{"0.1.1"};
int main(int argc, char* argv[]) {
io::init(true);
@@ -19,7 +19,7 @@ int main(int argc, char* argv[]) {
client_server.start();
uint16_t ver;
- for(int i = 0; i < version.size(); ++i) {
+ for (int i = 0; i < version.size(); ++i) {
if (i % 2) {
continue;
}
@@ -93,6 +93,8 @@ int main(int argc, char* argv[]) {
io::logger->info("got hwid from {} : {}", ip, client.hwid);
+ client.reset_security_time();
+
if (client_server.bl().find(client.hwid)) {
io::logger->warn("{} is hwid banned.", ip);
@@ -104,6 +106,10 @@ int main(int argc, char* argv[]) {
}
}
+ if (id == tcp::packet_id::security_report) {
+ client.reset_security_time();
+ }
+
if (id == tcp::packet_id::login_req) {
if (client.state != tcp::client_state::idle) {
return;
@@ -390,30 +396,35 @@ int main(int argc, char* argv[]) {
client_server().erase(it);
}
+ if (client.security_timeout()) {
+ io::logger->warn("{} failed to send security packet in time, dropping...",
+ client.get_ip());
+ }
+
io::logger->info("{} timed out.", client.get_ip());
});
-
commands cmds;
cmds.add("reload", [&]() {
- for(auto&[key, image] : client_server.images) {
+ for (auto& [key, image] : client_server.images) {
image.reload();
}
- for(auto&[key, image] : client_server.images64) {
+ for (auto& [key, image] : client_server.images64) {
image.reload();
}
});
- std::thread t1{[&](tcp::server &srv) {
- while (srv) {
- std::string cmd;
- getline(std::cin, cmd);
- if(!cmds.parse_input(cmd)) {
- io::logger->warn("invalid command.");
- }
- };
- }, std::ref(client_server)};
+ std::thread t1{[&](tcp::server& srv) {
+ while (srv) {
+ std::string cmd;
+ getline(std::cin, cmd);
+ if (!cmds.parse_input(cmd)) {
+ io::logger->warn("invalid command.");
+ }
+ };
+ },
+ std::ref(client_server)};
t1.detach();
std::thread t{tcp::server::monitor, std::ref(client_server)};