summaryrefslogtreecommitdiffstats
path: root/Tools/ProtoProxy
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/ProtoProxy')
-rw-r--r--Tools/ProtoProxy/CMakeLists.txt7
-rw-r--r--Tools/ProtoProxy/Connection.cpp134
-rw-r--r--Tools/ProtoProxy/Connection.h10
-rw-r--r--Tools/ProtoProxy/Globals.cpp10
-rw-r--r--Tools/ProtoProxy/Globals.h177
-rw-r--r--Tools/ProtoProxy/Server.h16
6 files changed, 91 insertions, 263 deletions
diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt
index 90258f64f..48a095f19 100644
--- a/Tools/ProtoProxy/CMakeLists.txt
+++ b/Tools/ProtoProxy/CMakeLists.txt
@@ -15,8 +15,6 @@ function(flatten_files arg1)
set(${arg1} "${res}" PARENT_SCOPE)
endfunction()
-add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib)
-
# Include the shared files:
set(SHARED_SRC
../../src/ByteBuffer.cpp
@@ -33,6 +31,7 @@ set(SHARED_SRC
)
set(SHARED_HDR
../../src/ByteBuffer.h
+ ../../src/Globals.h
../../src/StringUtils.h
../../src/UUID.h
../../src/mbedTLS++/AesCfb128Decryptor.h
@@ -72,13 +71,11 @@ 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})
@@ -92,7 +89,7 @@ add_executable(ProtoProxy
${SHARED_OSS_HDR}
)
-target_link_libraries(ProtoProxy zlib mbedtls fmt::fmt Threads::Threads)
+target_link_libraries(ProtoProxy fmt::fmt libdeflate mbedtls Threads::Threads)
include(../../SetFlags.cmake)
set_exe_flags(ProtoProxy)
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index 4c72c7097..f9b732142 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -12,6 +12,8 @@
#ifdef _WIN32
#include <direct.h> // For _mkdir()
+#else
+ #include <sys/stat.h> // for mkdir
#endif
@@ -59,25 +61,25 @@
#define COPY_TO_SERVER() \
do { \
- AString ToServer; \
+ ContiguousByteBuffer ToServer; \
m_ClientBuffer.ReadAgain(ToServer); \
switch (m_ServerState) \
{ \
case csUnencrypted: \
{ \
- SERVERSEND(ToServer.data(), ToServer.size()); \
+ SERVERSEND(ToServer); \
break; \
} \
case csEncryptedUnderstood: \
case csEncryptedUnknown: \
{ \
- SERVERENCRYPTSEND(ToServer.data(), ToServer.size()); \
+ SERVERENCRYPTSEND(ToServer); \
break; \
} \
case csWaitingForEncryption: \
{ \
Log("Waiting for server encryption, queued %u bytes", ToServer.size()); \
- m_ServerEncryptionBuffer.append(ToServer.data(), ToServer.size()); \
+ m_ServerEncryptionBuffer += ToServer; \
break; \
} \
} \
@@ -86,19 +88,19 @@
#define COPY_TO_CLIENT() \
do { \
- AString ToClient; \
+ ContiguousByteBuffer ToClient; \
m_ServerBuffer.ReadAgain(ToClient); \
switch (m_ClientState) \
{ \
case csUnencrypted: \
{ \
- CLIENTSEND(ToClient.data(), ToClient.size()); \
+ CLIENTSEND(ToClient); \
break; \
} \
case csEncryptedUnderstood: \
case csEncryptedUnknown: \
{ \
- CLIENTENCRYPTSEND(ToClient.data(), ToClient.size()); \
+ CLIENTENCRYPTSEND(ToClient); \
break; \
} \
case csWaitingForEncryption: \
@@ -114,7 +116,7 @@
do { \
if (!Proc) \
{ \
- AString Leftover; \
+ ContiguousByteBuffer Leftover; \
m_ClientBuffer.ReadAgain(Leftover); \
DataLog(Leftover.data(), Leftover.size(), "Leftover data after client packet parsing, %d bytes:", Leftover.size()); \
m_ClientBuffer.ResetRead(); \
@@ -374,15 +376,15 @@ bool cConnection::RelayFromServer(void)
}
case csEncryptedUnderstood:
{
- m_ServerDecryptor.ProcessData(reinterpret_cast<Byte *>(Buffer), reinterpret_cast<Byte *>(Buffer), static_cast<size_t>(res));
+ m_ServerDecryptor.ProcessData(reinterpret_cast<std::byte *>(Buffer), reinterpret_cast<const Byte *>(Buffer), static_cast<size_t>(res));
DataLog(Buffer, static_cast<size_t>(res), "Decrypted %d bytes from the SERVER", res);
return DecodeServersPackets(Buffer, res);
}
case csEncryptedUnknown:
{
- m_ServerDecryptor.ProcessData(reinterpret_cast<Byte *>(Buffer), reinterpret_cast<Byte *>(Buffer), static_cast<size_t>(res));
+ m_ServerDecryptor.ProcessData(reinterpret_cast<std::byte *>(Buffer), reinterpret_cast<const Byte *>(Buffer), static_cast<size_t>(res));
DataLog(Buffer, static_cast<size_t>(res), "Decrypted %d bytes from the SERVER", res);
- return CLIENTSEND(Buffer, static_cast<size_t>(res));
+ return CLIENTSEND({ reinterpret_cast<const std::byte *>(Buffer), static_cast<size_t>(res) });
}
}
ASSERT(!"Unhandled server state while relaying from server");
@@ -419,8 +421,8 @@ bool cConnection::RelayFromClient(void)
case csEncryptedUnknown:
{
DataLog(Buffer, static_cast<size_t>(res), "Decrypted %d bytes from the CLIENT", res);
- m_ServerEncryptor.ProcessData(reinterpret_cast<Byte *>(Buffer), reinterpret_cast<Byte *>(Buffer), static_cast<size_t>(res));
- return SERVERSEND(Buffer, static_cast<size_t>(res));
+ m_ServerEncryptor.ProcessData(reinterpret_cast<std::byte *>(Buffer), reinterpret_cast<const std::byte *>(Buffer), static_cast<size_t>(res));
+ return SERVERSEND({ reinterpret_cast<const std::byte *>(Buffer), static_cast<size_t>(res) });
}
}
ASSERT(!"Unhandled server state while relaying from client");
@@ -441,11 +443,11 @@ double cConnection::GetRelativeTime(void)
-bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, size_t a_Size, const char * a_Peer)
+bool cConnection::SendData(SOCKET a_Socket, const ContiguousByteBufferView a_Data, const char * a_Peer)
{
- DataLog(a_Data, a_Size, "Sending data to %s, %u bytes", a_Peer, static_cast<unsigned>(a_Size));
+ DataLog(a_Data.data(), a_Data.size(), "Sending data to %s, %zu bytes", a_Peer, a_Data.size());
- int res = static_cast<int>(send(a_Socket, a_Data, a_Size, 0)); // Windows uses int for a_Size, Linux uses size_t; but Windows doesn't complain. Return type is int on Windows and ssize_t on Linux
+ int res = static_cast<int>(send(a_Socket, reinterpret_cast<const char *>(a_Data.data()), a_Data.size(), 0)); // Windows uses int for a_Size, Linux uses size_t; but Windows doesn't complain. Return type is int on Windows and ssize_t on Linux
if (res <= 0)
{
Log("%s closed the socket: %d, %d; aborting connection", a_Peer, res, SocketError);
@@ -460,32 +462,30 @@ bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, size_t a_Size,
bool cConnection::SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer)
{
- AString All;
+ ContiguousByteBuffer All;
a_Data.ReadAll(All);
a_Data.CommitRead();
- return SendData(a_Socket, All.data(), All.size(), a_Peer);
+ return SendData(a_Socket, All, a_Peer);
}
-bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer)
+bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, ContiguousByteBufferView a_Data, const char * a_Peer)
{
- DataLog(a_Data, a_Size, "Encrypting %d bytes to %s", a_Size, a_Peer);
- const Byte * Data = reinterpret_cast<const Byte *>(a_Data);
- while (a_Size > 0)
+ DataLog(a_Data.data(), a_Data.size(), "Encrypting %zu bytes to %s", a_Data.size(), a_Peer);
+ while (a_Data.size() > 0)
{
- Byte Buffer[64 KiB];
- size_t NumBytes = (a_Size > sizeof(Buffer)) ? sizeof(Buffer) : a_Size;
- a_Encryptor.ProcessData(Buffer, Data, NumBytes);
- bool res = SendData(a_Socket, reinterpret_cast<const char *>(Buffer), NumBytes, a_Peer);
+ std::byte Buffer[64 KiB];
+ size_t NumBytes = (a_Data.size() > sizeof(Buffer)) ? sizeof(Buffer) : a_Data.size();
+ a_Encryptor.ProcessData(Buffer, a_Data.data(), NumBytes);
+ bool res = SendData(a_Socket, { Buffer, NumBytes }, a_Peer);
if (!res)
{
return false;
}
- Data += NumBytes;
- a_Size -= NumBytes;
+ a_Data = a_Data.substr(NumBytes);
}
return true;
}
@@ -496,10 +496,10 @@ bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Enc
bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer)
{
- AString All;
+ ContiguousByteBuffer All;
a_Data.ReadAll(All);
a_Data.CommitRead();
- return SendEncryptedData(a_Socket, a_Encryptor, All.data(), All.size(), a_Peer);
+ return SendEncryptedData(a_Socket, a_Encryptor, All, a_Peer);
}
@@ -647,7 +647,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
if (PacketLen == 0)
{
m_ServerBuffer.ResetRead();
- AString All;
+ ContiguousByteBuffer All;
m_ServerBuffer.ReadAll(All);
DataLog(All.data(), All.size(), "====== Received a bad packet length? Inspect the contents below ======");
m_ServerBuffer.CommitRead(); // Try to recover by marking everything as read
@@ -798,10 +798,11 @@ bool cConnection::HandleClientHandshake(void)
Packet.WriteVarUTF8String(ServerHost);
Packet.WriteBEUInt16(m_Server.GetConnectPort());
Packet.WriteVarInt32(NextState);
- AString Pkt;
+ ContiguousByteBuffer Pkt;
Packet.ReadAll(Pkt);
cByteBuffer ToServer(512);
- ToServer.WriteVarUTF8String(Pkt);
+ ToServer.WriteVarInt32(static_cast<UInt32>(Pkt.size()));
+ ToServer.Write(Pkt.data(), Pkt.size());
SERVERSEND(ToServer);
m_ClientProtocolState = static_cast<int>(NextState);
@@ -1111,8 +1112,8 @@ bool cConnection::HandleClientPluginMessage(void)
{
HANDLE_CLIENT_PACKET_READ(ReadVarUTF8String, AString, ChannelName);
HANDLE_CLIENT_PACKET_READ(ReadBEUInt16, UInt16, Length);
- AString Data;
- if (!m_ClientBuffer.ReadString(Data, Length))
+ ContiguousByteBuffer Data;
+ if (!m_ClientBuffer.ReadSome(Data, Length))
{
return false;
}
@@ -1253,8 +1254,8 @@ bool cConnection::HandleClientWindowClose(void)
bool cConnection::HandleClientUnknownPacket(UInt32 a_PacketType, UInt32 a_PacketLen, UInt32 a_PacketReadSoFar)
{
- AString Data;
- if (!m_ClientBuffer.ReadString(Data, a_PacketLen - a_PacketReadSoFar))
+ ContiguousByteBuffer Data;
+ if (!m_ClientBuffer.ReadSome(Data, a_PacketLen - a_PacketReadSoFar))
{
return false;
}
@@ -1288,14 +1289,14 @@ bool cConnection::HandleServerLoginEncryptionKeyRequest(void)
// Read the packet from the server:
HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, ServerID);
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, PublicKeyLength);
- AString PublicKey;
- if (!m_ServerBuffer.ReadString(PublicKey, PublicKeyLength))
+ ContiguousByteBuffer PublicKey;
+ if (!m_ServerBuffer.ReadSome(PublicKey, PublicKeyLength))
{
return false;
}
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, NonceLength);
- AString Nonce;
- if (!m_ServerBuffer.ReadString(Nonce, NonceLength))
+ ContiguousByteBuffer Nonce;
+ if (!m_ServerBuffer.ReadSome(Nonce, NonceLength))
{
return false;
}
@@ -1304,7 +1305,7 @@ bool cConnection::HandleServerLoginEncryptionKeyRequest(void)
DataLog(PublicKey.data(), PublicKey.size(), " Public key (%u bytes)", static_cast<unsigned>(PublicKey.size()));
// Reply to the server:
- SendEncryptionKeyResponse(PublicKey, Nonce);
+ SendEncryptionKeyResponse({ reinterpret_cast<const char *>(PublicKey.data()), PublicKey.size() }, { reinterpret_cast<const char *>(Nonce.data()), Nonce.size() });
// Do not send to client - we want the client connection open
return true;
@@ -1330,7 +1331,7 @@ bool cConnection::HandleServerLoginSuccess(void)
Log("Server communication is now encrypted");
m_ServerState = csEncryptedUnderstood;
DataLog(m_ServerEncryptionBuffer.data(), m_ServerEncryptionBuffer.size(), "Sending the queued data to server (%u bytes):", m_ServerEncryptionBuffer.size());
- SERVERENCRYPTSEND(m_ServerEncryptionBuffer.data(), m_ServerEncryptionBuffer.size());
+ SERVERENCRYPTSEND(m_ServerEncryptionBuffer);
m_ServerEncryptionBuffer.clear();
}
COPY_TO_CLIENT();
@@ -1827,8 +1828,8 @@ bool cConnection::HandleServerKick(void)
AString PacketStart("\xff");
PacketStart.push_back(static_cast<char>(ReasonBE16.size() / 256));
PacketStart.push_back(static_cast<char>(ReasonBE16.size() % 256));
- CLIENTSEND(PacketStart.data(), PacketStart.size());
- CLIENTSEND(reinterpret_cast<const char *>(ReasonBE16.data()), ReasonBE16.size() * sizeof(char16_t));
+ CLIENTSEND({ reinterpret_cast<const std::byte *>(PacketStart.data()), PacketStart.size() });
+ CLIENTSEND({ reinterpret_cast<const std::byte *>(ReasonBE16.data()), ReasonBE16.size() * sizeof(char16_t) });
return true;
}
else
@@ -1856,8 +1857,8 @@ bool cConnection::HandleServerMapChunk(void)
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, PrimaryBitmap);
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, AdditionalBitmap);
HANDLE_SERVER_PACKET_READ(ReadBEUInt32, UInt32, CompressedSize);
- AString CompressedData;
- if (!m_ServerBuffer.ReadString(CompressedData, CompressedSize))
+ ContiguousByteBuffer CompressedData;
+ if (!m_ServerBuffer.ReadSome(CompressedData, CompressedSize))
{
return false;
}
@@ -1880,8 +1881,8 @@ bool cConnection::HandleServerMapChunkBulk(void)
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, ChunkCount);
HANDLE_SERVER_PACKET_READ(ReadBEUInt32, UInt32, CompressedSize);
HANDLE_SERVER_PACKET_READ(ReadBool, bool, IsSkyLightSent);
- AString CompressedData;
- if (!m_ServerBuffer.ReadString(CompressedData, CompressedSize))
+ ContiguousByteBuffer CompressedData;
+ if (!m_ServerBuffer.ReadSome(CompressedData, CompressedSize))
{
return false;
}
@@ -1930,8 +1931,8 @@ bool cConnection::HandleServerMultiBlockChange(void)
HANDLE_SERVER_PACKET_READ(ReadBEInt32, Int32, ChunkZ);
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, NumBlocks);
HANDLE_SERVER_PACKET_READ(ReadBEUInt32, UInt32, DataSize);
- AString BlockChangeData;
- if (!m_ServerBuffer.ReadString(BlockChangeData, DataSize))
+ ContiguousByteBuffer BlockChangeData;
+ if (!m_ServerBuffer.ReadSome(BlockChangeData, DataSize))
{
return false;
}
@@ -2039,8 +2040,8 @@ bool cConnection::HandleServerPluginMessage(void)
{
HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, ChannelName);
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, Length);
- AString Data;
- if (!m_ServerBuffer.ReadString(Data, Length))
+ ContiguousByteBuffer Data;
+ if (!m_ServerBuffer.ReadSome(Data, Length))
{
return false;
}
@@ -2278,7 +2279,7 @@ bool cConnection::HandleServerSpawnObjectVehicle(void)
#ifdef _DEBUG
// DEBUG:
// This packet is still troublesome when DataIndicator != 0
- AString Buffer;
+ ContiguousByteBuffer Buffer;
m_ServerBuffer.ResetRead();
m_ServerBuffer.ReadAll(Buffer);
m_ServerBuffer.ResetRead();
@@ -2328,7 +2329,7 @@ bool cConnection::HandleServerSpawnObjectVehicle(void)
}
// TODO: Splash potions
}
- if ((ExtraLen > 0) && !m_ServerBuffer.ReadString(ExtraData, ExtraLen))
+ if ((ExtraLen > 0) && !m_ServerBuffer.ReadSome(ExtraData, ExtraLen))
{
return false;
}
@@ -2449,10 +2450,11 @@ bool cConnection::HandleServerStatusResponse(void)
cByteBuffer Packet(Response.size() + 50);
Packet.WriteVarInt32(0); // Packet type - status response
Packet.WriteVarUTF8String(Response);
- AString Pkt;
+ ContiguousByteBuffer Pkt;
Packet.ReadAll(Pkt);
cByteBuffer ToClient(Response.size() + 50);
- ToClient.WriteVarUTF8String(Pkt);
+ ToClient.WriteVarInt32(static_cast<UInt32>(Pkt.size()));
+ ToClient.Write(Pkt.data(), Pkt.size());
CLIENTSEND(ToClient);
return true;
}
@@ -2545,8 +2547,8 @@ bool cConnection::HandleServerUpdateTileEntity(void)
HANDLE_SERVER_PACKET_READ(ReadBEUInt8, UInt8, Action);
HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, DataLength);
- AString Data;
- if ((DataLength > 0) && !m_ServerBuffer.ReadString(Data, DataLength))
+ ContiguousByteBuffer Data;
+ if ((DataLength > 0) && !m_ServerBuffer.ReadSome(Data, DataLength))
{
return false;
}
@@ -2662,9 +2664,9 @@ bool cConnection::HandleServerWindowOpen(void)
bool cConnection::HandleServerUnknownPacket(UInt32 a_PacketType, UInt32 a_PacketLen, UInt32 a_PacketReadSoFar)
{
- AString Data;
+ ContiguousByteBuffer Data;
ASSERT(a_PacketLen >= a_PacketReadSoFar);
- if (!m_ServerBuffer.ReadString(Data, a_PacketLen - a_PacketReadSoFar))
+ if (!m_ServerBuffer.ReadSome(Data, a_PacketLen - a_PacketReadSoFar))
{
return false;
}
@@ -2764,9 +2766,9 @@ bool cConnection::ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata)
rs = rs - static_cast<int>(a_Buffer.GetReadableSpace());
cByteBuffer LenBuf(8);
LenBuf.WriteVarInt32(Len);
- AString VarLen;
+ ContiguousByteBuffer VarLen;
LenBuf.ReadAll(VarLen);
- a_Metadata.append(VarLen);
+ a_Metadata += { reinterpret_cast<const char *>(VarLen.data()), VarLen.size() };
Length = Len;
break;
}
@@ -2794,12 +2796,12 @@ bool cConnection::ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata)
} // switch (Type)
// Read the data in this item:
- AString data;
- if (!a_Buffer.ReadString(data, Length))
+ ContiguousByteBuffer data;
+ if (!a_Buffer.ReadSome(data, Length))
{
return false;
}
- a_Metadata.append(data);
+ a_Metadata += { reinterpret_cast<const char *>(data.data()), data.size() };
if (!a_Buffer.ReadBEUInt8(x))
{
return false;
diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h
index 6c13efba2..b524561a1 100644
--- a/Tools/ProtoProxy/Connection.h
+++ b/Tools/ProtoProxy/Connection.h
@@ -13,6 +13,10 @@
#include "mbedTLS++/AesCfb128Decryptor.h"
#include "mbedTLS++/AesCfb128Encryptor.h"
+#ifndef _WIN32
+ typedef int SOCKET;
+#endif
+
@@ -85,7 +89,7 @@ protected:
cAesCfb128Decryptor m_ServerDecryptor;
cAesCfb128Encryptor m_ServerEncryptor;
- AString m_ServerEncryptionBuffer; // Buffer for the data to be sent to the server once encryption is established
+ ContiguousByteBuffer m_ServerEncryptionBuffer; // Buffer for the data to be sent to the server once encryption is established
/** Set to true when PACKET_PING is received from the client; will cause special parsing for server kick */
bool m_HasClientPinged;
@@ -119,13 +123,13 @@ protected:
double GetRelativeTime(void);
/** Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false. */
- bool SendData(SOCKET a_Socket, const char * a_Data, size_t a_Size, const char * a_Peer);
+ bool SendData(SOCKET a_Socket, ContiguousByteBufferView a_Data, const char * a_Peer);
/** Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false. */
bool SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer);
/** Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false */
- bool SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer);
+ bool SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, ContiguousByteBufferView a_Data, const char * a_Peer);
/** Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false */
bool SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer);
diff --git a/Tools/ProtoProxy/Globals.cpp b/Tools/ProtoProxy/Globals.cpp
deleted file mode 100644
index 13c6ae709..000000000
--- a/Tools/ProtoProxy/Globals.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-
-// Globals.cpp
-
-// This file is used for precompiled header generation in MSVC environments
-
-#include "Globals.h"
-
-
-
-
diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h
deleted file mode 100644
index 71173d1db..000000000
--- a/Tools/ProtoProxy/Globals.h
+++ /dev/null
@@ -1,177 +0,0 @@
-
-// Globals.h
-
-// This file gets included from every module in the project, so that global symbols may be introduced easily
-// Also used for precompiled header generation in MSVC environments
-
-
-
-
-
-// Compiler-dependent stuff:
-#if defined(_MSC_VER)
- // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
- #pragma warning(disable:4481)
-
- // Disable some warnings that we don't care about:
- #pragma warning(disable:4100)
-
-#elif defined(__GNUC__)
-
- // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
- #define abstract
-
-#else
-
- #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
-
-#endif
-
-
-
-
-
-// Integral types with predefined sizes:
-typedef signed long long Int64;
-typedef signed int Int32;
-typedef signed short Int16;
-typedef signed char Int8;
-
-typedef unsigned long long UInt64;
-typedef unsigned int UInt32;
-typedef unsigned short UInt16;
-typedef unsigned char UInt8;
-
-typedef unsigned char Byte;
-
-
-
-
-
-// A macro to disallow the copy constructor and operator= functions
-// This should be used in the private: declarations for any class that shouldn't allow copying itself
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName &); \
- void operator=(const TypeName &)
-
-// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
-#define UNUSED(X) (void)(X)
-
-
-
-
-// OS-dependent stuff:
-#ifdef _WIN32
- #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
- #undef max
-
- // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
- #ifdef GetFreeSpace
- #undef GetFreeSpace
- #endif // GetFreeSpace
-
- #define SocketError WSAGetLastError()
-#else
- #include <sys/types.h>
- #include <sys/stat.h> // for mkdir
- #include <sys/time.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <time.h>
- #include <dirent.h>
- #include <errno.h>
- #include <iostream>
- #include <unistd.h>
-
- #include <cstdio>
- #include <cstring>
- #include <pthread.h>
- #include <semaphore.h>
- #include <errno.h>
- #include <fcntl.h>
-
- typedef int SOCKET;
- enum
- {
- INVALID_SOCKET = -1,
- };
- #define closesocket close
- #define SocketError errno
-#endif
-
-
-
-
-
-// CRT stuff:
-#include <assert.h>
-#include <stdio.h>
-#include <math.h>
-#include <stdarg.h>
-#include <time.h>
-
-
-
-
-
-// STL stuff:
-#include <chrono>
-#include <vector>
-#include <list>
-#include <deque>
-#include <string>
-#include <map>
-#include <algorithm>
-#include <memory>
-#include <atomic>
-#include <mutex>
-#include <thread>
-#include <condition_variable>
-
-
-
-
-
-// Common headers (part 1, without macros):
-#include "fmt.h"
-#include "StringUtils.h"
-#include "OSSupport/CriticalSection.h"
-
-#include "LoggerSimple.h"
-
-
-
-// Common definitions:
-
-/** Evaluates to the number of elements in an array (compile-time!) */
-#define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X)))
-
-/* Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)") */
-#define KiB * 1024
-
-/* Faster than (int)floorf((float)x / (float)div) */
-#define FAST_FLOOR_DIV(x, div) ((x) < 0 ? (((int)x / div) - 1) : ((int)x / div))
-
-// Own version of assert() that writes failed assertions to the log for review
-#ifdef NDEBUG
- #define ASSERT(x) ((void)0)
-#else
- #define ASSERT assert
-#endif
-
-// Pretty much the same as ASSERT() but stays in Release builds
-#define VERIFY(x) (!!(x) || (LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), exit(1), 0))
-
-
-
-
-
-
diff --git a/Tools/ProtoProxy/Server.h b/Tools/ProtoProxy/Server.h
index c09a72b85..e8db7f1c7 100644
--- a/Tools/ProtoProxy/Server.h
+++ b/Tools/ProtoProxy/Server.h
@@ -9,8 +9,20 @@
#pragma once
+#include "Globals.h"
#include "mbedTLS++/RsaPrivateKey.h"
+#ifdef _WIN32
+ #define SocketError WSAGetLastError()
+#else
+ typedef int SOCKET;
+ enum
+ {
+ INVALID_SOCKET = -1,
+ };
+ #define closesocket close
+ #define SocketError errno
+#endif
@@ -20,7 +32,7 @@ class cServer
{
SOCKET m_ListenSocket;
cRsaPrivateKey m_PrivateKey;
- AString m_PublicKeyDER;
+ ContiguousByteBuffer m_PublicKeyDER;
UInt16 m_ConnectPort;
public:
@@ -30,7 +42,7 @@ public:
void Run(void);
cRsaPrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
- const AString & GetPublicKeyDER (void) { return m_PublicKeyDER; }
+ ContiguousByteBufferView GetPublicKeyDER (void) { return m_PublicKeyDER; }
UInt16 GetConnectPort(void) const { return m_ConnectPort; }
} ;