diff options
| author | alpine <[email protected]> | 2020-06-26 14:06:25 +0200 |
|---|---|---|
| committer | alpine <[email protected]> | 2020-06-26 14:06:25 +0200 |
| commit | d89852b672d038ad07198dfeb6a5b1e89be84bb5 (patch) | |
| tree | e04e7cfcccf6b96af19678db79eba56acd57deed /client/src | |
| parent | Removed xor on streaming for now. (diff) | |
| download | loader-d89852b672d038ad07198dfeb6a5b1e89be84bb5.tar.xz loader-d89852b672d038ad07198dfeb6a5b1e89be84bb5.zip | |
Added server certificate verification on client.
Xor is now used only with messages.
Diffstat (limited to 'client/src')
| -rw-r--r-- | client/src/client/client.cpp | 4 | ||||
| -rw-r--r-- | client/src/client/client.h | 7 | ||||
| -rw-r--r-- | client/src/client/packet.h | 11 | ||||
| -rw-r--r-- | client/src/main.cpp | 2 |
4 files changed, 14 insertions, 10 deletions
diff --git a/client/src/client/client.cpp b/client/src/client/client.cpp index c82af1e..32a5b37 100644 --- a/client/src/client/client.cpp +++ b/client/src/client/client.cpp @@ -8,7 +8,7 @@ void tcp::client::start(const std::string_view server_ip, const uint16_t port) { int ret = SSL_CTX_load_verify_locations(m_ssl_ctx, "ssl/rootCA.crt", nullptr); if (ret != 1) { - io::logger->error("failed to load ca"); + io::logger->error("failed to load ca."); return; } SSL_CTX_set_verify(m_ssl_ctx, SSL_VERIFY_PEER, 0); @@ -39,7 +39,7 @@ void tcp::client::start(const std::string_view server_ip, const uint16_t port) { if (ret != 1) { ret = SSL_get_error(m_server_ssl, ret); - io::logger->error("ssl connection failed, code {}", ret); + io::logger->error("secure connection failed, code {}", ret); return; } diff --git a/client/src/client/client.h b/client/src/client/client.h index 1fc5191..2e4374f 100644 --- a/client/src/client/client.h +++ b/client/src/client/client.h @@ -1,15 +1,14 @@ #pragma once #include "../util/io.h" #include "../util/events.h" -#include "../util/enc.h" #include "packet.h" namespace tcp { struct version_t { - uint8_t major = 0; - uint8_t minor = 1; - uint8_t patch = 0; + uint8_t major; + uint8_t minor; + uint8_t patch; }; class client { diff --git a/client/src/client/packet.h b/client/src/client/packet.h index df44041..d6594b9 100644 --- a/client/src/client/packet.h +++ b/client/src/client/packet.h @@ -1,4 +1,5 @@ #pragma once +#include "../util/enc.h" namespace tcp { constexpr size_t session_id_len = 10; @@ -23,10 +24,13 @@ struct packet_t { return; } - session_id = msg.substr(0, session_id_len); + message = msg; + enc::decrypt_message(message); - action = msg[session_id_len]; - message = msg.substr(session_id_len); + session_id = message.substr(0, session_id_len); + + action = message[session_id_len]; + message = message.substr(session_id_len); } else { session_id = session; @@ -38,6 +42,7 @@ struct packet_t { session_id.clear(); return; } + enc::encrypt_message(message); } } diff --git a/client/src/main.cpp b/client/src/main.cpp index 410197f..220afd6 100644 --- a/client/src/main.cpp +++ b/client/src/main.cpp @@ -18,7 +18,7 @@ int main(int argc, char* argv[]) { // first packet is the session id and current version if (packet.id == 1) { client.session_id = packet.session_id; - tcp::version_t v; + tcp::version_t v{0, 1, 0}; auto version = fmt::format("{}.{}.{}", v.major, v.minor, v.patch); if(version != packet.message) { io::logger->error("please update your client"); |