fixed connection bugs

This commit is contained in:
2025-11-02 15:26:30 +05:00
parent 8179609d47
commit 94fcbe5daf
9 changed files with 61 additions and 29 deletions

View File

@@ -24,6 +24,7 @@ Result(i32) EncryptedSocketTCP_recv(EncryptedSocketTCP* ptr,
{
Deferral(4);
try(i32 received_size, i, socket_recv(ptr->sock, encrypted_buf, flags));
//TODO: return error if WaitAll flag was set and socket closed before filling the buffer
//TODO: return something when received_size == 0 (socket has been closed)
encrypted_buf.size = received_size;
try(i32 decrypted_size, u, AESStreamDecryptor_decrypt(&ptr->dec, encrypted_buf, decrypted_buf));

View File

@@ -9,6 +9,6 @@ Result(void) ClientHandshake_tryConstruct(ClientHandshake* ptr, Array(u8) sessio
}
void ServerHandshake_construct(ServerHandshake* ptr, u64 session_id){
PacketHeader_construct(&ptr->header, PROTOCOL_VERSION, PacketType_ClientHandshake, sizeof(session_id));
PacketHeader_construct(&ptr->header, PROTOCOL_VERSION, PacketType_ServerHandshake, sizeof(session_id));
ptr->session_id = session_id;
}