From 7ccb819f867493f8ec202ea3b39c94c198c64584 Mon Sep 17 00:00:00 2001 From: JustSomePwner Date: Thu, 30 Aug 2018 14:01:54 +0200 Subject: first --- server/client.hpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 server/client.hpp (limited to 'server/client.hpp') 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 +#pragma comment(lib, "ws2_32.lib") +#else +#include +#include +#include +#include +#include +#include +#endif + +#include +#include +#include +#include + +#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 -- cgit v1.2.3