diff options
| author | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
|---|---|---|
| committer | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
| commit | 7ccb819f867493f8ec202ea3b39c94c198c64584 (patch) | |
| tree | 94622e61af0ff359e3d6689cf274d74f60b2492a /server/client.hpp | |
| parent | 564d979b79e8a5aaa5014eba0ecd36c61575934f (diff) | |
first
Diffstat (limited to 'server/client.hpp')
| -rw-r--r-- | server/client.hpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/server/client.hpp b/server/client.hpp new file mode 100644 index 0000000..a3dcd78 --- /dev/null +++ b/server/client.hpp @@ -0,0 +1,58 @@ +#pragma once
+
+#ifdef WIN32
+#include <Windows.h>
+#pragma comment(lib, "ws2_32.lib")
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+#include <fstream>
+
+#include "util.hpp"
+
+constexpr auto PORT_NUM = 6969;
+constexpr auto BUFFER_SIZE = 255;
+
+namespace server
+{
+ class c_client {
+ SOCKET m_socket{ };
+ in_addr m_address{ };
+ ulong_t m_hwid{ };
+
+ public:
+ c_client( SOCKET socket, in_addr& address ) :
+ m_socket( socket ),
+ m_address( address ) { }
+
+ ~c_client( ) {
+ closesocket( m_socket );
+ }
+
+ void decode_buffer( uint8_t* buf, size_t length ) {
+ auto key = buf[ 0 ];
+ for( size_t i{ 1 }; i < length; ++i )
+ buf[ i ] ^= key;
+ }
+
+ auto get_ip( ) {
+ return inet_ntoa( m_address );
+ }
+
+ std::vector< byte > receive_message( );
+ bool send_message( byte* msg, size_t length );
+
+ //handles messages, hwid etc
+ void handle_buffer( byte* msg );
+ virtual bool handle( );
+ };
+}
\ No newline at end of file |
