summaryrefslogtreecommitdiffstats
path: root/Tools/ProtoProxy
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Tools/ProtoProxy/Connection.cpp122
-rw-r--r--Tools/ProtoProxy/Connection.h114
-rw-r--r--Tools/ProtoProxy/Globals.h14
-rw-r--r--Tools/ProtoProxy/ProtoProxy.cpp8
-rw-r--r--Tools/ProtoProxy/Server.cpp10
-rw-r--r--Tools/ProtoProxy/Server.h12
6 files changed, 131 insertions, 149 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index a9fbe163e..940b9a7eb 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -17,7 +17,7 @@
-/// When defined, the following macro causes a sleep after each parsed packet (DEBUG-mode only)
+/** When defined, the following macro causes a sleep after each parsed packet (DEBUG-mode only) */
// #define SLEEP_AFTER_PACKET
@@ -121,7 +121,7 @@
return true; \
} \
}
-
+
#define HANDLE_SERVER_READ(Proc) \
{ \
if (!Proc) \
@@ -130,7 +130,7 @@
return true; \
} \
}
-
+
@@ -162,7 +162,7 @@ AString PrintableAbsIntTriplet(int a_X, int a_Y, int a_Z, double a_Divisor)
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) {}
} ;
@@ -185,7 +185,7 @@ struct sChunkMeta
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cConnection:
cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) :
@@ -291,14 +291,14 @@ void cConnection::Log(const char * a_Format, ...)
va_end(args);
AString FullMsg;
Printf(FullMsg, "[%5.3f] %s\n", GetRelativeTime(), msg.c_str());
-
+
// Log to file:
cCSLock Lock(m_CSLog);
fputs(FullMsg.c_str(), m_LogFile);
#ifdef _DEBUG
fflush(m_LogFile);
#endif // _DEBUG
-
+
// Log to screen:
// std::cout << FullMsg;
}
@@ -317,11 +317,11 @@ void cConnection::DataLog(const void * a_Data, size_t a_Size, const char * a_For
AString FullMsg;
AString Hex;
Printf(FullMsg, "[%5.3f] %s\n%s\n", GetRelativeTime(), msg.c_str(), CreateHexDump(Hex, a_Data, a_Size, 16).c_str());
-
+
// Log to file:
cCSLock Lock(m_CSLog);
fputs(FullMsg.c_str(), m_LogFile);
-
+
/*
// Log to screen:
std::cout << FullMsg;
@@ -374,9 +374,9 @@ bool cConnection::RelayFromServer(void)
Log("Server closed the socket: %d; %d; aborting connection", res, SocketError);
return false;
}
-
+
DataLog(Buffer, static_cast<size_t>(res), "Received %d bytes from the SERVER", res);
-
+
switch (m_ServerState)
{
case csUnencrypted:
@@ -414,9 +414,9 @@ bool cConnection::RelayFromClient(void)
Log("Client closed the socket: %d; %d; aborting connection", res, SocketError);
return false;
}
-
+
DataLog(Buffer, static_cast<size_t>(res), "Received %d bytes from the CLIENT", res);
-
+
switch (m_ClientState)
{
case csUnencrypted:
@@ -456,7 +456,7 @@ double cConnection::GetRelativeTime(void)
bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, size_t a_Size, const char * a_Peer)
{
DataLog(a_Data, a_Size, "Sending data to %s, %u bytes", a_Peer, static_cast<unsigned>(a_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
if (res <= 0)
{
@@ -525,7 +525,7 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
Log("Too much queued data for the server, aborting connection");
return false;
}
-
+
while (m_ClientBuffer.CanReadBytes(1))
{
UInt32 PacketLen;
@@ -556,7 +556,7 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
}
break;
} // case -1
-
+
case 1:
{
// Status query
@@ -568,7 +568,7 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
}
break;
}
-
+
case 2:
{
// Login
@@ -580,7 +580,7 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
}
break;
}
-
+
case 3:
{
// Game:
@@ -611,7 +611,7 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
}
break;
} // case 3 - Game
-
+
default:
{
Log("Receiving server packets while in an unknown protocol state (%d)!", m_ClientProtocolState);
@@ -635,7 +635,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
Log("Too much queued data for the client, aborting connection");
return false;
}
-
+
if (
(m_ServerState == csEncryptedUnderstood) &&
(m_ClientState == csUnencrypted)
@@ -643,7 +643,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
{
// Client hasn't finished encryption handshake yet, don't send them any data yet
}
-
+
while (true)
{
UInt32 PacketLen;
@@ -679,7 +679,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
HANDLE_SERVER_READ(HandleServerUnknownPacket(PacketType, PacketLen, PacketReadSoFar));
break;
}
-
+
case 1:
{
// Status query:
@@ -691,7 +691,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
}
break;
}
-
+
case 2:
{
// Login:
@@ -704,7 +704,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
}
break;
}
-
+
case 3:
{
// Game:
@@ -766,7 +766,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
} // switch (PacketType)
break;
} // case 3 - Game
-
+
// TODO: Move this elsewhere
default:
{
@@ -775,7 +775,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
break;
}
} // switch (m_ProtocolState)
-
+
m_ServerBuffer.CommitRead();
} // while (CanReadBytes(1))
return true;
@@ -785,7 +785,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// packet handling, client-side, initial handshake:
bool cConnection::HandleClientHandshake(void)
@@ -796,7 +796,7 @@ bool cConnection::HandleClientHandshake(void)
HANDLE_CLIENT_PACKET_READ(ReadBEUInt16, UInt16, ServerPort);
HANDLE_CLIENT_PACKET_READ(ReadVarInt, UInt32, NextState);
m_ClientBuffer.CommitRead();
-
+
Log("Received an initial handshake packet from the client:");
Log(" ProtocolVersion = %u", ProtocolVersion);
Log(" ServerHost = \"%s\"", ServerHost.c_str());
@@ -815,10 +815,10 @@ bool cConnection::HandleClientHandshake(void)
cByteBuffer ToServer(512);
ToServer.WriteVarUTF8String(Pkt);
SERVERSEND(ToServer);
-
+
m_ClientProtocolState = static_cast<int>(NextState);
m_ServerProtocolState = static_cast<int>(NextState);
-
+
return true;
}
@@ -826,7 +826,7 @@ bool cConnection::HandleClientHandshake(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// packet handling, client-side, login:
bool cConnection::HandleClientLoginEncryptionKeyResponse(void)
@@ -852,7 +852,7 @@ bool cConnection::HandleClientLoginStart(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// packet handling, client-side, game:
bool cConnection::HandleClientAnimation(void)
@@ -934,7 +934,7 @@ bool cConnection::HandleClientClientStatuses(void)
HANDLE_CLIENT_PACKET_READ(ReadBEUInt8, UInt8, Statuses);
Log("Received a PACKET_CLIENT_STATUSES from the CLIENT:");
Log(" Statuses = %u (0x%02x)", Statuses, Statuses);
-
+
COPY_TO_SERVER();
return true;
}
@@ -1087,7 +1087,7 @@ bool cConnection::HandleClientPlayerPosition(void)
Log("Received a PACKET_PLAYER_POSITION from the client");
// TODO: list packet contents
-
+
COPY_TO_SERVER();
return true;
}
@@ -1110,7 +1110,7 @@ bool cConnection::HandleClientPlayerPositionLook(void)
Log(" Stance = %.03f", Stance);
Log(" Yaw, Pitch = <%.03f, %.03f>", Yaw, Pitch);
Log(" IsOnGround = %s", IsOnGround ? "true" : "false");
-
+
COPY_TO_SERVER();
return true;
}
@@ -1279,7 +1279,7 @@ bool cConnection::HandleClientUnknownPacket(UInt32 a_PacketType, UInt32 a_Packet
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// packet handling, server-side, login:
bool cConnection::HandleServerLoginDisconnect(void)
@@ -1314,10 +1314,10 @@ bool cConnection::HandleServerLoginEncryptionKeyRequest(void)
Log("Got PACKET_ENCRYPTION_KEY_REQUEST from the SERVER:");
Log(" ServerID = %s", ServerID.c_str());
DataLog(PublicKey.data(), PublicKey.size(), " Public key (%u bytes)", static_cast<unsigned>(PublicKey.size()));
-
+
// Reply to the server:
SendEncryptionKeyResponse(PublicKey, Nonce);
-
+
// Do not send to client - we want the client connection open
return true;
}
@@ -1333,10 +1333,10 @@ bool cConnection::HandleServerLoginSuccess(void)
Log("Received a login success packet from the server:");
Log(" UUID = \"%s\"", UUID.c_str());
Log(" Username = \"%s\"", Username.c_str());
-
+
Log("Server is now in protocol state Game.");
m_ServerProtocolState = 3;
-
+
if (m_IsServerEncrypted)
{
Log("Server communication is now encrypted");
@@ -1355,7 +1355,7 @@ bool cConnection::HandleServerLoginSuccess(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// packet handling, server-side, game:
bool cConnection::HandleServerAttachEntity(void)
@@ -1585,7 +1585,7 @@ bool cConnection::HandleServerEntityProperties(void)
Log("Received a PACKET_ENTITY_PROPERTIES from the server:");
Log(" EntityID = %u", EntityID);
Log(" Count = %u", Count);
-
+
for (UInt32 i = 0; i < Count; i++)
{
HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Key);
@@ -1797,7 +1797,7 @@ bool cConnection::HandleServerKick(void)
{
Log(" This was a std reply to client's PING");
AStringVector Split;
-
+
// Split by NULL chars (StringSplit() won't work here):
size_t Last = 0;
size_t Len = Reason.size();
@@ -1813,7 +1813,7 @@ bool cConnection::HandleServerKick(void)
{
Split.push_back(Reason.substr(Last));
}
-
+
if (Split.size() == 6)
{
Log(" Preamble: \"%s\"", Split[0].c_str());
@@ -1822,7 +1822,7 @@ bool cConnection::HandleServerKick(void)
Log(" MOTD: \"%s\"", Split[3].c_str());
Log(" Cur players: \"%s\"", Split[4].c_str());
Log(" Max players: \"%s\"", Split[5].c_str());
-
+
// Modify the MOTD to show that it's being ProtoProxied:
Reason.assign(Split[0]);
Reason.push_back(0);
@@ -1876,9 +1876,9 @@ bool cConnection::HandleServerMapChunk(void)
Log("Received a PACKET_MAP_CHUNK from the server:");
Log(" ChunkPos = [%d, %d]", ChunkX, ChunkZ);
Log(" Compressed size = %u (0x%x)", CompressedSize, CompressedSize);
-
+
// TODO: Save the compressed data into a file for later analysis
-
+
COPY_TO_CLIENT()
return true;
}
@@ -1897,7 +1897,7 @@ bool cConnection::HandleServerMapChunkBulk(void)
{
return false;
}
-
+
// Read individual chunk metas.
// Need to read them first and only then start logging (in case we don't have the full packet yet)
typedef std::vector<sChunkMeta> sChunkMetas;
@@ -1911,12 +1911,12 @@ bool cConnection::HandleServerMapChunkBulk(void)
HANDLE_SERVER_PACKET_READ(ReadBEInt16, Int16, AddBitmap);
ChunkMetas.push_back(sChunkMeta(ChunkX, ChunkZ, PrimaryBitmap, AddBitmap));
}
-
+
Log("Received a PACKET_MAP_CHUNK_BULK from the server:");
Log(" ChunkCount = %u", ChunkCount);
Log(" Compressed size = %u (0x%x)", CompressedSize, CompressedSize);
Log(" IsSkyLightSent = %s", IsSkyLightSent ? "true" : "false");
-
+
// Log individual chunk coords:
int idx = 0;
for (sChunkMetas::iterator itr = ChunkMetas.begin(), end = ChunkMetas.end(); itr != end; ++itr, ++idx)
@@ -1927,7 +1927,7 @@ bool cConnection::HandleServerMapChunkBulk(void)
} // for itr - ChunkMetas[]
// TODO: Save the compressed data into a file for later analysis
-
+
COPY_TO_CLIENT();
return true;
}
@@ -2038,7 +2038,7 @@ bool cConnection::HandleServerPlayerPositionLook(void)
Log("Received a PACKET_PLAYER_POSITION_LOOK from the server");
// TODO: list packet contents
-
+
COPY_TO_CLIENT();
return true;
}
@@ -2304,7 +2304,7 @@ bool cConnection::HandleServerSpawnObjectVehicle(void)
}
DataLog(Buffer.data(), Buffer.size(), "Buffer while parsing the PACKET_SPAWN_OBJECT_VEHICLE packet (%u bytes):", static_cast<unsigned>(Buffer.size()));
#endif // _DEBUG
-
+
HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, EntityID);
HANDLE_SERVER_PACKET_READ(ReadBEUInt8, UInt8, ObjType);
HANDLE_SERVER_PACKET_READ(ReadBEInt32, Int32, PosX);
@@ -2446,7 +2446,7 @@ bool cConnection::HandleServerStatusResponse(void)
HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Response);
Log("Received server's status response:");
Log(" Response: %s", Response.c_str());
-
+
// Modify the response to show that it's being proto-proxied:
const char DescSearch[] = "\"description\":{\"text\":\"";
size_t idx = Response.find(DescSearch);
@@ -2555,7 +2555,7 @@ bool cConnection::HandleServerUpdateTileEntity(void)
HANDLE_SERVER_PACKET_READ(ReadBEInt16, Int16, BlockY);
HANDLE_SERVER_PACKET_READ(ReadBEInt32, Int32, BlockZ);
HANDLE_SERVER_PACKET_READ(ReadBEUInt8, UInt8, Action);
- HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, DataLength);
+ HANDLE_SERVER_PACKET_READ(ReadBEUInt16, UInt16, DataLength);
AString Data;
if ((DataLength > 0) && !m_ServerBuffer.ReadString(Data, DataLength))
@@ -2736,7 +2736,7 @@ bool cConnection::ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc)
fclose(f);
AppendPrintf(a_ItemDesc, "\n (saved to file \"%s\")", fnam.c_str());
}
-
+
return true;
}
@@ -2901,7 +2901,7 @@ void cConnection::LogMetadata(const AString & a_Metadata, size_t a_IndentCount)
}
case 6:
{
- Log("%spos[%u] = <%d, %d, %d>", Indent.c_str(), Index,
+ Log("%spos[%u] = <%d, %d, %d>", Indent.c_str(), Index,
(a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4],
(a_Metadata[pos + 5] << 24) | (a_Metadata[pos + 6] << 16) | (a_Metadata[pos + 7] << 8) | a_Metadata[pos + 8],
(a_Metadata[pos + 9] << 24) | (a_Metadata[pos + 10] << 16) | (a_Metadata[pos + 11] << 8) | a_Metadata[pos + 12]
@@ -2939,7 +2939,7 @@ void cConnection::SendEncryptionKeyResponse(const AString & a_ServerPublicKey, c
m_ServerEncryptor.Init(SharedSecret, SharedSecret);
m_ServerDecryptor.Init(SharedSecret, SharedSecret);
-
+
// Encrypt the nonce:
Byte EncryptedNonce[128];
res = PubKey.Encrypt(reinterpret_cast<const Byte *>(a_Nonce.data()), a_Nonce.size(), EncryptedNonce, sizeof(EncryptedNonce));
@@ -2948,7 +2948,7 @@ void cConnection::SendEncryptionKeyResponse(const AString & a_ServerPublicKey, c
Log("Nonce encryption failed: %d (0x%x)", res, res);
return;
}
-
+
// Send the packet to the server:
Log("Sending PACKET_ENCRYPTION_KEY_RESPONSE to the SERVER");
cByteBuffer ToServer(1024);
@@ -2966,7 +2966,3 @@ void cConnection::SendEncryptionKeyResponse(const AString & a_ServerPublicKey, c
m_ServerState = csEncryptedUnderstood;
m_IsServerEncrypted = true;
}
-
-
-
-
diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h
index d8a63d70f..2402e9f95 100644
--- a/Tools/ProtoProxy/Connection.h
+++ b/Tools/ProtoProxy/Connection.h
@@ -25,19 +25,21 @@ class cServer;
class cConnection
{
- AString m_LogNameBase; ///< Base for the log filename and all files connected to this log
-
- int m_ItemIdx; ///< Index for the next file into which item metadata should be written (ParseSlot() function)
-
+ /** Base for the log filename and all files connected to this log */
+ AString m_LogNameBase;
+
+ /** Index for the next file into which item metadata should be written (ParseSlot() function) */
+ int m_ItemIdx;
+
cCriticalSection m_CSLog;
FILE * m_LogFile;
-
+
cServer & m_Server;
SOCKET m_ClientSocket;
SOCKET m_ServerSocket;
-
+
std::chrono::steady_clock::time_point m_BeginTick; // Tick when the relative time was first retrieved (used for GetRelativeTime())
-
+
enum eConnectionState
{
csUnencrypted, // The connection is not encrypted. Packets must be decoded in order to be able to start decryption.
@@ -45,35 +47,35 @@ class cConnection
csEncryptedUnknown, // The communication is encrypted, but an unknown packet has been received, so packets cannot be decoded anymore
csWaitingForEncryption, // The communication is waiting for the other line to establish encryption
};
-
+
eConnectionState m_ClientState;
eConnectionState m_ServerState;
-
+
int m_Nonce;
-
+
public:
cConnection(SOCKET a_ClientSocket, cServer & a_Server);
~cConnection();
-
+
void Run(void);
-
+
void Log(const char * a_Format, ...);
void DataLog(const void * a_Data, size_t a_Size, const char * a_Format, ...);
void LogFlush(void);
-
+
protected:
cByteBuffer m_ClientBuffer;
cByteBuffer m_ServerBuffer;
-
+
cAesCfb128Decryptor m_ServerDecryptor;
cAesCfb128Encryptor m_ServerEncryptor;
AString 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
+
+ /** Set to true when PACKET_PING is received from the client; will cause special parsing for server kick */
bool m_HasClientPinged;
-
+
/*
The protocol states can be one of:
-1: no initial handshake received yet
@@ -81,52 +83,52 @@ protected:
2: login
3: game
*/
- /// State the to-server protocol is in (as defined by the initial handshake / login), -1 if no initial handshake received yet
+ /** State the to-server protocol is in (as defined by the initial handshake / login), -1 if no initial handshake received yet */
int m_ServerProtocolState;
-
- /// State the to-client protocol is in (as defined by the initial handshake / login), -1 if no initial handshake received yet
+
+ /** State the to-client protocol is in (as defined by the initial handshake / login), -1 if no initial handshake received yet */
int m_ClientProtocolState;
-
- /// True if the server connection has provided encryption keys
+
+ /** True if the server connection has provided encryption keys */
bool m_IsServerEncrypted;
-
+
bool ConnectToServer(void);
-
- /// Relays data from server to client; returns false if connection aborted
+
+ /** Relays data from server to client; returns false if connection aborted */
bool RelayFromServer(void);
-
- /// Relays data from client to server; returns false if connection aborted
+
+ /** Relays data from client to server; returns false if connection aborted */
bool RelayFromClient(void);
-
- /// Returns the time relative to the first call of this function, in the fractional seconds elapsed
+
+ /** Returns the time relative to the first call of this function, in the fractional seconds elapsed */
double GetRelativeTime(void);
-
- /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false.
+
+ /** 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);
-
- /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false.
+
+ /** 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
+
+ /** 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);
-
- /// 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
+
+ /** 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);
-
- /// Decodes packets coming from the client, sends appropriate counterparts to the server; returns false if the connection is to be dropped
+
+ /** Decodes packets coming from the client, sends appropriate counterparts to the server; returns false if the connection is to be dropped */
bool DecodeClientsPackets(const char * a_Data, int a_Size);
- /// Decodes packets coming from the server, sends appropriate counterparts to the client; returns false if the connection is to be dropped
+ /** Decodes packets coming from the server, sends appropriate counterparts to the client; returns false if the connection is to be dropped */
bool DecodeServersPackets(const char * a_Data, int a_Size);
-
+
// Packet handling, client-side, initial:
bool HandleClientHandshake(void);
-
+
// Packet handling, client-side, status:
bool HandleClientStatusPing(void);
bool HandleClientStatusRequest(void);
-
+
// Packet handling, client-side, login:
bool HandleClientLoginEncryptionKeyResponse(void);
bool HandleClientLoginStart(void);
@@ -155,7 +157,7 @@ protected:
bool HandleClientUseEntity(void);
bool HandleClientWindowClick(void);
bool HandleClientWindowClose(void);
-
+
bool HandleClientUnknownPacket(UInt32 a_PacketType, UInt32 a_PacketLen, UInt32 a_PacketReadSoFar);
// Packet handling, server-side, login:
@@ -221,25 +223,21 @@ protected:
bool HandleServerWindowClose(void);
bool HandleServerWindowContents(void);
bool HandleServerWindowOpen(void);
-
+
bool HandleServerUnknownPacket(UInt32 a_PacketType, UInt32 a_PacketLen, UInt32 a_PacketReadSoFar);
- /// Parses the slot data in a_Buffer into item description; returns true if successful, false if not enough data
+ /** Parses the slot data in a_Buffer into item description; returns true if successful, false if not enough data */
bool ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc);
-
- /// Parses the metadata in a_Buffer into raw metadata in an AString; returns true if successful, false if not enough data
+
+ /** Parses the metadata in a_Buffer into raw metadata in an AString; returns true if successful, false if not enough data */
bool ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata);
-
- /// Logs the contents of the metadata in the AString, using Log(). Assumes a_Metadata is valid (parsed by ParseMetadata()). The log is indented by a_IndentCount spaces
+
+ /** Logs the contents of the metadata in the AString, using Log(). Assumes a_Metadata is valid (parsed by ParseMetadata()). The log is indented by a_IndentCount spaces */
void LogMetadata(const AString & a_Metadata, size_t a_IndentCount);
-
- /// Send EKResp to the server:
+
+ /** Send EKResp to the server: */
void SendEncryptionKeyResponse(const AString & a_ServerPublicKey, const AString & a_Nonce);
-
- /// Starts client encryption based on the parameters received
+
+ /** Starts client encryption based on the parameters received */
void StartClientEncryption(const AString & a_EncryptedSecret, const AString & a_EncryptedNonce);
} ;
-
-
-
-
diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h
index 3ab01a61f..0ce5ea878 100644
--- a/Tools/ProtoProxy/Globals.h
+++ b/Tools/ProtoProxy/Globals.h
@@ -195,14 +195,14 @@ typedef unsigned char Byte;
// Common definitions:
-/// Evaluates to the number of elements in an array (compile-time!)
+/** 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)" )
+/* 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) )
+/* 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
@@ -212,7 +212,7 @@ typedef unsigned char Byte;
#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 ) )
+#define VERIFY(x) (!!(x) || (LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), exit(1), 0))
// C++11 has std::shared_ptr in <memory>, included earlier
#define SharedPtr std::shared_ptr
@@ -222,10 +222,10 @@ typedef unsigned char Byte;
-/// A generic interface used mainly in ForEach() functions
+/* A generic interface used mainly in ForEach() functions */
template <typename Type> class cItemCallback
{
public:
- /// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
+ /* Called for each item in the internal list; return true to stop the loop, or false to continue enumerating */
virtual bool Item(Type * a_Type) = 0;
} ;
diff --git a/Tools/ProtoProxy/ProtoProxy.cpp b/Tools/ProtoProxy/ProtoProxy.cpp
index ac5858d02..809f2dc7d 100644
--- a/Tools/ProtoProxy/ProtoProxy.cpp
+++ b/Tools/ProtoProxy/ProtoProxy.cpp
@@ -52,12 +52,8 @@ int main(int argc, char ** argv)
LOGERROR("Server initialization failed: %d", res);
return res;
}
-
+
Server.Run();
-
+
return 0;
}
-
-
-
-
diff --git a/Tools/ProtoProxy/Server.cpp b/Tools/ProtoProxy/Server.cpp
index 60998798c..2db67e960 100644
--- a/Tools/ProtoProxy/Server.cpp
+++ b/Tools/ProtoProxy/Server.cpp
@@ -23,7 +23,7 @@ cServer::cServer(void)
int cServer::Init(UInt16 a_ListenPort, UInt16 a_ConnectPort)
{
m_ConnectPort = a_ConnectPort;
-
+
#ifdef _WIN32
WSAData wsa;
int res = WSAStartup(0x0202, &wsa);
@@ -33,7 +33,7 @@ int cServer::Init(UInt16 a_ListenPort, UInt16 a_ConnectPort)
return res;
}
#endif // _WIN32
-
+
m_ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_ListenSocket < 0)
{
@@ -71,7 +71,7 @@ int cServer::Init(UInt16 a_ListenPort, UInt16 a_ConnectPort)
return err;
}
LOGINFO("Listening for client connections on port %d, connecting to server at localhost:%d", a_ListenPort, a_ConnectPort);
-
+
LOGINFO("Generating protocol encryption keypair...");
m_PrivateKey.Generate();
m_PublicKeyDER = m_PrivateKey.GetPubKeyDER();
@@ -103,7 +103,3 @@ void cServer::Run(void)
LOGINFO("Client disconnected. Ready for another connection.");
}
}
-
-
-
-
diff --git a/Tools/ProtoProxy/Server.h b/Tools/ProtoProxy/Server.h
index b29c6e394..c09a72b85 100644
--- a/Tools/ProtoProxy/Server.h
+++ b/Tools/ProtoProxy/Server.h
@@ -22,19 +22,15 @@ class cServer
cRsaPrivateKey m_PrivateKey;
AString m_PublicKeyDER;
UInt16 m_ConnectPort;
-
+
public:
cServer(void);
-
+
int Init(UInt16 a_ListenPort, UInt16 a_ConnectPort);
void Run(void);
-
+
cRsaPrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
const AString & GetPublicKeyDER (void) { return m_PublicKeyDER; }
-
+
UInt16 GetConnectPort(void) const { return m_ConnectPort; }
} ;
-
-
-
-