ess ess ell

This commit is contained in:
malloc 2019-02-07 15:26:43 -06:00
parent aede155430
commit cd267454c2
5 changed files with 56 additions and 2 deletions

View file

@ -27,10 +27,16 @@
#endif
#include <stdint.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "util/ipaddr.h"
#include "util/thread.h"
#define GLV_TCP_FLAG_TYPE 1
#define GLV_TCP_FLAG_NBIO 2
#define GLV_TCP_FLAG_TLS 2
#define GLV_TCP_FLAG_NBIO 4
#define GLV_TCP_RECV_APPEND 1
#define GLV_TCP_RECV_BLOCK 2
@ -41,7 +47,7 @@ typedef struct {
uint32_t flags;
} glv_tcp_t;
glv_tcp_t* glv_tcp_create_server();
glv_tcp_t* glv_tcp_create_server(uint16_t port);
glv_tcp_t* glv_tcp_create_client();
int glv_tcp_send(glv_tcp_t* sock, const char* data, unsigned int length);

View file

@ -1,6 +1,8 @@
#ifndef _WIN32
#include "tcp.h"
glv_tcp_t* glv_tcp_create_server(uint16_t port) {
}
#endif

35
src/sock/tcp_ssl.c Normal file
View file

@ -0,0 +1,35 @@
#include "tcp.h"
struct {
SSL_CTX* server;
glv_mutex_t server_mtx;
SSL_CTX* client;
glv_mutex_t client_mtx;
} _ssl_ctx;
static int ssl_init() {
static int is_inited = 0;
if(is_inited)
return 1;
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
_ssl_ctx.server = SSL_CTX_new(SSLv23_server_method());
if(!_ssl_ctx.server)
return 0;
_ssl_ctx.client = SSL_CTX_new(SSLv23_client_method());
if(!_ssl_ctx.client)
return 0;
SSL_CTX_set_ecdh_auto(_ssl_ctx.server, 1);
SSL_CTX_set_ecdh_auto(_ssl_ctx.client, 1);
int success = 0;
success |= SSL_CTX_use_certificate_file(
_ssl_ctx.server,
);
}

5
src/util/ini.c Normal file
View file

@ -0,0 +1,5 @@
//
// Created by alec on 2/7/2019.
//
#include "ini.h"

6
src/util/ini.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef GLV_UTIL_INI_H
#define GLV_UTIL_INI_H
#endif