#ifndef HTTPLISTENER_H
#define HTTPLISTENER_H
#include "sessionhandler.h"
#include "threadpools.h"
#include "config.h"
#include "../util/systems.h"
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _acceptor Acceptor;
typedef struct _listener_config ListenerConfig;
typedef struct _http_ssl HttpSSL;
union vs {
VirtualServer *vs;
char *vs_name;
};
struct _listener_config {
ServerConfiguration *cfg;
sstr_t name;
sstr_t vs;
sstr_t threadpool;
char *address;
int port;
int nacceptors;
WSBool blockingio;
WSBool ssl;
sstr_t certfile;
sstr_t privkeyfile;
sstr_t chainfile;
sstr_t disable_proto;
};
struct _acceptor {
pthread_t tid;
HttpListener *listener;
};
struct _http_listener {
ServerConfiguration *cfg;
sstr_t name;
union vs default_vs;
int port;
int server_socket;
SessionHandler *session_handler;
threadpool_t *threadpool;
HttpListener *next;
Acceptor **acceptors;
int nacceptors;
int running;
HttpSSL *ssl;
uint32_t ref;
};
struct _http_ssl {
unsigned char *cert;
size_t certlen;
unsigned char *privkey;
size_t privkeylen;
unsigned char *chain;
size_t chainlen;
SSL_CTX *sslctx;
};
int start_all_listener();
HttpListener* http_listener_create(ListenerConfig *conf);
HttpListener* http_listener_new(ListenerConfig *conf);
int http_listener_start(HttpListener *listener);
void http_listener_ref(HttpListener *listener);
void http_listener_unref(HttpListener *listener);
Acceptor* acceptor_new(HttpListener *listener);
void acceptor_start(Acceptor *a);
void* acceptor_thread(Acceptor *a);
#ifdef __cplusplus
}
#endif
#endif