summaryrefslogtreecommitdiffstats
path: root/Tools/ProtoProxy
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/ProtoProxy')
-rw-r--r--Tools/ProtoProxy/.gitignore3
-rw-r--r--Tools/ProtoProxy/CMakeLists.txt153
-rw-r--r--Tools/ProtoProxy/Connection.cpp63
-rw-r--r--Tools/ProtoProxy/Globals.h20
-rw-r--r--Tools/ProtoProxy/ProtoProxy.sln29
-rw-r--r--Tools/ProtoProxy/ProtoProxy.vcproj279
-rw-r--r--Tools/ProtoProxy/Server.cpp23
7 files changed, 221 insertions, 349 deletions
diff --git a/Tools/ProtoProxy/.gitignore b/Tools/ProtoProxy/.gitignore
index 2a38341e5..8def77d0b 100644
--- a/Tools/ProtoProxy/.gitignore
+++ b/Tools/ProtoProxy/.gitignore
@@ -3,3 +3,6 @@ Release
Logs/
*.log
*.nbt
+*.sln
+*.vcproj
+*.vcxproj
diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt
new file mode 100644
index 000000000..f8a01a134
--- /dev/null
+++ b/Tools/ProtoProxy/CMakeLists.txt
@@ -0,0 +1,153 @@
+
+cmake_minimum_required (VERSION 2.6)
+
+project (ProtoProxy)
+
+
+
+macro(add_flags_cxx FLAGS)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAGS}")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAGS}")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${FLAGS}")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${FLAGS}")
+endmacro()
+
+
+
+
+# Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
+if (NOT MSVC)
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
+endif()
+
+
+
+if(MSVC)
+ # Make build use multiple threads under MSVC:
+ add_flags_cxx("/MP")
+
+ # Make release builds use link-time code generation:
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL")
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
+ set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
+elseif(APPLE)
+ #on os x clang adds pthread for us but we need to add it for gcc
+ if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ add_flags_cxx("-pthread")
+ endif()
+else()
+ # Let gcc / clang know that we're compiling a multi-threaded app:
+ add_flags_cxx("-pthread")
+endif()
+
+
+
+
+# Use static CRT in MSVC builds:
+if (MSVC)
+ string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+ string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+ string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+ string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+endif()
+
+
+
+
+# Set include paths to the used libraries:
+include_directories("../../lib")
+include_directories("../../src")
+
+
+function(flatten_files arg1)
+ set(res "")
+ foreach(f ${${arg1}})
+ get_filename_component(f ${f} ABSOLUTE)
+ list(APPEND res ${f})
+ endforeach()
+ set(${arg1} "${res}" PARENT_SCOPE)
+endfunction()
+
+
+# Include the libraries:
+file(GLOB CRYPTOPP_SRC "../../lib/cryptopp/*.cpp")
+file(GLOB CRYPTOPP_HDR "../../lib/cryptopp/*.h")
+flatten_files(CRYPTOPP_SRC)
+flatten_files(CRYPTOPP_HDR)
+source_group("CryptoPP" FILES ${CRYPTOPP_SRC} ${CRYPTOPP_HDR})
+
+file(GLOB ZLIB_SRC "../../lib/zlib/*.c")
+file(GLOB ZLIB_HDR "../../lib/zlib/*.h")
+flatten_files(ZLIB_SRC)
+flatten_files(ZLIB_HDR)
+source_group("ZLib" FILES ${ZLIB_SRC} ${ZLIB_HDR})
+
+
+# Include the shared files:
+set(SHARED_SRC
+ ../../src/ByteBuffer.cpp
+ ../../src/StringUtils.cpp
+ ../../src/Log.cpp
+ ../../src/MCLogger.cpp
+)
+set(SHARED_HDR
+ ../../src/ByteBuffer.h
+ ../../src/StringUtils.h
+ ../../src/Log.h
+ ../../src/MCLogger.h
+)
+set(SHARED_OSS_SRC
+ ../../src/OSSupport/CriticalSection.cpp
+ ../../src/OSSupport/File.cpp
+ ../../src/OSSupport/IsThread.cpp
+ ../../src/OSSupport/Timer.cpp
+)
+set(SHARED_OSS_HDR
+ ../../src/OSSupport/CriticalSection.h
+ ../../src/OSSupport/File.h
+ ../../src/OSSupport/IsThread.h
+ ../../src/OSSupport/Timer.h
+)
+flatten_files(SHARED_SRC)
+flatten_files(SHARED_HDR)
+flatten_files(SHARED_OSS_SRC)
+flatten_files(SHARED_OSS_HDR)
+source_group("Shared" FILES ${SHARED_SRC} ${SHARED_HDR})
+source_group("Shared\\OSSupport" FILES ${SHARED_OSS_SRC} ${SHARED_OSS_HDR})
+
+
+
+# Include the main source files:
+set(SOURCES
+ Connection.cpp
+ Globals.cpp
+ ProtoProxy.cpp
+ Server.cpp
+)
+set(HEADERS
+ Connection.h
+ Globals.h
+ Server.h
+)
+source_group("" FILES ${SOURCES} ${HEADERS})
+
+add_executable(ProtoProxy
+ ${SOURCES}
+ ${HEADERS}
+ ${SHARED_SRC}
+ ${SHARED_HDR}
+ ${SHARED_OSS_SRC}
+ ${SHARED_OSS_HDR}
+ ${CRYPTOPP_SRC}
+ ${CRYPTOPP_HDR}
+ ${ZLIB_SRC}
+ ${ZLIB_HDR}
+)
+
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index 10f2b4073..34da9b700 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -155,6 +155,32 @@ AString PrintableAbsIntTriplet(int a_X, int a_Y, int a_Z, double a_Divisor = 32)
+struct sCoords
+{
+ int x, y, z;
+
+ sCoords(int a_X, int a_Y, int a_Z) : x(a_X), y(a_Y), z(a_Z) {}
+} ;
+
+
+
+
+
+struct sChunkMeta
+{
+ int m_ChunkX, m_ChunkZ;
+ short m_PrimaryBitmap;
+ short m_AddBitmap;
+ sChunkMeta(int a_ChunkX, int a_ChunkZ, short a_PrimaryBitmap, short a_AddBitmap) :
+ m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ), m_PrimaryBitmap(a_PrimaryBitmap), m_AddBitmap(a_AddBitmap)
+ {
+ }
+} ;
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cConnection:
@@ -220,7 +246,7 @@ void cConnection::Run(void)
int res = select(2, &ReadFDs, NULL, NULL, NULL);
if (res <= 0)
{
- printf("select() failed: %d; aborting client", WSAGetLastError());
+ printf("select() failed: %d; aborting client", SocketError);
break;
}
if (FD_ISSET(m_ServerSocket, &ReadFDs))
@@ -319,7 +345,7 @@ bool cConnection::ConnectToServer(void)
localhost.sin_addr.s_addr = htonl(0x7f000001); // localhost
if (connect(m_ServerSocket, (sockaddr *)&localhost, sizeof(localhost)) != 0)
{
- printf("connection to server failed: %d\n", WSAGetLastError());
+ printf("connection to server failed: %d\n", SocketError);
return false;
}
Log("Connected to SERVER");
@@ -336,7 +362,7 @@ bool cConnection::RelayFromServer(void)
int res = recv(m_ServerSocket, Buffer, sizeof(Buffer), 0);
if (res <= 0)
{
- Log("Server closed the socket: %d; %d; aborting connection", res, WSAGetLastError());
+ Log("Server closed the socket: %d; %d; aborting connection", res, SocketError);
return false;
}
@@ -376,7 +402,7 @@ bool cConnection::RelayFromClient(void)
int res = recv(m_ClientSocket, Buffer, sizeof(Buffer), 0);
if (res <= 0)
{
- Log("Client closed the socket: %d; %d; aborting connection", res, WSAGetLastError());
+ Log("Client closed the socket: %d; %d; aborting connection", res, SocketError);
return false;
}
@@ -424,7 +450,7 @@ bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, int a_Size, con
int res = send(a_Socket, a_Data, a_Size, 0);
if (res <= 0)
{
- Log("%s closed the socket: %d, %d; aborting connection", a_Peer, res, WSAGetLastError());
+ Log("%s closed the socket: %d, %d; aborting connection", a_Peer, res, SocketError);
return false;
}
return true;
@@ -1249,7 +1275,7 @@ bool cConnection::HandleServerLoginDisconnect(void)
HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Reason);
Log("Received a login-disconnect packet from the server:");
Log(" Reason = \"%s\"", Reason.c_str());
- COPY_TO_SERVER();
+ COPY_TO_CLIENT();
return true;
}
@@ -1664,12 +1690,6 @@ bool cConnection::HandleServerExplosion(void)
HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, PosZ);
HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Force);
HANDLE_SERVER_PACKET_READ(ReadBEInt, int, NumRecords);
- struct sCoords
- {
- int x, y, z;
-
- sCoords(int a_X, int a_Y, int a_Z) : x(a_X), y(a_Y), z(a_Z) {}
- } ;
std::vector<sCoords> Records;
Records.reserve(NumRecords);
int PosXI = (int)PosX, PosYI = (int)PosY, PosZI = (int)PosZ;
@@ -1864,16 +1884,6 @@ bool cConnection::HandleServerMapChunkBulk(void)
// Read individual chunk metas.
// Need to read them first and only then start logging (in case we don't have the full packet yet)
- struct sChunkMeta
- {
- int m_ChunkX, m_ChunkZ;
- short m_PrimaryBitmap;
- short m_AddBitmap;
- sChunkMeta(int a_ChunkX, int a_ChunkZ, short a_PrimaryBitmap, short a_AddBitmap) :
- m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ), m_PrimaryBitmap(a_PrimaryBitmap), m_AddBitmap(a_AddBitmap)
- {
- }
- } ;
typedef std::vector<sChunkMeta> sChunkMetas;
sChunkMetas ChunkMetas;
ChunkMetas.reserve(ChunkCount);
@@ -1903,7 +1913,6 @@ bool cConnection::HandleServerMapChunkBulk(void)
// TODO: Save the compressed data into a file for later analysis
COPY_TO_CLIENT();
- Sleep(50);
return true;
}
@@ -2390,12 +2399,12 @@ bool cConnection::HandleServerStatusResponse(void)
{
Response.assign(Response.substr(0, idx + sizeof(DescSearch) - 1) + "ProtoProxy: " + Response.substr(idx + sizeof(DescSearch) - 1));
}
- cByteBuffer Packet(1000);
+ cByteBuffer Packet(Response.size() + 50);
Packet.WriteVarInt(0); // Packet type - status response
Packet.WriteVarUTF8String(Response);
AString Pkt;
Packet.ReadAll(Pkt);
- cByteBuffer ToClient(1000);
+ cByteBuffer ToClient(Response.size() + 50);
ToClient.WriteVarUTF8String(Pkt);
CLIENTSEND(ToClient);
return true;
@@ -2853,8 +2862,8 @@ void cConnection::SendEncryptionKeyResponse(const AString & a_ServerPublicKey, c
int EncryptedLength = rsaEncryptor.FixedCiphertextLength();
ASSERT(EncryptedLength <= sizeof(EncryptedSecret));
rsaEncryptor.Encrypt(rng, SharedSecret, sizeof(SharedSecret), EncryptedSecret);
- m_ServerEncryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
- m_ServerDecryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
+ m_ServerEncryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16, true))(Name::FeedbackSize(), 1));
+ m_ServerDecryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16, true))(Name::FeedbackSize(), 1));
// Encrypt the nonce:
byte EncryptedNonce[128];
diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h
index 8424aca81..7415c9e62 100644
--- a/Tools/ProtoProxy/Globals.h
+++ b/Tools/ProtoProxy/Globals.h
@@ -95,6 +95,7 @@ typedef unsigned short UInt16;
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <winsock2.h>
+ #include <ws2tcpip.h>
// Windows SDK defines min and max macros, messing up with our std::min and std::max usage
#undef min
@@ -104,6 +105,8 @@ typedef unsigned short UInt16;
#ifdef GetFreeSpace
#undef GetFreeSpace
#endif // GetFreeSpace
+
+ #define SocketError WSAGetLastError()
#else
#include <sys/types.h>
#include <sys/stat.h> // for mkdir
@@ -116,6 +119,7 @@ typedef unsigned short UInt16;
#include <dirent.h>
#include <errno.h>
#include <iostream>
+ #include <unistd.h>
#include <cstdio>
#include <cstring>
@@ -123,6 +127,14 @@ typedef unsigned short UInt16;
#include <semaphore.h>
#include <errno.h>
#include <fcntl.h>
+
+ typedef int SOCKET;
+ enum
+ {
+ INVALID_SOCKET = -1,
+ };
+ #define closesocket close
+ #define SocketError errno
#if !defined(ANDROID_NDK)
#include <tr1/memory>
#endif
@@ -211,10 +223,10 @@ public:
-#include "CryptoPP/randpool.h"
-#include "CryptoPP/aes.h"
-#include "CryptoPP/rsa.h"
-#include "CryptoPP/modes.h"
+#include "cryptopp/randpool.h"
+#include "cryptopp/aes.h"
+#include "cryptopp/rsa.h"
+#include "cryptopp/modes.h"
using namespace CryptoPP;
diff --git a/Tools/ProtoProxy/ProtoProxy.sln b/Tools/ProtoProxy/ProtoProxy.sln
deleted file mode 100644
index 1c8c1a2a7..000000000
--- a/Tools/ProtoProxy/ProtoProxy.sln
+++ /dev/null
@@ -1,29 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProtoProxy", "ProtoProxy.vcproj", "{EFEC8F76-1397-49A4-885B-314CB4244231}"
- ProjectSection(ProjectDependencies) = postProject
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CryptoPP", "..\..\VC2008\CryptoPP.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Debug|Win32.ActiveCfg = Debug|Win32
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Debug|Win32.Build.0 = Debug|Win32
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Release|Win32.ActiveCfg = Release|Win32
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Release|Win32.Build.0 = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Tools/ProtoProxy/ProtoProxy.vcproj b/Tools/ProtoProxy/ProtoProxy.vcproj
deleted file mode 100644
index 0b3c77bc5..000000000
--- a/Tools/ProtoProxy/ProtoProxy.vcproj
+++ /dev/null
@@ -1,279 +0,0 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="ProtoProxy"
- ProjectGUID="{EFEC8F76-1397-49A4-885B-314CB4244231}"
- RootNamespace="ProtoProxy"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../lib;../../src"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../../lib;../../src"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hpp"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\Connection.cpp"
- >
- </File>
- <File
- RelativePath=".\Connection.h"
- >
- </File>
- <File
- RelativePath=".\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Globals.h"
- >
- </File>
- <File
- RelativePath=".\ProtoProxy.cpp"
- >
- </File>
- <File
- RelativePath=".\Server.cpp"
- >
- </File>
- <File
- RelativePath=".\Server.h"
- >
- </File>
- </Filter>
- <Filter
- Name="shared"
- >
- <File
- RelativePath="..\..\src\ByteBuffer.cpp"
- >
- </File>
- <File
- RelativePath="..\..\src\ByteBuffer.h"
- >
- </File>
- <File
- RelativePath="..\..\src\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\src\StringUtils.h"
- >
- </File>
- <Filter
- Name="OSSupport"
- >
- <File
- RelativePath="..\..\src\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\src\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\src\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\src\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\src\OSSupport\Timer.cpp"
- >
- </File>
- <File
- RelativePath="..\..\src\OSSupport\Timer.h"
- >
- </File>
- </Filter>
- </Filter>
- <File
- RelativePath=".\ProtoProxy.txt"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/Tools/ProtoProxy/Server.cpp b/Tools/ProtoProxy/Server.cpp
index 35732764c..71b5ecb94 100644
--- a/Tools/ProtoProxy/Server.cpp
+++ b/Tools/ProtoProxy/Server.cpp
@@ -22,13 +22,16 @@ cServer::cServer(void)
int cServer::Init(short a_ListenPort, short a_ConnectPort)
{
m_ConnectPort = a_ConnectPort;
- WSAData wsa;
- int res = WSAStartup(0x0202, &wsa);
- if (res != 0)
- {
- printf("Cannot initialize WinSock: %d\n", res);
- return res;
- }
+
+ #ifdef _WIN32
+ WSAData wsa;
+ int res = WSAStartup(0x0202, &wsa);
+ if (res != 0)
+ {
+ printf("Cannot initialize WinSock: %d\n", res);
+ return res;
+ }
+ #endif // _WIN32
printf("Generating protocol encryption keypair...\n");
time_t CurTime = time(NULL);
@@ -62,12 +65,12 @@ void cServer::Run(void)
while (true)
{
sockaddr_in Addr;
- ZeroMemory(&Addr, sizeof(Addr));
- int AddrSize = sizeof(Addr);
+ memset(&Addr, 0, sizeof(Addr));
+ socklen_t AddrSize = sizeof(Addr);
SOCKET client = accept(m_ListenSocket, (sockaddr *)&Addr, &AddrSize);
if (client == INVALID_SOCKET)
{
- printf("accept returned an error: %d; bailing out.\n", WSAGetLastError());
+ printf("accept returned an error: %d; bailing out.\n", SocketError);
return;
}
printf("Client connected, proxying...\n");