@@ -69,54 +69,64 @@ lws_protocols protocols[] = {
6969 .rx_buffer_size = 0
7070 },
7171#endif /* LIBWEBSOCKETS_FOUND */
72- { nullptr /* terminator */ }
72+ {
73+ .name = nullptr /* terminator */
74+ }
7375};
7476
7577/* * List of libwebsockets mounts. */
7678static lws_http_mount mounts[] = {
7779#ifdef WITH_API
7880 {
79- .mount_next = &mounts[1 ],
80- .mountpoint = " /api/v1" ,
81- .origin = " http-api" ,
82- .def = nullptr ,
83- .cgienv = nullptr ,
84- .cgi_timeout = 0 ,
85- .cache_max_age = 0 ,
86- .cache_reusable = 0 ,
87- .cache_revalidate = 0 ,
88- .cache_intermediaries = 0 ,
89- .origin_protocol = LWSMPRO_CALLBACK ,
90- .mountpoint_len = 7
81+ .mount_next = &mounts[1 ], /* linked-list "next" */
82+ .mountpoint = " /api/v1" , /* mountpoint URL */
83+ .origin = " http-api" , /* protocol */
84+ .def = nullptr ,
85+ .protocol = " http-api" ,
86+ .cgienv = nullptr ,
87+ .extra_mimetypes = nullptr ,
88+ .interpret = nullptr ,
89+ .cgi_timeout = 0 ,
90+ .cache_max_age = 0 ,
91+ .auth_mask = 0 ,
92+ .cache_reusable = 0 ,
93+ .cache_revalidate = 0 ,
94+ .cache_intermediaries = 0 ,
95+ .origin_protocol = LWSMPRO_CALLBACK , /* dynamic */
96+ .mountpoint_len = 7 /* char count */
9197 },
9298#endif /* WITH_API */
9399 {
94- .mount_next = nullptr ,
95- .mountpoint = " /" ,
96- .origin = nullptr ,
97- .def = " /index.html" ,
98- .cgienv = nullptr ,
99- .cgi_timeout = 0 ,
100- .cache_max_age = 0 ,
101- .cache_reusable = 0 ,
102- .cache_revalidate = 0 ,
100+ .mount_next = nullptr ,
101+ .mountpoint = " /" ,
102+ .origin = nullptr ,
103+ .def = " /index.html" ,
104+ .protocol = nullptr ,
105+ .cgienv = nullptr ,
106+ .extra_mimetypes = nullptr ,
107+ .interpret = nullptr ,
108+ .cgi_timeout = 0 ,
109+ .cache_max_age = 0 ,
110+ .auth_mask = 0 ,
111+ .cache_reusable = 0 ,
112+ .cache_revalidate = 0 ,
103113 .cache_intermediaries = 0 ,
104- .origin_protocol = LWSMPRO_FILE ,
105- .mountpoint_len = 1
114+ .origin_protocol = LWSMPRO_FILE ,
115+ .mountpoint_len = 1
106116 }
107117};
108118
109119/* * List of libwebsockets extensions. */
110120static const lws_extension extensions[] = {
111121 {
112- " permessage-deflate" ,
113- lws_extension_callback_pm_deflate,
114- " permessage-deflate"
122+ . name = " permessage-deflate" ,
123+ . callback = lws_extension_callback_pm_deflate,
124+ . client_offer = " permessage-deflate"
115125 },
116126 {
117- " deflate-frame" ,
118- lws_extension_callback_pm_deflate,
119- " deflate_frame"
127+ . name = " deflate-frame" ,
128+ . callback = lws_extension_callback_pm_deflate,
129+ . client_offer = " deflate_frame"
120130 },
121131 { nullptr /* terminator */ }
122132};
@@ -227,22 +237,22 @@ int Web::parse(json_t *cfg)
227237void Web::start ()
228238{
229239 /* Start server */
230- lws_context_creation_info ctx_info = {
231- .port = port,
232- .protocols = protocols,
233- .extensions = extensions,
234- .ssl_cert_filepath = ssl_cert.empty () ? nullptr : ssl_cert.c_str (),
235- .ssl_private_key_filepath = ssl_private_key.empty () ? nullptr : ssl_private_key.c_str (),
236- .gid = -1 ,
237- .uid = -1 ,
238- .options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS | LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT ,
239- .user = (void *) this ,
240+ lws_context_creation_info ctx_info;
241+
242+ ctx_info.port = port;
243+ ctx_info.protocols = protocols;
244+ ctx_info.extensions = extensions;
245+ ctx_info.ssl_cert_filepath = ssl_cert.empty () ? nullptr : ssl_cert.c_str ();
246+ ctx_info.ssl_private_key_filepath = ssl_private_key.empty () ? nullptr : ssl_private_key.c_str ();
247+ ctx_info.gid = -1 ;
248+ ctx_info.uid = -1 ;
249+ ctx_info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS | LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT ;
250+ ctx_info.user = (void *) this ;
240251#if LWS_LIBRARY_VERSION_NUMBER <= 3000000
241- // https://github.com/warmcat/libwebsockets/issues/1249
242- .max_http_header_pool = 1024 ,
252+ // https://github.com/warmcat/libwebsockets/issues/1249
253+ ctx_info .max_http_header_pool = 1024 ;
243254 #endif
244- .mounts = mounts
245- };
255+ ctx_info.mounts = mounts;
246256
247257 logger->info (" Starting sub-system: htdocs={}" , htdocs.c_str ());
248258
@@ -262,7 +272,7 @@ void Web::start()
262272 logger->warn (" WebSocket: failed to setup vhost. Trying another port: {}" , ctx_info.port );
263273 }
264274
265- if (vhost == NULL )
275+ if (vhost == nullptr )
266276 throw RuntimeError (" Failed to initialize virtual host" );
267277
268278 /* Start thread */
0 commit comments