src/server/daemon/httplistener.h

changeset 438
22eca559aded
parent 415
d938228c382e
child 440
d77b8f3e14e2
equal deleted inserted replaced
437:545010bc5e71 438:22eca559aded
45 /* HttpListener typedef in nsapi.h */ 45 /* HttpListener typedef in nsapi.h */
46 typedef struct _acceptor Acceptor; 46 typedef struct _acceptor Acceptor;
47 typedef struct _listener_config ListenerConfig; 47 typedef struct _listener_config ListenerConfig;
48 typedef struct _http_ssl HttpSSL; 48 typedef struct _http_ssl HttpSSL;
49 49
50 typedef struct _ws_socket WSSocket;
51
50 52
51 53
52 54
53 union vs { 55 union vs {
54 VirtualServer *vs; 56 VirtualServer *vs;
55 char *vs_name; 57 char *vs_name;
56 }; 58 };
57 struct _listener_config { 59 struct _listener_config {
58 ServerConfiguration *cfg; 60 ServerConfiguration *cfg;
59 cxmutstr name; 61 cxmutstr name;
60 cxmutstr vs; 62 cxmutstr vs;
61 cxmutstr threadpool; 63 cxmutstr threadpool;
62 char *address; 64 char *address;
63 int port; 65 int port;
64 int nacceptors; 66 int nacceptors;
65 WSBool blockingio; 67 WSBool blockingio;
66 WSBool ssl; 68 WSBool ssl;
67 cxstring certfile; 69 cxstring certfile;
68 cxstring privkeyfile; 70 cxstring privkeyfile;
69 cxstring chainfile; 71 cxstring chainfile;
70 cxstring disable_proto; 72 cxstring disable_proto;
71 }; 73 };
72 74
73 struct _acceptor { 75 struct _acceptor {
74 pthread_t tid; 76 pthread_t tid;
75 HttpListener *listener; 77 HttpListener *listener;
79 struct _http_listener { 81 struct _http_listener {
80 ServerConfiguration *cfg; 82 ServerConfiguration *cfg;
81 cxmutstr name; 83 cxmutstr name;
82 union vs default_vs; 84 union vs default_vs;
83 int port; 85 int port;
84 int server_socket; 86 WSSocket *server_socket;
85 int server_socket6; 87 WSSocket *server_socket6;
86 SessionHandler *session_handler; 88 SessionHandler *session_handler;
87 threadpool_t *threadpool; 89 threadpool_t *threadpool;
88 HttpListener *next; 90 HttpListener *next;
89 Acceptor **acceptors; 91 Acceptor **acceptors;
90 Acceptor **acceptors6; 92 Acceptor **acceptors6;
93 HttpSSL *ssl; 95 HttpSSL *ssl;
94 uint32_t ref; // reference counter 96 uint32_t ref; // reference counter
95 }; 97 };
96 98
97 struct _http_ssl { 99 struct _http_ssl {
100 /*
98 unsigned char *cert; 101 unsigned char *cert;
99 size_t certlen; 102 size_t certlen;
100 unsigned char *privkey; 103 unsigned char *privkey;
101 size_t privkeylen; 104 size_t privkeylen;
102 unsigned char *chain; 105 unsigned char *chain;
103 size_t chainlen; 106 size_t chainlen;
107 */
104 108
105 SSL_CTX *sslctx; 109 SSL_CTX *sslctx;
106 110
107 // TODO: ssl/tls cipher, ... config 111 // TODO: ssl/tls cipher, ... config
108 }; 112 };
113
114 struct _ws_socket {
115 int socket;
116 WSBool listening;
117 HttpSSL *ssl;
118 uint32_t ref; // reference counter
119 };
120
121 /*
122 * global listener init function
123 * must be called before any other listener initialization
124 */
125 int http_listener_global_init(void);
109 126
110 int start_all_listener(); 127 int start_all_listener();
111 128
112 HttpListener* http_listener_create(ListenerConfig *conf); 129 HttpListener* http_listener_create(ListenerConfig *conf);
113 130
121 138
122 Acceptor* acceptor_new(HttpListener *listener); 139 Acceptor* acceptor_new(HttpListener *listener);
123 140
124 void acceptor_start(Acceptor *a); 141 void acceptor_start(Acceptor *a);
125 142
143 void acceptor_shutdown(Acceptor *a);
144
126 void* acceptor_thread(Acceptor *a); 145 void* acceptor_thread(Acceptor *a);
146
147 void wssocket_ref(WSSocket *ws);
148 void wssocket_unref(WSSocket *ws);
127 149
128 150
129 #ifdef __cplusplus 151 #ifdef __cplusplus
130 } 152 }
131 #endif 153 #endif

mercurial