27 #include <openssl/ssl.h>
28 #include <openssl/err.h>
49 this->max_fds = sysconf(_SC_OPEN_MAX);
50 if (this->max_fds <= 10) {
58 this->
logger = va_arg(* params, Logger);
59 this->worker = va_arg(* params,
void *);
60 port = va_arg(* params,
int);
61 backlog = va_arg(* params,
unsigned int);
65 "accept up to %zu connections",
68 this->fds =
memCalloc(
sizeof(
struct pollfd), this->max_fds);
71 this->sock =
new(Sock, this->
logger, port);
74 this->sockSSL =
new(Sock, this->
logger, port+1);
78 OpenSSL_add_all_algorithms();
79 SSL_load_error_strings();
80 this->ctx = SSL_CTX_new(SSLv23_server_method());
81 SSL_CTX_set_cipher_list(
83 "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS");
84 SSL_CTX_use_certificate_file(
86 CONFIGDIR
"/taskrambler.crt",
89 SSL_CTX_use_RSAPrivateKey_file(
91 CONFIGDIR
"/taskrambler.pem",
97 (this->fds)[0].fd = this->sock->handle;
98 (this->fds)[0].events = POLLIN;
99 (this->fds)[1].fd = this->sockSSL->handle;
100 (this->fds)[1].events = POLLIN;
113 for (i=0; i<this->nfds; i++) {
114 if (this->sock->handle != (this->fds)[i].fd &&
115 this->sockSSL->handle != (this->fds)[i].fd) {
124 delete(this->sockSSL);
126 SSL_CTX_free(this->ctx);
CREATE_CLASS(Server, NULL, IFACE(Class))
void socketListen(Sock this, int backlog)
void socketNonblock(Sock this)
void loggerLog(void *, logger_level, const char *const,...)
static int serverCtor(void *_this, va_list *params)
void * memCalloc(size_t, size_t)
void serverCloseConn(Server, unsigned int)
INIT_IFACE(Class, serverCtor, serverDtor, NULL)
static void serverDtor(void *_this)