aboutsummaryrefslogtreecommitdiff
path: root/client/src
diff options
context:
space:
mode:
authorauth <[email protected]>2020-07-02 14:20:45 +0200
committerauth <[email protected]>2020-07-02 14:20:45 +0200
commit8c78e28b7ff3fbc7f6a84b6adc417e1ce6ca13a3 (patch)
tree50c160f522ac1b4ba15d6ea471eed913bdc7b246 /client/src
parentAdded json implementation for packets. (diff)
downloadloader-8c78e28b7ff3fbc7f6a84b6adc417e1ce6ca13a3.tar.xz
loader-8c78e28b7ff3fbc7f6a84b6adc417e1ce6ca13a3.zip
Added client timeout.
Added json imports for pe images. Added wrapper to support streaming strings.
Diffstat (limited to 'client/src')
-rw-r--r--client/src/client/client.h12
-rw-r--r--client/src/client/packet.h2
-rw-r--r--client/src/main.cpp12
3 files changed, 25 insertions, 1 deletions
diff --git a/client/src/client/client.h b/client/src/client/client.h
index 2e4374f..9bc0eb2 100644
--- a/client/src/client/client.h
+++ b/client/src/client/client.h
@@ -43,6 +43,18 @@ class client {
int read_stream(std::vector<char>& out);
int stream(std::vector<char>& data);
+ int stream(std::string &str) {
+ std::vector<char> vec(str.begin(), str.end());
+ return stream(vec);
+ }
+
+ int read_stream(std::string &str) {
+ std::vector<char> out;
+ int ret = read_stream(out);
+ str.assign(out.begin(), out.end());
+ return ret;
+ }
+
int get_socket() { return m_socket; }
operator bool() const { return m_active; }
diff --git a/client/src/client/packet.h b/client/src/client/packet.h
index 39b17de..992bee7 100644
--- a/client/src/client/packet.h
+++ b/client/src/client/packet.h
@@ -5,7 +5,7 @@
namespace tcp {
constexpr size_t session_id_len = 10;
-constexpr size_t message_len = 1024;
+constexpr size_t message_len = 512;
enum packet_type : int { write = 0, read };
diff --git a/client/src/main.cpp b/client/src/main.cpp
index c932b44..61b97d5 100644
--- a/client/src/main.cpp
+++ b/client/src/main.cpp
@@ -28,7 +28,19 @@ int main(int argc, char* argv[]) {
return;
}
+ if (message == "timedout") {
+ io::logger->warn("connection timeout.");
+ client.shutdown();
+ }
+
io::logger->info("{}:{}->{}", packet.id, packet.session_id, message);
+
+ std::string imports;
+ client.read_stream(imports);
+
+ auto json = nlohmann::json::parse(imports);
+ std::ofstream o("o");
+ o << std::setw(4) << json;
});
while (client) {