ess ess ell
This commit is contained in:
parent
aede155430
commit
cd267454c2
5 changed files with 56 additions and 2 deletions
|
@ -27,10 +27,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <openssl/ssl.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
|
||||||
#include "util/ipaddr.h"
|
#include "util/ipaddr.h"
|
||||||
|
#include "util/thread.h"
|
||||||
|
|
||||||
#define GLV_TCP_FLAG_TYPE 1
|
#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_APPEND 1
|
||||||
#define GLV_TCP_RECV_BLOCK 2
|
#define GLV_TCP_RECV_BLOCK 2
|
||||||
|
@ -41,7 +47,7 @@ typedef struct {
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
} glv_tcp_t;
|
} 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();
|
glv_tcp_t* glv_tcp_create_client();
|
||||||
|
|
||||||
int glv_tcp_send(glv_tcp_t* sock, const char* data, unsigned int length);
|
int glv_tcp_send(glv_tcp_t* sock, const char* data, unsigned int length);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include "tcp.h"
|
#include "tcp.h"
|
||||||
|
|
||||||
|
glv_tcp_t* glv_tcp_create_server(uint16_t port) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
35
src/sock/tcp_ssl.c
Normal file
35
src/sock/tcp_ssl.c
Normal 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
5
src/util/ini.c
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
//
|
||||||
|
// Created by alec on 2/7/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ini.h"
|
6
src/util/ini.h
Normal file
6
src/util/ini.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef GLV_UTIL_INI_H
|
||||||
|
#define GLV_UTIL_INI_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Reference in a new issue