diff --git a/src/Cedar/Client.c b/src/Cedar/Client.c index 1c40787b..d3daf774 100644 --- a/src/Cedar/Client.c +++ b/src/Cedar/Client.c @@ -4846,6 +4846,7 @@ void InRpcClientGetConnectionStatus(RPC_CLIENT_GET_CONNECTION_STATUS *s, PACK *p s->UseCompress = PackGetInt(p, "UseCompress") ? true : false; s->IsRUDPSession = PackGetInt(p, "IsRUDPSession") ? true : false; PackGetStr(p, "UnderlayProtocol", s->UnderlayProtocol, sizeof(s->UnderlayProtocol)); + PackGetStr(p, "ProtocolDetails", s->ProtocolDetails, sizeof(s->ProtocolDetails)); s->IsUdpAccelerationEnabled = PackGetInt(p, "IsUdpAccelerationEnabled") ? true : false; s->IsUsingUdpAcceleration = PackGetInt(p, "IsUsingUdpAcceleration") ? true : false; @@ -4908,6 +4909,7 @@ void OutRpcClientGetConnectionStatus(PACK *p, RPC_CLIENT_GET_CONNECTION_STATUS * PackAddBool(p, "UseCompress", c->UseCompress); PackAddBool(p, "IsRUDPSession", c->IsRUDPSession); PackAddStr(p, "UnderlayProtocol", c->UnderlayProtocol); + PackAddStr(p, "ProtocolDetails", c->ProtocolDetails); PackAddBool(p, "IsUdpAccelerationEnabled", c->IsUdpAccelerationEnabled); PackAddBool(p, "IsUsingUdpAcceleration", c->IsUsingUdpAcceleration); diff --git a/src/Cedar/Protocol.c b/src/Cedar/Protocol.c index 94f2a682..dbb2b4fc 100644 --- a/src/Cedar/Protocol.c +++ b/src/Cedar/Protocol.c @@ -2940,6 +2940,8 @@ bool ServerAccept(CONNECTION *c) rudp_bulk_version = 2; } + s->BulkOnRUDPVersion = rudp_bulk_version; + if (s->EnableBulkOnRUDP) { AddProtocolDetailsKeyValueInt(s->ProtocolDetails, sizeof(s->ProtocolDetails), "RUDP_Bulk_Ver", s->BulkOnRUDPVersion); diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index ee97595d..6a7413db 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -2388,8 +2388,6 @@ void RUDPBulkSend(RUDP_STACK *r, RUDP_SESSION *se, void *data, UINT data_size) padding_size = Rand32() % 31 + 1; - size = sizeof(UINT64) + data_size + padding_size; - // Packet: IV + Encrypted(SEQ_NO + Data + padding) + MAC buf_size = RUDP_BULK_IV_SIZE_V2 + sizeof(UINT64) + data_size + padding_size + RUDP_BULK_MAC_SIZE_V2; buf = Malloc(buf_size); @@ -2417,7 +2415,7 @@ void RUDPBulkSend(RUDP_STACK *r, RUDP_SESSION *se, void *data, UINT data_size) // Encryption c = NewCipher("ChaCha20-Poly1305"); SetCipherKey(c, se->BulkSendKey->Data, true); - CipherProcessAead(c, iv, tmp + size, RUDP_BULK_MAC_SIZE_V2, tmp, tmp, size - RUDP_BULK_MAC_SIZE_V2, NULL, 0); + CipherProcessAead(c, iv, tmp + size, RUDP_BULK_MAC_SIZE_V2, tmp, tmp, size, NULL, 0); FreeCipher(c); // Next IV @@ -2635,7 +2633,7 @@ bool RUDPCheckSignOfRecvPacket(RUDP_STACK *r, RUDP_SESSION *se, void *recv_data, c = NewCipher("ChaCha20-Poly1305"); SetCipherKey(c, se->BulkRecvKey->Data, false); - size = CipherProcessAead(c, iv, p + size, RUDP_BULK_MAC_SIZE_V2, r->TmpBuf, p, size - RUDP_BULK_MAC_SIZE_V2, NULL, 0); + size = CipherProcessAead(c, iv, p + size - RUDP_BULK_MAC_SIZE_V2, RUDP_BULK_MAC_SIZE_V2, r->TmpBuf, p, size - RUDP_BULK_MAC_SIZE_V2, NULL, 0); FreeCipher(c); if (size == 0) @@ -2719,7 +2717,7 @@ bool RUDPProcessBulkRecvPacket(RUDP_STACK *r, RUDP_SESSION *se, void *recv_data, c = NewCipher("ChaCha20-Poly1305"); SetCipherKey(c, se->BulkRecvKey->Data, false); - ret = CipherProcessAead(c, iv, p + size, RUDP_BULK_MAC_SIZE_V2, p, p, size - RUDP_BULK_MAC_SIZE_V2, NULL, 0); + ret = CipherProcessAead(c, iv, p + size - RUDP_BULK_MAC_SIZE_V2, RUDP_BULK_MAC_SIZE_V2, p, p, size - RUDP_BULK_MAC_SIZE_V2, NULL, 0); FreeCipher(c); if (ret == 0)