#pragma once #include "tcp-chat/client.h" #include "cryptography/AES.h" #include "cryptography/RSA.h" #include "network/encrypted_sockets.h" typedef struct ServerConnection ServerConnection; typedef struct Client { str username; Array(u8) user_data_key; ServerConnection* conn; } Client; typedef struct ServerConnection { Client* client; EndpointIPv4 server_end; br_rsa_public_key server_pk; RSAEncryptor rsa_enc; Array(u8) token; Array(u8) session_key; EncryptedSocketTCP sock; i64 session_id; i64 user_id; } ServerConnection; /// @param server_addr_cstr /// @param server_pk_base64 public key encoded by `RSA_serializePublicKey_base64()` Result(ServerConnection*) ServerConnection_open(Client* client, cstr server_addr_cstr, cstr server_pk_base64); void ServerConnection_close(ServerConnection* conn); /// @param out_str heap-allocated string Result(void) ServerConnection_requestServerName(ServerConnection* conn, str* out_str); /// @param out_str heap-allocated string Result(void) ServerConnection_requestServerDescription(ServerConnection* conn, str* out_str);