Enhance server ssl configuration

- Added SSL certificate and key paths to ServerConfig structure.
- Updated init_config function to initialize new SSL paths.
- Formated code for better readability.
This commit is contained in:
2025-10-05 17:35:00 +00:00
parent 46b653efe0
commit 72df6a73fc
13 changed files with 1420 additions and 1000 deletions

View File

@@ -7,14 +7,15 @@
// WebSocket opcodes
#define WS_OPCODE_CONTINUATION 0x0
#define WS_OPCODE_TEXT 0x1
#define WS_OPCODE_BINARY 0x2
#define WS_OPCODE_CLOSE 0x8
#define WS_OPCODE_PING 0x9
#define WS_OPCODE_PONG 0xA
#define WS_OPCODE_TEXT 0x1
#define WS_OPCODE_BINARY 0x2
#define WS_OPCODE_CLOSE 0x8
#define WS_OPCODE_PING 0x9
#define WS_OPCODE_PONG 0xA
// WebSocket frame header structure
typedef struct {
typedef struct
{
uint8_t fin;
uint8_t opcode;
uint8_t mask;
@@ -23,7 +24,8 @@ typedef struct {
} ws_frame_header_t;
// WebSocket connection context
typedef struct {
typedef struct
{
int socket_fd;
SSL *ssl;
bool is_ssl;
@@ -41,7 +43,7 @@ int ws_send_pong(ws_connection_t *conn, const uint8_t *payload, size_t payload_l
void ws_close_connection(ws_connection_t *conn, uint16_t status_code);
// Helper functions
char* ws_generate_accept_key(const char *client_key);
char *ws_generate_accept_key(const char *client_key);
bool ws_is_valid_utf8(const uint8_t *data, size_t len);
#endif