diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-07-06 13:47:03 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-07-06 22:33:03 +0200 |
commit | 4ec44751e2ae35542d7364b9bcad95b1a32cb135 (patch) | |
tree | 23dcd61746e249bf43207fe9273c4736d296e73c /Tools/ProtoProxy | |
parent | Replace chunk coordinates magic with numeric_limits (diff) | |
download | cuberite-4ec44751e2ae35542d7364b9bcad95b1a32cb135.tar cuberite-4ec44751e2ae35542d7364b9bcad95b1a32cb135.tar.gz cuberite-4ec44751e2ae35542d7364b9bcad95b1a32cb135.tar.bz2 cuberite-4ec44751e2ae35542d7364b9bcad95b1a32cb135.tar.lz cuberite-4ec44751e2ae35542d7364b9bcad95b1a32cb135.tar.xz cuberite-4ec44751e2ae35542d7364b9bcad95b1a32cb135.tar.zst cuberite-4ec44751e2ae35542d7364b9bcad95b1a32cb135.zip |
Diffstat (limited to 'Tools/ProtoProxy')
-rw-r--r-- | Tools/ProtoProxy/Connection.cpp | 20 | ||||
-rw-r--r-- | Tools/ProtoProxy/Connection.h | 2 |
2 files changed, 6 insertions, 16 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index ba4614382..2bb6c9a43 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -421,7 +421,7 @@ 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<std::byte *>(Buffer), reinterpret_cast<const std::byte *>(Buffer), static_cast<size_t>(res)); + m_ServerEncryptor.ProcessData(reinterpret_cast<std::byte *>(Buffer), static_cast<size_t>(res)); return SERVERSEND({ reinterpret_cast<const std::byte *>(Buffer), static_cast<size_t>(res) }); } } @@ -472,22 +472,12 @@ bool cConnection::SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a -bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, ContiguousByteBufferView a_Data, const char * a_Peer) +bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, ContiguousByteBuffer & a_Data, const char * a_Peer) { DataLog(a_Data.data(), a_Data.size(), "Encrypting %zu bytes to %s", a_Data.size(), a_Peer); - while (a_Data.size() > 0) - { - 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; - } - a_Data = a_Data.substr(NumBytes); - } - return true; + + a_Encryptor.ProcessData(a_Data.data(), a_Data.size()); + return SendData(a_Socket, a_Data, a_Peer); } diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h index b524561a1..b5e1b4ce0 100644 --- a/Tools/ProtoProxy/Connection.h +++ b/Tools/ProtoProxy/Connection.h @@ -129,7 +129,7 @@ protected: 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, ContiguousByteBufferView a_Data, const char * a_Peer); + bool SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, ContiguousByteBuffer & 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); |