diff options
| author | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
|---|---|---|
| committer | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
| commit | 3d412a4b30a9f7c7f51ea6562e694315948bd3da (patch) | |
| tree | 26d67dfd1f3e5fd12903ad13e85d0cb8bcf8f21c /server | |
| parent | e4729e4393d90271a3814c7a79950a660c48325a (diff) | |
cleaned up
in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever.
i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64
Diffstat (limited to 'server')
| -rw-r--r-- | server/client.cpp | 201 | ||||
| -rw-r--r-- | server/client.hpp | 67 | ||||
| -rw-r--r-- | server/message.hpp | 8 | ||||
| -rw-r--r-- | server/server.cpp | 48 | ||||
| -rw-r--r-- | server/server.hpp | 34 | ||||
| -rw-r--r-- | server/server.vcxproj | 234 | ||||
| -rw-r--r-- | server/server.vcxproj.filters | 42 | ||||
| -rw-r--r-- | server/server_windows.cpp | 40 | ||||
| -rw-r--r-- | server/util.hpp | 25 |
9 files changed, 0 insertions, 699 deletions
diff --git a/server/client.cpp b/server/client.cpp deleted file mode 100644 index 22aa053..0000000 --- a/server/client.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "client.hpp" -#include "server.hpp" - -/* -std::vector< byte > server::c_client::receive_message( ) { - std::vector< uint8_t > ret; - char buffer[ BUFFER_SIZE ]{ }; - int received = 0; - - while( true ) { - received = recv( m_socket, buffer, BUFFER_SIZE, 0 ); - if( received < 0 ) - break; - - for( int i{ }; i < received; ++i ) - ret.push_back( buffer[ i ] ); - - if( received < BUFFER_SIZE ) - break; - } - - if( ret.size( ) ) { - decode_buffer( ret.data( ), ret.size( ) ); - ret.push_back( 0 ); - ret.erase( ret.begin( ) ); - } - - return ret; -} -*/ - -void server::c_client::kill( ) { - closesocket( m_socket ); - printf( "%s disconnected\n", get_ip( ) ); -} - -std::string server::c_client::get_msg( ) { - std::string ret{ }; - char buffer[ BUFFER_SIZE ]{ }; - int received = 0; - - while ( true ) { - received = recv( m_socket, buffer, BUFFER_SIZE, 0 ); - if ( received < 0 ) - break; - - for ( int i{ }; i < received; ++i ) - ret.push_back( buffer[ i ] ); - - if ( received < BUFFER_SIZE ) - break; - } - - if ( ret.size( ) ) { - decode_buffer( ( uint8_t* )ret.data( ), ret.size( ) ); - // ret.push_back( 0 ); somehow broke things :/ - ret.erase( ret.begin( ) ); - } - - return ret; -} - -bool server::c_client::send_msg( byte* msg, size_t length ) { - auto buffer = std::make_unique< uint8_t[ ] >( length + 1 ); - auto key = util::random_number( 0, 255 ) & 0xff; - - buffer[ 0 ] = key; - memcpy( buffer.get( ) + 1, - msg, - length ); - - for( size_t i = 1; i <= length; ++i ) { - buffer[ i ] ^= key; - } - - int result = send( m_socket, ( char* )buffer.get( ), length + 1, 0 ); - if( result == -1 ) { -#if WIN - printf( "error sending message to %s: %d\n", - get_ip( ), WSAGetLastError( ) ); -#else - printf( "error sending message to %s\n", - get_ip( ) ); -#endif - return false; - } - - return true; -} - -bool server::c_client::send_msg( const char* msg ) { - auto length = strlen( msg ); - auto buffer = std::make_unique< uint8_t[ ] >( length + 1 ); - auto key = util::random_number( 0, 255 ) & 0xff; - - memset( buffer.get( ), 0, length+1 ); - - buffer[ 0 ] = key; - memcpy( buffer.get( ) + 1, - msg, - length ); - - for ( size_t i = 1; i <= length; ++i ) { - buffer[ i ] ^= key; - } - - int result = send( m_socket, ( char* )buffer.get( ), length + 1, 0 ); - if ( result == -1 ) { -#if WIN - printf( "error sending message to %s: %d\n", - get_ip( ), WSAGetLastError( ) ); -#else - printf( "error sending message to %s\n", - get_ip( ) ); -#endif - return false; - } - - return true; -} - -bool server::c_client::handle( ) { - /* - ALL TEST CODE BELOW. - */ - auto hello_msg = get_msg( ); - printf( "%s\n", hello_msg.c_str( ) ); - - if ( hello_msg != "hello" ) - return false; - - auto username = get_msg( ); - if ( username != "friendly" ) - return false; - - printf( "correct username\n" ); - send_msg( "correct username" ); - - auto password = get_msg( ); - if ( password != "nigger" ) - return false; - - printf( "correct password\n" ); - send_msg( "correct password" ); - - const char* games_list = -R"(games: -1: CSGO -2: CSGO (test) -3: Garry's Mod -)"; - - send_msg( games_list ); - - auto game_id = get_msg( ); - - if ( game_id== "1" ) { - printf( "csgo\n" ); - send_msg( "csgo.exe" ); - } - else if ( game_id == "2" ) { - printf( "csgo test\n" ); - send_msg( "csgo.exe" ); - } - else if ( game_id == "3" ) { - printf( "gmod\n" ); - send_msg( "hl2.exe" ); - } - else { - printf( "invalid\n" ); - return false; - } - - auto found = get_msg( ); - if ( found != "found" ) - return false; - - printf( "process found\n" ); - - if ( game_id == "3" ) { - // test. make sure the file is in ur directory - auto file = std::ifstream( "gmod.dll", std::ifstream::binary ); - if ( file.is_open( ) ) { - file.seekg( 0, file.end ); - - auto size = ( int )file.tellg( );
- auto buffer = std::make_unique< char[ ] >( size );
-
- memset( buffer.get( ), 0, size );
-
- file.seekg( 0, file.beg );
- file.read( buffer.get( ), size );
- - send_msg( ( byte* )buffer.get( ), size ); - - file.close( ); - } - } - - return true; -} diff --git a/server/client.hpp b/server/client.hpp deleted file mode 100644 index c59e116..0000000 --- a/server/client.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once
-
-#ifdef WIN
-#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 <memory>
-#include <thread>
-
-
-#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( ) {
- kill( );
- }
-
-
- 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 );
- }
-
- void kill( );
-
- //std::vector< byte > receive_message( );
- std::string get_msg( );
- bool send_msg( byte* msg, size_t length );
- bool send_msg( const char* );
-
- //handles messages, hwid etc
- void handle_buffer( byte* msg );
- virtual bool handle( );
- };
-}
\ No newline at end of file diff --git a/server/message.hpp b/server/message.hpp deleted file mode 100644 index bf67389..0000000 --- a/server/message.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once
-
-enum MessageType_t {
- MSG_HELLO = 'h',
- MSG_READY = 'r',
- MSG_BAN = 'q',
- MSG_IMPORT = 'i'
-};
\ No newline at end of file diff --git a/server/server.cpp b/server/server.cpp deleted file mode 100644 index 010ec84..0000000 --- a/server/server.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "server.hpp"
-
-int server::c_server::init( ) {
-#if WIN
- if( WSAStartup( MAKEWORD( 2, 2 ), &m_sock_data ) ) // windows
- return 1;
-#endif
-
- m_socket = socket( AF_INET, SOCK_STREAM, 0 );
- if( m_socket == INVALID_SOCKET )
- return 2;
-
- sockaddr_in server_address{ };
- server_address.sin_addr.s_addr = INADDR_ANY;
- server_address.sin_port = htons( PORT_NUM );
- server_address.sin_family = AF_INET;
-
- auto result = ::bind( m_socket, ( sockaddr* )( &server_address ), sizeof( server_address ) );
- return result != -1 ? 0 : 3;
-}
-
-void server::c_server::listen( ) {
- ::listen( m_socket, 5 );
-
- sockaddr_in client_address{ };
-
- // not needed, this is set in accept, values are input.
- // client_address.sin_port = htons( PORT_NUM );
- int len = sizeof( client_address );
-
- SOCKET result = accept( m_socket, ( sockaddr* )( &client_address ), &len );
- if( result == INVALID_SOCKET ) {
- printf( "socket error accepting a connection\n" );
- return;
- }
-
- printf( "incoming connection from: %s\n", inet_ntoa( client_address.sin_addr ) );
-
- // connection established.
- auto client = std::make_shared< c_client >( result, client_address.sin_addr );
-
- // handshake.
- client->send_msg( "hello" );
-
- // surprised it even works with shared_ptr.
- std::thread thread{ &c_client::handle, client };
- thread.detach( );
-}
diff --git a/server/server.hpp b/server/server.hpp deleted file mode 100644 index 5ac8393..0000000 --- a/server/server.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once
-#include <vector>
-#include <memory>
-#include <mutex>
-#include <thread>
-
-#include "client.hpp"
-
-
-//since this will be running on our vps we dont need string encryption or protection for anything
-//which is cool, i guess
-
-namespace server
-{
- class c_server {
- // not sure if even needed.
- std::mutex m_mutex;
- private:
- WSADATA m_sock_data{ };
- SOCKET m_socket{ };
-
- public:
- ~c_server( ) {
- if ( m_socket )
- closesocket( m_socket );
- }
-
- int init( );
- void listen( );
- void client_loop( );
- };
-}
-
-extern server::c_server g_server;
\ No newline at end of file diff --git a/server/server.vcxproj b/server/server.vcxproj deleted file mode 100644 index 2135457..0000000 --- a/server/server.vcxproj +++ /dev/null @@ -1,234 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="pHit|Win32">
- <Configuration>pHit</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="pHit|x64">
- <Configuration>pHit</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <VCProjectVersion>15.0</VCProjectVersion>
- <ProjectGuid>{F0038E32-6DE8-47B7-BC86-8A2274B24406}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>server</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v141</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v141</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- <SpectreMitigation>false</SpectreMitigation>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='pHit|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v141</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v141</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v141</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- <SpectreMitigation>false</SpectreMitigation>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='pHit|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v141</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='pHit|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='pHit|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='pHit|Win32'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='pHit|x64'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='pHit|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- </ClCompile>
- <Link>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='pHit|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- </ClCompile>
- <Link>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="client.cpp" />
- <ClCompile Include="server.cpp" />
- <ClCompile Include="server_windows.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="client.hpp" />
- <ClInclude Include="message.hpp" />
- <ClInclude Include="server.hpp" />
- <ClInclude Include="util.hpp" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
\ No newline at end of file diff --git a/server/server.vcxproj.filters b/server/server.vcxproj.filters deleted file mode 100644 index d732209..0000000 --- a/server/server.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="server_windows.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="client.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="server.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="server.hpp">
- <Filter>Source Files</Filter>
- </ClInclude>
- <ClInclude Include="client.hpp">
- <Filter>Source Files</Filter>
- </ClInclude>
- <ClInclude Include="util.hpp">
- <Filter>Source Files</Filter>
- </ClInclude>
- <ClInclude Include="message.hpp">
- <Filter>Source Files</Filter>
- </ClInclude>
- </ItemGroup>
-</Project>
\ No newline at end of file diff --git a/server/server_windows.cpp b/server/server_windows.cpp deleted file mode 100644 index e372ee5..0000000 --- a/server/server_windows.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifdef WIN
-#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 <thread>
-#include "server.hpp"
-
-server::c_server g_server;
-
-int main( ) {
- std::thread listen_thread;
-
- int result = g_server.init( );
- if( !result ) {
- //listen_thread = std::thread( [ ]( ) { while( 1 ) { g_server.listen( ); } } );
- //listen_thread.detach( );
-
- while( true ) {
- g_server.listen( );
- //Sleep( 1 );
- }
- }
- else
- printf( "server init error (%d)\n", result );
-
- system( "pause" );
- return 0;
-}
diff --git a/server/util.hpp b/server/util.hpp deleted file mode 100644 index 1d408e0..0000000 --- a/server/util.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once
-#include <random>
-
-using ulong_t = unsigned long;
-
-namespace util
-{
- namespace {
- //make a random generator and seed it with a p random number
- static std::random_device rd;
- static std::mt19937 gen( rd( ) );
- }
-
- template < typename t >
- __forceinline t random_number( t min, t max ) {
- if constexpr( !std::is_integral_v< t > ) {
- std::uniform_real_distribution< t > dist( min, max );
- return dist( gen );
- }
- else {
- std::uniform_int_distribution< t > dist( min, max );
- return dist( gen );
- }
- }
-}
\ No newline at end of file |
