fixed bugs in server and moved token hash calculation to client

This commit is contained in:
2025-11-21 21:22:53 +05:00
parent baca2fb4d3
commit 0abee3f7df
20 changed files with 161 additions and 156 deletions

View File

@@ -9,18 +9,19 @@ typedef struct ServerConnection ServerConnection;
typedef struct Client {
str username;
Array(u8) user_data_key;
Array(u8) token;
ServerConnection* server_connection;
ServerConnection* conn;
} Client;
typedef struct ServerConnection {
Client* client;
EndpointIPv4 server_end;
br_rsa_public_key server_pk;
RSAEncryptor rsa_enc;
u64 session_id;
Array(u8) token;
Array(u8) session_key;
EncryptedSocketTCP sock;
u64 session_id;
str server_name;
str server_description;
u64 user_id;
@@ -28,10 +29,13 @@ typedef struct ServerConnection {
/// @param server_addr_cstr
/// @param server_pk_base64 public key encoded by `RSA_serializePublicKey_base64()`
Result(ServerConnection*) ServerConnection_open(cstr server_addr_cstr, cstr server_pk_base64);
void ServerConnection_close(ServerConnection* conn);
Result(ServerConnection*) ServerConnection_open(Client* client,
cstr server_addr_cstr, cstr server_pk_base64);
void ServerConnection_close(ServerConnection* conn);
/// updates conn->server_name
Result(void) ServerConnection_requestServerName(ServerConnection* conn);
/// updates conn->server_description
Result(void) ServerConnection_requestServerDescription(ServerConnection* conn);