diff -r 545010bc5e71 -r 22eca559aded src/server/daemon/httplistener.h --- a/src/server/daemon/httplistener.h Sun Nov 20 12:43:44 2022 +0100 +++ b/src/server/daemon/httplistener.h Sat Nov 26 17:07:08 2022 +0100 @@ -47,6 +47,8 @@ typedef struct _listener_config ListenerConfig; typedef struct _http_ssl HttpSSL; +typedef struct _ws_socket WSSocket; + @@ -56,18 +58,18 @@ }; struct _listener_config { ServerConfiguration *cfg; - cxmutstr name; - cxmutstr vs; - cxmutstr threadpool; + cxmutstr name; + cxmutstr vs; + cxmutstr threadpool; char *address; int port; int nacceptors; WSBool blockingio; WSBool ssl; - cxstring certfile; - cxstring privkeyfile; - cxstring chainfile; - cxstring disable_proto; + cxstring certfile; + cxstring privkeyfile; + cxstring chainfile; + cxstring disable_proto; }; struct _acceptor { @@ -81,8 +83,8 @@ cxmutstr name; union vs default_vs; int port; - int server_socket; - int server_socket6; + WSSocket *server_socket; + WSSocket *server_socket6; SessionHandler *session_handler; threadpool_t *threadpool; HttpListener *next; @@ -95,18 +97,33 @@ }; struct _http_ssl { + /* unsigned char *cert; size_t certlen; unsigned char *privkey; size_t privkeylen; unsigned char *chain; size_t chainlen; + */ SSL_CTX *sslctx; // TODO: ssl/tls cipher, ... config }; +struct _ws_socket { + int socket; + WSBool listening; + HttpSSL *ssl; + uint32_t ref; // reference counter +}; + +/* + * global listener init function + * must be called before any other listener initialization + */ +int http_listener_global_init(void); + int start_all_listener(); HttpListener* http_listener_create(ListenerConfig *conf); @@ -123,8 +140,13 @@ void acceptor_start(Acceptor *a); +void acceptor_shutdown(Acceptor *a); + void* acceptor_thread(Acceptor *a); +void wssocket_ref(WSSocket *ws); +void wssocket_unref(WSSocket *ws); + #ifdef __cplusplus }