diff options
author | Test_User <hax@andrewyu.org> | 2024-06-18 14:25:16 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2024-06-18 14:25:16 -0400 |
commit | 9f5d2e74e61cbc112d6e71176f4389f0be2c4f9f (patch) | |
tree | 8d65cc6f2c040d5c22406d1c4632bc0455768222 | |
parent | 03c8ff39bcb15bf094fcf7af699b6fedc5b38327 (diff) | |
download | haxircd-9f5d2e74e61cbc112d6e71176f4389f0be2c4f9f.tar.gz haxircd-9f5d2e74e61cbc112d6e71176f4389f0be2c4f9f.zip |
Network relocations, and in-progress buffered networking code
-rw-r--r-- | Makefile | 55 | ||||
-rw-r--r-- | config.h | 8 | ||||
-rw-r--r-- | general_network.c | 19 | ||||
-rw-r--r-- | general_network.h | 5 | ||||
-rw-r--r-- | networks/gnutls.c (renamed from gnutls_network.c) | 10 | ||||
-rw-r--r-- | networks/gnutls.h (renamed from gnutls_network.h) | 4 | ||||
-rw-r--r-- | networks/openssl.c (renamed from openssl_network.c) | 8 | ||||
-rw-r--r-- | networks/openssl.h (renamed from openssl_network.h) | 4 | ||||
-rw-r--r-- | networks/plaintext.c (renamed from plaintext_network.c) | 8 | ||||
-rw-r--r-- | networks/plaintext.h (renamed from plaintext_network.h) | 4 | ||||
-rw-r--r-- | networks/plaintext_buffered.c | 288 | ||||
-rw-r--r-- | networks/plaintext_buffered.h | 45 | ||||
-rw-r--r-- | real_main.c | 6 | ||||
-rw-r--r-- | server_network.c | 14 |
14 files changed, 443 insertions, 35 deletions
@@ -39,6 +39,8 @@ LDFLAGS = -lpthread printf '%s\n' 'LAST_GNUTLS_SERVER = $(GNUTLS_SERVER)' >> .makeopts printf '%s\n' 'LAST_OPENSSL_CLIENT = $(OPENSSL_CLIENT)' >> .makeopts printf '%s\n' 'LAST_OPENSSL_SERVER = $(OPENSSL_SERVER)' >> .makeopts + printf '%s\n' 'LAST_PLAINTEXT_BUFFERED_CLIENT = $(PLAINTEXT_BUFFERED_CLIENT)' >> .makeopts + printf '%s\n' 'LAST_PLAINTEXT_BUFFERED_SERVER = $(PLAINTEXT_BUFFERED_SERVER)' >> .makeopts printf '%s\n' 'LAST_INSPIRCD2_PROTOCOL = $(INSPIRCD2_PROTOCOL)' >> .makeopts printf '%s\n' 'LAST_INSPIRCD3_PROTOCOL = $(INSPIRCD3_PROTOCOL)' >> .makeopts printf '%s\n' 'LAST_HAXSERV_PSEUDOCLIENT = $(HAXSERV_PSEUDOCLIENT)' >> .makeopts @@ -102,6 +104,22 @@ else OPENSSL_SERVER = $(LAST_OPENSSL_SERVER) endif +ifneq ($(PLAINTEXT_CLIENT),) +ifneq ($(PLAINTEXT_CLIENT),$(LAST_PLAINTEXT_CLIENT)) +rebuild = 1 +endif +else +PLAINTEXT_CLIENT = $(LAST_PLAINTEXT_CLIENT) +endif + +ifneq ($(PLAINTEXT_BUFFERED_SERVER),) +ifneq ($(PLAINTEXT_BUFFERED_SERVER),$(LAST_PLAINTEXT_BUFFERED_SERVER)) +rebuild = 1 +endif +else +PLAINTEXT_BUFFERED_SERVER = $(LAST_PLAINTEXT_BUFFERED_SERVER) +endif + ifneq ($(INSPIRCD2_PROTOCOL),) ifneq ($(INSPIRCD2_PROTOCOL),$(LAST_INSPIRCD2_PROTOCOL)) rebuild = 1 @@ -209,6 +227,18 @@ USE_SERVER = 1 USE_OPENSSL = 1 endif +ifeq ($(PLAINTEXT_BUFFERED_CLIENT),1) +CFLAGS += -DUSE_PLAINTEXT_BUFFERED_CLIENT +USE_CLIENT = 1 +USE_PLAINTEXT_BUFFERED = 1 +endif + +ifeq ($(PLAINTEXT_BUFFERED_SERVER),1) +CFLAGS += -DUSE_PLAINTEXT_BUFFERED_SERVER +USE_SERVER = 1 +USE_PLAINTEXT_BUFFERED = 1 +endif + ifeq ($(INSPIRCD2_PROTOCOL),1) @@ -247,22 +277,27 @@ CFLAGS += -DUSE_SERVER endif ifeq ($(USE_PLAINTEXT),1) -OFILES += plaintext_network.o +OFILES += networks/plaintext.o CFLAGS += -DUSE_PLAINTEXT endif ifeq ($(USE_GNUTLS),1) -OFILES += gnutls_network.o +OFILES += networks/gnutls.o CFLAGS += -DUSE_GNUTLS $(shell pkg-config gnutls --cflags) LDFLAGS += $(shell pkg-config gnutls --libs) endif ifeq ($(USE_OPENSSL),1) -OFILES += openssl_network.o +OFILES += networks/openssl.o CFLAGS += -DUSE_OPENSSL $(shell pkg-config openssl --cflags) LDFLAGS += $(shell pkg-config openssl --libs) endif +ifeq ($(USE_PLAINTEXT_BUFFERED),1) +OFILES += networks/plaintext_buffered.o +CFLAGS += -DUSE_PLAINTEXT_BUFFERED +endif + ifeq ($(USE_PROTOCOLS),1) @@ -328,15 +363,19 @@ $(call DEPS,protocols,o) $(call DEPS,table,o) ifeq ($(USE_PLAINTEXT),1) -$(call DEPS,plaintext_network,o) +$(call DEPS,networks/plaintext,o) endif ifeq ($(USE_GNUTLS),1) -$(call DEPS,gnutls_network,o) +$(call DEPS,networks/gnutls,o) endif ifeq ($(USE_OPENSSL),1) -$(call DEPS,openssl_network,o) +$(call DEPS,networks/openssl,o) +endif + +ifeq ($(USE_PLAINTEXT_BUFFERED),1) +$(call DEPS,networks/plaintext_buffered,o) endif ifeq ($(USE_CLIENT),1) @@ -368,4 +407,6 @@ $(call DEPS,pseudoclients/haxserv,so) endif clean: - $(RM) HaxIRCd *.o *.so protocols/*.o protocols/*.so pseudoclients/*.o pseudoclients/*.so + $(RM) HaxIRCd + for file in `find . -name '*.so'`; do $(RM) $$file; done + for file in `find . -name '*.o'`; do $(RM) $$file; done @@ -33,6 +33,10 @@ #include "general_network.h" #include "protocols.h" +// #define K 1024 +// #define M (1024 * K) +// #define G (1024 * M) + #ifdef USE_SERVER struct server_config { struct string name; // = STRING("hax.example.org"), @@ -76,6 +80,10 @@ extern char *OPENSSL_CERT_PATH; // = "/etc/keys/crt.pem", or 0 extern char *OPENSSL_KEY_PATH; // = "/etc/keys/key.pem", or 0 #endif +#ifdef USE_PLAINTEXT_BUFFERED +extern size_t PLAINTEXT_BUFFERED_LEN; // = 1 M +#endif + #ifdef USE_SERVER extern unsigned short SERVER_PORTS[NUM_NET_TYPES][NUM_PROTOCOLS]; // = {7000, ...}; extern size_t SERVER_LISTEN[NUM_NET_TYPES][NUM_PROTOCOLS]; // = {16, ...}; diff --git a/general_network.c b/general_network.c index 4436643..a400a5a 100644 --- a/general_network.c +++ b/general_network.c @@ -41,13 +41,16 @@ #include "haxstring_utils.h" #ifdef USE_PLAINTEXT -#include "plaintext_network.h" +#include "networks/plaintext.h" #endif #ifdef USE_GNUTLS -#include "gnutls_network.h" +#include "networks/gnutls.h" #endif #ifdef USE_OPENSSL -#include "openssl_network.h" +#include "networks/openssl.h" +#endif +#ifdef USE_PLAINTEXT_BUFFERED +#include "networks/plaintext_buffered.h" #endif #ifdef USE_PROTOCOLS @@ -102,6 +105,16 @@ struct network networks[NUM_NET_TYPES] = { .close = plaintext_close, }, #endif +#ifdef USE_PLAINTEXT_BUFFERED + [NET_TYPE_PLAINTEXT_BUFFERED] = { + .send = plaintext_buffered_send, + .recv = plaintext_buffered_recv, + .connect = plaintext_buffered_connect, + .accept = plaintext_buffered_accept, + .shutdown = plaintext_buffered_shutdown, + .close = plaintext_buffered_close, + }, +#endif #ifdef USE_GNUTLS [NET_TYPE_GNUTLS] = { .send = gnutls_send, diff --git a/general_network.h b/general_network.h index 5a83b18..dd9b692 100644 --- a/general_network.h +++ b/general_network.h @@ -157,8 +157,11 @@ extern char casemap[UCHAR_MAX+1]; #ifdef USE_OPENSSL #define NET_TYPE_OPENSSL 2 #endif +#ifdef USE_PLAINTEXT_BUFFERED +#define NET_TYPE_PLAINTEXT_BUFFERED 3 +#endif -#define NUM_NET_TYPES 3 +#define NUM_NET_TYPES 4 #define MODE_TYPE_UNKNOWN 0 #define MODE_TYPE_NOARGS 1 diff --git a/gnutls_network.c b/networks/gnutls.c index 659d934..c5a4122 100644 --- a/gnutls_network.c +++ b/networks/gnutls.c @@ -37,11 +37,11 @@ #include <sys/socket.h> #include <unistd.h> -#include "config.h" -#include "general_network.h" -#include "gnutls_network.h" -#include "main.h" -#include "mutex.h" +#include "../config.h" +#include "../general_network.h" +#include "../main.h" +#include "../mutex.h" +#include "gnutls.h" struct gnutls_handle { gnutls_session_t session; diff --git a/gnutls_network.h b/networks/gnutls.h index f4f4358..51c7362 100644 --- a/gnutls_network.h +++ b/networks/gnutls.h @@ -30,8 +30,8 @@ #include <stddef.h> -#include "haxstring.h" -#include "general_network.h" +#include "../haxstring.h" +#include "../general_network.h" int init_gnutls_network(void); diff --git a/openssl_network.c b/networks/openssl.c index b8bd462..fdfd602 100644 --- a/openssl_network.c +++ b/networks/openssl.c @@ -35,10 +35,10 @@ #include <pthread.h> #include <unistd.h> -#include "config.h" -#include "main.h" -#include "mutex.h" -#include "openssl_network.h" +#include "../config.h" +#include "../main.h" +#include "../mutex.h" +#include "openssl.h" struct openssl_handle { SSL *ssl; diff --git a/openssl_network.h b/networks/openssl.h index 3cb940a..8c032f7 100644 --- a/openssl_network.h +++ b/networks/openssl.h @@ -30,8 +30,8 @@ #include <stddef.h> -#include "haxstring.h" -#include "general_network.h" +#include "../haxstring.h" +#include "../general_network.h" int init_openssl_network(void); diff --git a/plaintext_network.c b/networks/plaintext.c index 38348af..4279f8c 100644 --- a/plaintext_network.c +++ b/networks/plaintext.c @@ -35,10 +35,10 @@ #include <sys/types.h> #include <unistd.h> -#include "config.h" -#include "general_network.h" -#include "haxstring.h" -#include "plaintext_network.h" +#include "../config.h" +#include "../general_network.h" +#include "../haxstring.h" +#include "plaintext.h" int init_plaintext_network(void) { return 0; diff --git a/plaintext_network.h b/networks/plaintext.h index c34c7e1..2cc390a 100644 --- a/plaintext_network.h +++ b/networks/plaintext.h @@ -30,8 +30,8 @@ #include <stddef.h> -#include "haxstring.h" -#include "general_network.h" +#include "../haxstring.h" +#include "../general_network.h" int init_plaintext_network(void); diff --git a/networks/plaintext_buffered.c b/networks/plaintext_buffered.c new file mode 100644 index 0000000..97a6672 --- /dev/null +++ b/networks/plaintext_buffered.c @@ -0,0 +1,288 @@ +// One of the code files for HaxServ +// +// Written by: Test_User <hax@andrewyu.org> +// +// This is free and unencumbered software released into the public +// domain. +// +// Anyone is free to copy, modify, publish, use, compile, sell, or +// distribute this software, either in source code form or as a compiled +// binary, for any purpose, commercial or non-commercial, and by any +// means. +// +// In jurisdictions that recognize copyright laws, the author or authors +// of this software dedicate any and all copyright interest in the +// software to the public domain. We make this dedication for the benefit +// of the public at large and to the detriment of our heirs and +// successors. We intend this dedication to be an overt act of +// relinquishment in perpetuity of all present and future rights to this +// software under copyright law. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include <arpa/inet.h> +#include <errno.h> +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> + +#include "../config.h" +#include "../general_network.h" +#include "../haxstring.h" +#include "../main.h" +#include "../mutex.h" +#include "plaintext_buffered.h" + +struct plaintext_buffered_handle { + MUTEX_TYPE mutex; + int fd; + char valid; + char close; + char *buffer; + size_t write_buffer_index; + size_t buffer_len; +}; + +void * plaintext_buffered_send_thread(void *handle) { + struct plaintext_buffered_handle *info = handle; + + size_t read_buffer_index = 0; + mutex_lock(&(info->mutex)); + while (1) { + size_t len; + len = info->buffer_len; + mutex_unlock(&(info->mutex)); + if (read_buffer_index + len > PLAINTEXT_BUFFERED_LEN) + len = PLAINTEXT_BUFFERED_LEN - read_buffer_index; + + ssize_t res; + do { + res = send(info->fd, &(info->buffer[read_buffer_index]), len, 0); + } while (res == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK || errno == ETIMEDOUT)); + if (res < 0) + goto plaintext_buffered_send_thread_error; + + read_buffer_index += (size_t)res; + if (read_buffer_index >= PLAINTEXT_BUFFERED_LEN) + read_buffer_index = 0; + + mutex_lock(&(info->mutex)); + + info->buffer_len -= (size_t)res; + } + + plaintext_buffered_send_thread_error: + // TODO: Sane solution that works with ptread mutexes + while (1) { + mutex_lock(&(info->mutex)); + if (info->close) { + close(info->fd); + free(info->buffer); + mutex_unlock(&(info->mutex)); + mutex_destroy(&(info->mutex)); + free(info); + return 0; + } + mutex_unlock(&(info->mutex)); + } + + return 0; +} + +int init_plaintext_buffered_network(void) { + return 0; +} + +int plaintext_buffered_send(void *handle, struct string msg) { + struct plaintext_buffered_handle *plaintext_handle = handle; + while (msg.len > 0) { + size_t len = msg.len; + if (len > PLAINTEXT_BUFFERED_LEN - plaintext_handle->write_buffer_index) + len = PLAINTEXT_BUFFERED_LEN - plaintext_handle->write_buffer_index; + mutex_lock(&(plaintext_handle->mutex)); + if (!plaintext_handle->valid) + return 1; + if (len > PLAINTEXT_BUFFERED_LEN - plaintext_handle->buffer_len) + len = PLAINTEXT_BUFFERED_LEN - plaintext_handle->buffer_len; + memcpy(&(plaintext_handle->buffer[plaintext_handle->write_buffer_index]), msg.data, len); + plaintext_handle->write_buffer_index += len; + if (plaintext_handle->write_buffer_index >= PLAINTEXT_BUFFERED_LEN) + plaintext_handle->write_buffer_index = 0; + plaintext_handle->buffer_len += len; + mutex_unlock(&(plaintext_handle->mutex)); + msg.len -= len; + } + + return 0; +} + +size_t plaintext_buffered_recv(void *handle, char *data, size_t len, char *err) { + struct plaintext_buffered_handle *plaintext_handle = handle; + ssize_t res; + do { + res = recv(plaintext_handle->fd, data, len, 0); + } while (res == -1 && (errno == EINTR)); + + if (res == -1) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { + *err = 1; + } else { + *err = 3; + } + return 0; + } else if (res == 0) { + *err = 2; + return 0; + } + *err = 0; + + return (size_t)res; +} + +int plaintext_buffered_connect(void **handle, struct string address, struct string port, struct string *addr_out) { + struct sockaddr sockaddr; + if (resolve(address, port, &sockaddr) != 0) + return -1; + + int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (fd == -1) + return -1; + + { + struct timeval timeout = { + .tv_sec = PING_INTERVAL, + .tv_usec = 0, + }; + + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); + } + + int res; + do { + res = connect(fd, &sockaddr, sizeof(sockaddr)); + } while (res < 0 && errno == EINTR); + if (res < 0) + goto plaintext_buffered_connect_close; + + struct plaintext_buffered_handle *plaintext_handle; + plaintext_handle = malloc(sizeof(*plaintext_handle)); + if (!handle) + goto plaintext_buffered_connect_close; + *handle = plaintext_handle; + plaintext_handle->valid = 1; + plaintext_handle->fd = fd; + + addr_out->data = malloc(sizeof(sockaddr)); + if (!addr_out->data) + goto plaintext_buffered_connect_free_handle; + memcpy(addr_out->data, &sockaddr, sizeof(sockaddr)); + addr_out->len = sizeof(sockaddr); + + plaintext_handle->buffer = malloc(PLAINTEXT_BUFFERED_LEN); + if (!plaintext_handle->buffer) + goto plaintext_buffered_connect_free_addr; + plaintext_handle->write_buffer_index = 0; + plaintext_handle->buffer_len = 0; + + if (mutex_init(&(plaintext_handle->mutex)) != 0) + goto plaintext_buffered_connect_free_buffer; + + pthread_t trash; + if (pthread_create(&trash, &pthread_attr, plaintext_buffered_send_thread, plaintext_handle) != 0) + goto plaintext_buffered_connect_destroy_mutex; + + return fd; + + plaintext_buffered_connect_destroy_mutex: + mutex_destroy(&(plaintext_handle->mutex)); + plaintext_buffered_connect_free_buffer: + free(plaintext_handle->buffer); + plaintext_buffered_connect_free_addr: + free(addr_out->data); + plaintext_buffered_connect_free_handle: + free(plaintext_handle); + plaintext_buffered_connect_close: + close(fd); + + return -1; +} + +int plaintext_buffered_accept(int listen_fd, void **handle, struct string *addr) { + struct sockaddr address; + socklen_t address_len = sizeof(address); + + int con_fd; + do { + con_fd = accept(listen_fd, &address, &address_len); + } while (con_fd == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK || errno == ENETDOWN || errno == EPROTO || errno == ENOPROTOOPT || errno == EHOSTDOWN || errno == ENONET || errno == EHOSTUNREACH || errno == EOPNOTSUPP || errno == ENETUNREACH)); + + if (con_fd == -1) + return -1; + + struct plaintext_buffered_handle *plaintext_handle = malloc(sizeof(*plaintext_handle)); + if (!plaintext_handle) + goto plaintext_buffered_accept_close; + *handle = plaintext_handle; + plaintext_handle->valid = 1; + plaintext_handle->close = 1; + plaintext_handle->fd = con_fd; + + addr->data = malloc(address_len); + if (addr->data == 0 && address_len != 0) + goto plaintext_buffered_accept_free_handle; + memcpy(addr->data, &address, address_len); + addr->len = address_len; + + + plaintext_handle->buffer = malloc(PLAINTEXT_BUFFERED_LEN); + if (!plaintext_handle->buffer) + goto plaintext_buffered_accept_free_addr; + plaintext_handle->write_buffer_index = 0; + plaintext_handle->buffer_len = 0; + + if (mutex_init(&(plaintext_handle->mutex)) != 0) + goto plaintext_buffered_accept_free_buffer; + + pthread_t trash; + if (pthread_create(&trash, &pthread_attr, plaintext_buffered_send_thread, plaintext_handle) != 0) + goto plaintext_buffered_accept_destroy_mutex; + + return con_fd; + + plaintext_buffered_accept_destroy_mutex: + mutex_destroy(&(plaintext_handle->mutex)); + plaintext_buffered_accept_free_buffer: + free(plaintext_handle->buffer); + plaintext_buffered_accept_free_addr: + free(addr->data); + plaintext_buffered_accept_free_handle: + free(plaintext_handle); + plaintext_buffered_accept_close: + close(con_fd); + + return -1; +} + +void plaintext_buffered_shutdown(void *handle) { + struct plaintext_buffered_handle *plaintext_handle = handle; + mutex_lock(&(plaintext_handle->mutex)); + plaintext_handle->valid = 0; + mutex_unlock(&(plaintext_handle->mutex)); + shutdown(plaintext_handle->fd, SHUT_RDWR); +} + +void plaintext_buffered_close(int fd, void *handle) { + struct plaintext_buffered_handle *plaintext_handle = handle; + mutex_lock(&(plaintext_handle->mutex)); + plaintext_handle->close = 1; + mutex_unlock(&(plaintext_handle->mutex)); +} diff --git a/networks/plaintext_buffered.h b/networks/plaintext_buffered.h new file mode 100644 index 0000000..dbe591f --- /dev/null +++ b/networks/plaintext_buffered.h @@ -0,0 +1,45 @@ +// One of the headers for HaxServ +// +// Written by: Test_User <hax@andrewyu.org> +// +// This is free and unencumbered software released into the public +// domain. +// +// Anyone is free to copy, modify, publish, use, compile, sell, or +// distribute this software, either in source code form or as a compiled +// binary, for any purpose, commercial or non-commercial, and by any +// means. +// +// In jurisdictions that recognize copyright laws, the author or authors +// of this software dedicate any and all copyright interest in the +// software to the public domain. We make this dedication for the benefit +// of the public at large and to the detriment of our heirs and +// successors. We intend this dedication to be an overt act of +// relinquishment in perpetuity of all present and future rights to this +// software under copyright law. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once + +#include <stddef.h> + +#include "../haxstring.h" +#include "../general_network.h" + +int init_plaintext_buffered_network(void); + +int plaintext_buffered_send(void *fd, struct string msg); +size_t plaintext_buffered_recv(void *fd, char *data, size_t len, char *err); + +int plaintext_buffered_connect(void **handle, struct string address, struct string port, struct string *addr_out); +int plaintext_buffered_accept(int listen_fd, void **handle, struct string *addr); + +void plaintext_buffered_shutdown(void *handle); +void plaintext_buffered_close(int fd, void *handle); diff --git a/real_main.c b/real_main.c index 2b6d71a..3990feb 100644 --- a/real_main.c +++ b/real_main.c @@ -35,13 +35,13 @@ #include "mutex.h" #ifdef USE_PLAINTEXT -#include "plaintext_network.h" +#include "networks/plaintext.h" #endif #ifdef USE_GNUTLS -#include "gnutls_network.h" +#include "networks/gnutls.h" #endif #ifdef USE_OPENSSL -#include "openssl_network.h" +#include "networks/openssl.h" #endif #ifdef USE_SERVER diff --git a/server_network.c b/server_network.c index a3f420a..dfbc6f6 100644 --- a/server_network.c +++ b/server_network.c @@ -40,10 +40,16 @@ #include "server_network.h" #ifdef USE_PLAINTEXT_SERVER -#include "plaintext_network.h" +#include "networks/plaintext.h" #endif #ifdef USE_GNUTLS_SERVER -#include "gnutls_network.h" +#include "networks/gnutls.h" +#endif +#ifdef USE_OPENSSL_SERVER +#include "networks/openssl.h" +#endif +#ifdef USE_PLAINTEXT_BUFFERED_SERVER +#include "networks/plaintext_buffered.h" #endif struct table server_config = {0}; @@ -76,6 +82,10 @@ int start_server_network(void) { if (start_server_network_threads(NET_TYPE_OPENSSL) != 0) return 1; #endif +#ifdef USE_PLAINTEXT_BUFFERED_SERVER + if (start_server_network_threads(NET_TYPE_PLAINTEXT_BUFFERED) != 0) + return 1; +#endif pthread_t trash; for (size_t i = 0; i < SERVER_CONFIG_LEN; i++) { |