blob: 0931c8923505b8020c2a419f9cf8d09bb793cc22 [file] [log] [blame]
Andy Greena35c86f2013-01-31 10:16:44 +08001Changelog
2---------
3
Andy Green502130d2018-05-10 16:13:26 +08004 - CHANGE: REMOVED: lws_client_connect() and lws_client_connect_extended()
5 compatibility apis for lws_client_connect_via_info() have been marked as
6 deprecated for several versions and are now removed. Use
7 lws_client_connect_via_info() instead.
8
9
Andy Green1c08a962018-05-04 13:27:12 +080010v3.0.0
11======
12
13 - CHANGE: Clients used to call LWS_CALLBACK_CLOSED same as servers...
14 LWS_CALLBACK_CLIENT_CLOSED has been introduced and is called for clients
15 now.
16
17 - CHANGE: LWS_CALLBACK_CLIENT_CONNECTION_ERROR used to only be directed at
18 protocols[0]. However in many cases, the protocol to bind to was provided
19 at client connection info time and the wsi bound accordingly. In those
20 cases, CONNECTION_ERROR is directed at the bound protocol, not protcols[0]
21 any more.
22
23 - CHANGE: CMAKE: the following cmake defaults have changed with this version:
24
25 - LWS_WITH_ZIP_FOPS: now defaults OFF
26 - LWS_WITH_RANGES: now defaults OFF
27 - LWS_WITH_ZLIB: now defaults OFF
28 - LWS_WITHOUT_EXTENSIONS: now defaults ON
29
30 - CHANGE: REMOVED: lws_alloc_vfs_file() (read a file to malloc buffer)
31
32 - CHANGE: REMOVED: lws_read() (no longer useful outside of lws internals)
33
34 - CHANGE: REMOVED: ESP8266... ESP32 is now within the same price range and much
35 more performant
36
37 - CHANGE: soname bump... don't forget to `ldconfig`
38
39 - NEW: all event libraries support "foreign" loop integration where lws itself
40 if just a temporary user of the loop unrelated to the actual loop lifecycle.
41
42 See `minimal-http-server-eventlib-foreign` for example code demonstrating
43 this for all the event libraries.
44
45 Internal loop in lws is also supported and demonstrated by
46 `minimal-http-server-eventlib`.
47
48 - NEW: ws-over-h2 support. This is a new RFC-on-the-way supported by Chrome
49 and shortly firefox that allows ws connections to be multiplexed back to the
50 server on the same tcp + tls wrapper h2 connection that the html and scripts
51 came in on. This is hugely faster that discrete connections.
52
53 - NEW: UDP socket adoption and related event callbacks
54
55 - NEW: Multi-client connection binding, queuing and pipelining support.
56
57 Lws detects multiple client connections to the same server and port, and
58 optimizes how it handles them according to the server type and provided
59 flags. For http/1.0, all occur with individual parallel connections. For
60 http/1.1, you can enable keepalive pipelining, so the connections occur
61 sequentially on a single network connection. For http/2, they all occur
62 as parallel streams within a single h2 network connection.
63
64 See minimal-http-client-multi for example code.
65
66 - NEW: High resolution timer API for wsi, get a callback on your wsi with
67 LWS_CALLBACK_TIMER, set and reset the timer with lws_set_timer_usecs(wsi, us)
68 Actual resolution depends on event backend. Works with all backends, poll,
69 libuv, libevent, and libev.
70
71 - NEW: Protocols can arrange vhost-protocol instance specific callbacks with
72 second resolution using `lws_timed_callback_vh_protocol()`
73
74 - NEW: ACME client plugin for self-service TLS certificates
75
76 - NEW: RFC7517 JSON Web Keys RFC7638 JWK thumbprint, and RFC7515 JSON Web
77 signatures support
78
79 - NEW: lws_cancel_service() now provides a generic way to synchronize events
80 from other threads, which appear as a LWS_CALLBACK_EVENT_WAIT_CANCELLED
81 callback on all protocols. This is compatible with all the event libraries.
82
83 - NEW: support BSD poll() where changes to the poll wait while waiting are
84 undone.
85
86 - NEW: Introduce generic hash, hmac and RSA apis that operate the same
87 regardless of OpenSSL or mbedTLS tls backend
88
89 - NEW: Introduce X509 element query api that works the same regardless of
90 OpenSSL or mbedTLS tls backend
91
92 - NEW: Introduce over 30 "minimal examples" in ./minimal-examples... these
93 replace most of the old test servers
94
95 - test-echo -> minimal-ws-server-echo and minimal-ws-client-echo
96
97 - test-server-libuv / -libevent / -libev ->
98 minimal-https-server-eventlib / -eventlib-foreign / -eventlib-demos
99
100 - test-server-v2.0 -> folded into all the minimal servers
101
102 - test-server direct http serving -> minimal-http-server-dynamic
103
104 The minimal examples allow individual standalone build using their own
105 small CMakeLists.txt.
106
107 - NEW: lws now detects any back-to-back writes that did not go through the
108 event loop inbetween and reports them. This will flag any possibility of
109 failure rather than wait until the problem happens.
110
111 - NEW: CMake has LWS_WITH_DISTRO_RECOMMENDED to select features that are
112 appropriate for distros
113
114 - NEW: Optional vhost URL `error_document_404` if given causes a redirect there
115 instead of serve the default 404 page.
116
117 - NEW: lws_strncpy() wrapper guarantees NUL in copied string even if it was
118 truncated to fit.
119
120 - NEW: for client connections, local protocol binding name can be separated
121 from the ws subprotocol name if needed, using .local_protocol_name
122
123 - NEW: Automatic detection of time discontiguities
124
125 - NEW: Applies TCP_USER_TIMEOUT for Linux tcp keepalive where available
126
127 - QA: 1600 tests run on each commit in Travis CI, including almost all
128 Autobahn in client and server mode, various h2load tests, h2spec, attack.sh
129 the minimal example selftests and others.
130
131 - QA: fix small warnings introduced on gcc8.x (eg, Fedora 28)
132
133 - QA: Add most of -Wextra on gcc (-Wsign-compare, -Wignored-qualifiers,
134 -Wtype-limits, -Wuninitialized)
135
136 - QA: clean out warnings on windows
137
138 - QA: pass all 146 h2spec tests now on strict
139
140 - QA: introduce 35 selftests that operate different minimal examples against
141 each other and confirm the results.
142
143 - QA: LWS_WITH_MINIMAL_EXAMPLES allows mass build of all relevant minimal-
144 examples with the LWS build, for CI and to make all the example binaries
145 available from the lws build dir ./bin
146
147 - REFACTOR: the lws source directory layout in ./lib has been radically
148 improved, and there are now README.md files in selected subdirs with extra
149 documentation of interest to people working on lws itself.
150
151 - REFACTOR: pipelined transactions return to the event loop before starting the
152 next part.
153
154 - REFACTOR: TLS: replace all TLS library constants with generic LWS ones and
155 adapt all the TLS library code to translate to these common ones.
156
157 Isolated all the tls-related private stuff in `./lib/tls/private.h`, and all
158 the mbedTLS stuff in `./lib/tls/mbedtls` + openSSL stuff in
159 `./lib/tls/openssl`
160
161 - REFACTOR: the various kinds of wsi possible with lws have been extracted
162 from the main code and isolated into "roles" in `./lib/roles` which
163 communicate with the core code via an ops struct. Everything related to
164 ah is migrated to the http role.
165
166 wsi modes are eliminated and replaced by the ops pointer for the role the
167 wsi is performing. Generic states for wsi are available to control the
168 lifecycle using core code.
169
170 Adding new "roles" is now much easier with the changes and ops struct to
171 plug into.
172
173 - REFACTOR: reduce four different kinds of buffer management in lws into a
174 generic scatter-gather struct lws_buflist.
175
176 - REFACTOR: close notifications go through event loop
177
178
Andy Greenfcf5b2c2017-10-16 20:09:58 +0800179v2.4.0
180======
181
182 - HTTP/2 server support is now mature and usable! LWS_WITH_HTTP2=1 enables it.
183 Uses ALPN to serve HTTP/2, HTTP/1 and ws[s] connections all from the same
184 listen port seamlessly. (Requires ALPN-capable OpenSSL 1.1 or mbedTLS).
185
186 - LWS_WITH_MBEDTLS=1 at CMake now builds and works against mbedTLS instead of
187 OpenSSL. Most things work identically, although on common targets where
188 OpenSSL has acceleration, mbedTLS is many times slower in operation. However
189 it is a lot smaller codewise.
190
191 - Generic hash apis introduced that work the same on mbedTLS or OpenSSL backend
192
193 - LWS_WITH_PEER_LIMITS tracks IPs across all vhosts and allows restrictions on
194 both the number of simultaneous connections and wsi in use for any single IP
195
196 - lws_ring apis provide a generic single- or multi-tail ringbuffer... mirror
197 protocol now uses this. Features include ring elements may be sized to fit
198 structs in the ringbuffer, callback when no tail any longer needs an element
199 and it can be deleted, and zerocopy options to write new members directly
200 into the ringbuffer, and use the ringbuffer element by address too.
201
202 - abstract ssh 2 server plugin included, with both plugin and standalone
203 demos provided. You can bind the plugin to a vhost and also serve full-
204 strength ssh from the vhost. IO from the ssh server is controlled by an
205 "ops" struct of callbacks for tx, rx, auth etc.
206
207 - Many fixes, cleanups, source refactors and other improvements.
208
209
Andy Greene6bd6292017-07-28 14:13:42 +0800210v2.3.0
211======
212
213 - ESP32 OpenSSL support for client and server
214
215 - ESP32 4 x WLAN credential slots may be configured
216
217 - Libevent event loop support
218
219 - SOCKS5 proxy support
220
221 - lws_meta protocol for websocket connection multiplexing
222
223 - lws_vhost_destroy() added... allows dynamic removal of listening
224 vhosts. Vhosts with shared listen sockets adopt the listen socket
225 automatically if the owner is destroyed.
226
227 - IPv6 on Windows
228
229 - Improved CGI handling suitable for general CGI scripting, eg, PHP
230
231 - Convert even the "old style" test servers to use statically included
232 plugin sources
233
234 - LWS_WITH_STATS cmake option dumps resource usage and timing information
235 every few seconds to debug log, including latency information about
236 delay from asking for writeable callback to getting it
237
238 - Large (> 2GB) files may be served
239
240 - LWS_WITH_HTTP_PROXY Cmake option adds proxying mounts
241
242 - Workaround for libev build by disabling -Werror on the test app
243
244 - HTTP2 support disabled since no way to serve websockets on it
245
246
Andy Green6be573f2017-03-06 15:35:45 +0800247v2.2.0
248======
249
250Major new features
251
252 - A mount can be protected by Basic Auth... in lwsws it looks like this
253
254 ```
255{
256 "mountpoint": "/basic-auth",
257 "origin": "file://_lws_ddir_/libwebsockets-test-server/private",
258 "basic-auth": "/var/www/balogins-private"
259}
260```
261
262The text file named in `basic-auth` contains user:password information
263one per line.
264
265See README.lwsws.md for more information.
266
267 - RFC7233 RANGES support in lws server... both single and multipart.
268 This allows seeking for multimedia file serving and download resume.
269 It's enabled by default but can be disabled by CMake option.
270
271 - On Linux, lwsws can reload configuration without dropping ongoing
272 connections, when sent a SIGHUP. The old configuration drops its
273 listen sockets so the new configuration can listen on them.
274 New connections connect to the server instance with the new
275 configuration. When all old connections eventually close, the old
276 instance automatically exits. This is equivalent to
277 `systemctl reload apache`
278
279 - New `adopt` api allow adoption including SSL negotiation and
280 for raw sockets and file descriptors.
281
282 - Chunked transfer encoding supported for client and server
283
284 - Adaptations to allow operations inside OPTEE Secure World
285
286 - ESP32 initial port - able to do all test server functions. See
287 README.build.md
288
289 - Serving gzipped files from inside a ZIP file is supported... this
290 includes directly serving the gzipped content if the client
291 indicated it could accept it (ie, almost all browsers) saving
292 bandwidth and time. For clients that can't accept it, lws
293 automatically decompresses and serves the content in memory-
294 efficient chunks. Only a few hundred bytes of heap are needed
295 to serve any size file from inside the zip. See README.coding.md
296
297 - RAW file descriptors may now be adopted into the lws event loop,
298 independent of event backend (including poll service).
299 See README.coding.md
300
301 - RAW server socket descriptors may now be enabled on the vhost if
302 the first thing sent on the connection is not a valid http method.
303 The user code can associate these with a specific protocol per
304 vhost, and RAW-specific callbacks appear there for creation, rx,
305 writable and close. See libwebsockets-test-server-v2.0 for an example.
306 See README.coding.md
307
308 - RAW client connections are now possible using the method "RAW".
309 After connection, the socket is associated to the protocol
310 named in the client connection info and RAW-specific callbacks
311 appear there for creation, rx, writable and close.
312 See libwebsockets-test-client (with raw://) for an example.
313 See README.coding.md
314
315
Andy Green73557502016-10-06 21:48:20 +0800316v2.1.0
317======
318
319Major new features
320
321 - Support POST arguments, including multipart and file attachment
322
323 - Move most of lwsws into lws, make the stub CC0
324
325 - Add loopback test plugin to confirm client ws / http coexistence
326
327 - Integrate lwsws testing on Appveyor (ie, windows)
328
329 - Introduce helpers for sql, urlencode and urldecode sanitation
330
331 - Introduce LWS_CALLBACK_HTTP_BIND_PROTOCOL / DROP_PROTOCOL that
332 are compatible with http:/1.1 pipelining and different plugins
333 owning different parts of the URL space
334
335 - lwsgs - Generic Sessions plugin supports serverside sessions,
336 cookies, hashed logins, forgot password etc
337
338 - Added APIs for sending email to SMTP servers
339
340 - Messageboard example plugin for lwsgs
341
342 - Automatic PING sending at fixed intervals and close if no response
343
344 - Change default header limit in ah to 4096 (from 1024)
345
346 - Add SNI matching for wildcards if no specific wildcard vhost name match
347
348 - Convert docs to Doxygen
349
350 - ESP8266 support ^^
351
Enno Boland7731a3e2016-05-05 22:08:41 +0200352Fixes
353-----
354
Andy Green73557502016-10-06 21:48:20 +0800355See git log v2.0.0..
Enno Boland7731a3e2016-05-05 22:08:41 +0200356
Andy Greenfb8be052016-05-12 19:39:29 +0800357
Enno Boland7731a3e2016-05-05 22:08:41 +0200358
Andy Green55006432016-05-05 09:40:18 +0800359v2.0.0
360======
361
362Summary
363-------
364
365 - There are only api additions, the api is compatible with v1.7.x. But
366 there is necessarily an soname bump to 8.
367
368 - If you are using lws client, you mainly need to be aware the option
369 LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT is needed at context-creation time
370 if you will use SSL.
371
372 - If you are using lws for serving, the above is also true but there are
373 many new features to simplify your code (and life). There is a
374 summany online here
375
376 https://libwebsockets.org/lws-2.0-new-features.html
377
378 but basically the keywords are vhosts, mounts and plugins. You can now
379 do the web serving part from lws without any user callback code at all.
380 See ./test-server/test-server-v2.0.c for an example, it has no user
381 code for ws either since it uses the protocol plugins... that one C file
382 is all that is needed to do the whole test server function.
383
384 You now have the option to use a small generic ws-capable webserver
385 "lwsws" and write your ws part as a plugin. That eliminates even
386 cut-and-pasting the test server code and offers more configurable
387 features like control over http cacheability in JSON.
388
389
Andy Green0c3cc2e2016-02-20 09:12:52 +0800390Fixes
391-----
392
Andy Green55006432016-05-05 09:40:18 +0800393These are already in 1.7.x series
394
Andy Green0c3cc2e2016-02-20 09:12:52 +08003951) MAJOR (Windows-only) fix assert firing
396
3972) MAJOR http:/1.1 connections handled by lws_return_http_status() did not
398get sent a content-length resulting in the link hanging until the peer closed
399it. attack.sh updated to add a test for this.
400
Andy Green26d42492016-02-24 12:40:21 +08004013) MINOR An error about hdr struct in _lws_ws_related is corrected, it's not
402known to affect anything until after it was fixed
403
Andy Green5c0bcf42016-02-24 21:27:46 +08004044) MINOR During the close shutdown wait state introduced at v1.7, if something
405requests callback on writeable for the socket it will busywait until the
406socket closes
407
Andy Greendbfbbb42016-02-24 20:58:19 +08004085) MAJOR Although the test server has done it for a few versions already, it
409is now required for the user code to explicitly call
410
411 if (lws_http_transaction_completed(wsi))
412 return -1;
413
414when it finishes replying to a transaction in http. Previously the library
415did it for you, but that disallowed large, long transfers with multiple
416trips around the event loop (and cgi...).
417
Andy Green4ba798d2016-02-25 21:50:49 +08004186) MAJOR connections on ah waiting list that closed did not get removed from
419the waiting list...
420
Andy Green83af28a2016-02-28 10:55:31 +08004217) MAJOR since we added the ability to hold an ah across http keepalive
422transactions where more headers had already arrived, we broke the ability
423to tell if more headers had arrived. Result was if the browser didn't
424close the keepalive, we retained ah for the lifetime of the keepalive,
425using up the pool.
426
Andy Green442e1c82016-02-29 10:10:42 +08004278) MAJOR windows-only-POLLHUP was not coming
428
Andy Green4f5ebec2016-03-09 23:13:31 +08004299) Client should not send ext hdr if no exts
Andy Greendbfbbb42016-02-24 20:58:19 +0800430
Andy Green0c3cc2e2016-02-20 09:12:52 +0800431Changes
432-------
433
4341) MINOR test-server gained some new switches
435
436 -C <file> use external SSL cert file
437 -K <file> use external SSL key file
438 -A <file> use external SSL CA cert file
439
440 -u <uid> set effective uid
441 -g <gid> set effective gid
442
443together you can use them like this to have the test-server work with the
444usual purchased SSL certs from an official CA.
445
446 --ssl -C your.crt -K your.key -A your.cer -u 99 -g 99
447
4482) MINOR the OpenSSL magic to setup ECDH cipher usage is implemented in the
449library, and the ciphers restricted to use ECDH only.
450Using this, the lws test server can score an A at SSLLABS test
451
4523) MINOR STS (SSL always) header is added to the test server if you use --ssl. With
453that, we score A+ at SSLLABS test
454
4554) MINOR daemonize function (disabled at cmake by default) is updated to work
456with systemd
457
4585) MINOR example systemd .service file now provided for test server
459(not installed by default)
460
Andy Green0ad1a6e2016-02-20 14:05:55 +08004616) test server html is updated with tabs and a new live server monitoring
462feature. Input sanitization added to the js.
463
Andy Green2d8d35a2016-02-29 14:19:16 +08004647) client connections attempted when no ah is free no longer fail, they are
465just deferred until an ah becomes available.
466
Andy Greena661ee52016-02-29 13:18:30 +08004678) The test client pays attention to if you give it an http:/ or https://
468protocol string to its argument in URL format. If so, it stays in http[s]
469client mode and doesn't upgrade to ws[s], allowing you to do generic http client
Andy Green5c8906e2016-03-13 16:44:19 +0800470operations. Receiving transfer-encoding: chunked is supported.
Andy Greena661ee52016-02-29 13:18:30 +0800471
Andy Green1e5a9ad2016-03-20 11:59:53 +08004729) If you enable -DLWS_WITH_HTTP_PROXY=1 at cmake, the test server has a
473new URI path http://localhost:7681/proxytest If you visit here, a client
474connection to http://example.com:80 is spawned, and the results piped on
475to your original connection.
476
47710) Also with LWS_WITH_HTTP_PROXY enabled at cmake, lws wants to link to an
478additional library, "libhubbub". This allows lws to do html rewriting on the
479fly, adjusting proxied urls in a lightweight and fast way.
Andy Greenfb5f33b2016-03-01 07:19:01 +0800480
Andy Greenc6fd3602016-03-23 09:22:11 +080048111) There's a new context creation flag LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT,
482this is included automatically if you give any other SSL-related option flag.
483If you give no SSL-related option flag, nor this one directly, then even
484though SSL support may be compiled in, it is never initialized nor used for the
485whole lifetime of the lws context.
486
487Conversely in order to prepare the context to use SSL, even though, eg, you
488are not listening on SSL but will use SSL client connections later, you must
489give this flag explicitly to make sure SSL is initialized.
490
Andy Green2d8d35a2016-02-29 14:19:16 +0800491
Andy Greend7fddad2016-02-18 20:36:55 +0800492User API additions
493------------------
494
Andy Green0c3cc2e2016-02-20 09:12:52 +08004951) MINOR APIBREAK There's a new member in struct lws_context_creation_info, ecdh_curve,
Andy Greend7fddad2016-02-18 20:36:55 +0800496which lets you set the name of the ECDH curve OpenSSL should use. By
497default (if you leave ecdh_curve NULL) it will use "prime256v1"
498
Andy Green51d9afa2016-02-24 11:05:56 +08004992) MINOR NEWAPI It was already possible to adopt a foreign socket that had not
500been read from using lws_adopt_socket() since v1.7. Now you can adopt a
501partially-used socket if you don't need SSL, by passing it what you read
502so it can drain that before reading from the socket.
503
504LWS_VISIBLE LWS_EXTERN struct lws *
505lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd,
506 const char *readbuf, size_t len);
Andy Greend7fddad2016-02-18 20:36:55 +0800507
Andy Green6a8099b2016-02-21 21:25:48 +08005083) MINOR NEWAPI CGI type "network io" subprocess execution is now possible from
509a simple api.
510
511LWS_VISIBLE LWS_EXTERN int
Andy Green1a138852016-03-20 11:55:25 +0800512lws_cgi(struct lws *wsi, char * const *exec_array, int script_uri_path_len,
513 int timeout_secs);
Andy Green6a8099b2016-02-21 21:25:48 +0800514
515LWS_VISIBLE LWS_EXTERN int
516lws_cgi_kill(struct lws *wsi);
517
518To use it, you must first set the cmake option
519
520$ cmake .. -DLWS_WITH_CGI=1
521
522See test-server-http.c and test server path
523
524http://localhost:7681/cgitest
525
526stdin gets http body, you can test it with wget
527
528$ echo hello > hello.txt
529$ wget http://localhost:7681/cgitest --post-file=hello.txt -O- --quiet
530lwstest script
531read="hello"
532
Andy Green1a138852016-03-20 11:55:25 +0800533The test script returns text/html table showing /proc/meminfo. But the cgi
534support is complete enough to run cgit cgi.
535
Andy Greend61bed32016-02-25 15:01:55 +08005364) There is a helper api for forming logging timestamps
537
538LWS_VISIBLE int
539lwsl_timestamp(int level, char *p, int len)
540
541this generates this kind of timestamp for use as logging preamble
542
543lwsts[13116]: [2016/01/25 14:52:52:8386] NOTICE: Initial logging level 7
544
Andy Greena661ee52016-02-29 13:18:30 +08005455) struct lws_client_connect_info has a new member
546
547 const char *method
548
549If it's NULL, then everything happens as before, lws_client_connect_via_info()
550makes a ws or wss connection to the address given.
551
552If you set method to a valid http method like "GET", though, then this method
553is used and the connection remains in http[s], it's not upgraded to ws[s].
554
555So with this, you can perform http[s] client operations as well as ws[s] ones.
556
557There are 4 new related callbacks
558
559 LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP = 44,
560 LWS_CALLBACK_CLOSED_CLIENT_HTTP = 45,
561 LWS_CALLBACK_RECEIVE_CLIENT_HTTP = 46,
562 LWS_CALLBACK_COMPLETED_CLIENT_HTTP = 47,
Andy Green6a8099b2016-02-21 21:25:48 +0800563
Andy Green494418a2016-03-02 09:17:22 +08005646) struct lws_client_connect_info has a new member
565
566 const char *parent_wsi
567
568if non-NULL, the client wsi is set to be a child of parent_wsi. This ensures
569if parent_wsi closes, then the client child is closed just before.
570
Andy Green0f9904f2016-03-17 15:26:49 +08005717) If you're using SSL, there's a new context creation-time option flag
572LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS. If you give this, non-ssl
573connections to the server listen port are accepted and receive a 301
574redirect to / on the same host and port using https://
575
Andy Greenc5376b12016-04-08 09:45:49 +08005768) User code may set per-connection extension options now, using a new api
577"lws_set_extension_option()".
578
579This should be called from the ESTABLISHED callback like this
580
581 lws_set_extension_option(wsi, "permessage-deflate",
582 "rx_buf_size", "12"); /* 1 << 12 */
583
584If the extension is not active (missing or not negotiated for the
585connection, or extensions are disabled on the library) the call is
586just returns -1. Otherwise the connection's extension has its
587named option changed.
588
589The extension may decide to alter or disallow the change, in the
590example above permessage-deflate restricts the size of his rx
591output buffer also considering the protocol's rx_buf_size member.
592
593
Andy Greencd0c6962016-03-28 10:12:37 +0800594New application lwsws
595---------------------
596
597A libwebsockets-based general webserver is built by default now, lwsws.
598
599It's configured by JSON, by default in
600
601 /etc/lwsws/conf
602
603which contains global lws context settings like this
604
605{
606 "global": {
607 "uid": "99",
608 "gid": "99",
609 "interface": "eth0",
610 "count-threads": "1"
611 }
612}
613
614 /etc/lwsws/conf.d/*
615
616which contains zero or more files describing vhosts, like this
617
618{
619 "vhosts": [
620 { "name": "warmcat.com",
621 "port": "443",
622 "host-ssl-key": "/etc/pki/tls/private/warmcat.com.key",
623 "host-ssl-cert": "/etc/pki/tls/certs/warmcat.com.crt",
624 "host-ssl-ca": "/etc/pki/tls/certs/warmcat.com.cer",
625 "mounts": [
626 { "/": [
627 { "home": "file:///var/www/warmcat.com" },
628 { "default": "index.html" }
629 ]
630 }
631 ]
632 }
633 ]
634}
635
636
Andy Green0c3cc2e2016-02-20 09:12:52 +0800637
Andy Green9c60ed92016-02-16 12:32:18 +0800638v1.7.0
639======
640
Andy Green67112662016-01-11 11:34:01 +0800641Extension Changes
642-----------------
643
6441) There is now a "permessage-deflate" / RFC7692 implementation. It's very
645similar to "deflate-frame" we have offered for a long while; deflate-frame is
646now provided as an alias of permessage-deflate.
647
648The main differences are that the new permessage-deflate implementation:
649
650 - properly performs streaming respecting input and output buffer limits. The
651 old deflate-frame implementation could only work on complete deflate input
652 and produce complete inflate output for each frame. The new implementation
653 only mallocs buffers at initialization.
654
655 - goes around the event loop after each input package is processed allowing
656 interleaved output processing. The RX flow control api can be used to
657 force compressed input processing to match the rate of compressed output
658 processing (test--echo shows an example of how to do this).
659
660 - when being "deflate-frame" for compatibility he uses the same default zlib
661 settings as the old "deflate-frame", but instead of exponentially increasing
662 malloc allocations until the whole output will fit, he observes the default
663 input and output chunking buffer sizes of "permessage-deflate", that's
664 1024 in and 1024 out at a time.
665
6662) deflate-stream has been disabled for many versions (for over a year) and is
667now removed. Browsers are now standardizing on "permessage-deflate" / RFC7692
668
6693) struct lws_extension is simplified, and lws extensions now have a public
670api (their callback) for use in user code to compose extensions and options
671the user code wants. lws_get_internal_exts() is deprecated but kept around
672as a NOP. The changes allow one extension implementation to go by different
673names and allows the user client code to control option offers per-ext.
674
675The test client and server are updated to use the new way. If you use
676the old way it should still work, but extensions will be disabled until you
677update your code.
678
679Extensions are now responsible for allocating and per-instance private struct
680at instance construction time and freeing it when the instance is destroyed.
681Not needing to know the size means the extension's struct can be opaque
682to user code.
683
684
Andy Green3df58002015-12-25 12:44:12 +0800685User api additions
686------------------
687
Andy Green200a6a22016-02-15 20:36:02 +08006881) The info struct gained three new members
Andy Green3df58002015-12-25 12:44:12 +0800689
690 - max_http_header_data: 0 for default (1024) or set the maximum amount of known
691 http header payload that lws can deal with. Payload in unknown http
692 headers is dropped silently. If for some reason you need to send huge
693 cookies or other HTTP-level headers, you can now increase this at context-
694 creation time.
695
696 - max_http_header_pool: 0 for default (16) or set the maximum amount of http
697 headers that can be tracked by lws in this context. For the server, if
698 the header pool is completely in use then accepts on the listen socket
699 are disabled until one becomes free. For the client, if you simultaneously
700 have pending connects for more than this number of client connections,
701 additional connects will fail until some of the pending connections timeout
702 or complete.
703
Andy Green200a6a22016-02-15 20:36:02 +0800704 - timeout_secs: 0 for default (currently 20s), or set the library's
705 network activity timeout to the given number of seconds
706
Andy Green3df58002015-12-25 12:44:12 +0800707HTTP header processing in lws only exists until just after the first main
708callback after the HTTP handshake... for ws connections that is ESTABLISHED and
709for HTTP connections the HTTP callback.
710
711So these settings are not related to the maximum number of simultaneous
Andy Green3246ebb2015-12-26 12:03:06 +0800712connections, but the number of HTTP handshakes that may be expected or ongoing,
Andy Green3df58002015-12-25 12:44:12 +0800713or have just completed, at one time. The reason it's useful is it changes the
714memory allocation for header processing to be one-time at context creation
715instead of every time there is a new connection, and gives you control over
716the peak allocation.
717
718Setting max_http_header_pool to 1 is fine it will just queue incoming
719connections before the accept as necessary, you can still have as many
Andy Green5b85e392015-12-26 13:23:11 +0800720simultaneous post-header connections as you like. Since the http header
721processing is completed and the allocation released after ESTABLISHED or the
722HTTP callback, even with a pool of 1 many connections can be handled rapidly.
723
Andy Green066a7a12015-12-26 15:47:06 +08007242) There is a new callback that allows the user code to get acccess to the
725optional close code + aux data that may have been sent by the peer.
726
727LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
728 The peer has sent an unsolicited Close WS packet. @in and
729 @len are the optional close code (first 2 bytes, network
730 order) and the optional additional information which is not
731 defined in the standard, and may be a string or non-human-
732 readble data.
733 If you return 0 lws will echo the close and then close the
Andy Green67112662016-01-11 11:34:01 +0800734 connection. If you return nonzero lws will just close the
735 connection.
Andy Green066a7a12015-12-26 15:47:06 +0800736
737As usual not handling it does the right thing, if you're not interested in it
738just ignore it.
739
740The test server has "open and close" testing buttons at the bottom, if you
741open and close that connection, on close it will send a close code 3000 decimal
742and the string "Bye!" as the aux data.
743
744The test server dumb-increment callback handles this callback reason and prints
745
746lwsts[15714]: LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len 6
747lwsts[15714]: 0: 0x0B
748lwsts[15714]: 1: 0xB8
749lwsts[15714]: 2: 0x42
750lwsts[15714]: 3: 0x79
751lwsts[15714]: 4: 0x65
752lwsts[15714]: 5: 0x21
753
Andy Green1fb95e82015-12-26 17:20:34 +08007543) There is a new API to allow the user code to control the content of the
755close frame sent when about to return nonzero from the user callback to
756indicate the connection should close.
757
758/**
759 * lws_close_reason - Set reason and aux data to send with Close packet
760 * If you are going to return nonzero from the callback
761 * requesting the connection to close, you can optionally
762 * call this to set the reason the peer will be told if
763 * possible.
764 *
765 * @wsi: The websocket connection to set the close reason on
766 * @status: A valid close status from websocket standard
767 * @buf: NULL or buffer containing up to 124 bytes of auxiliary data
768 * @len: Length of data in @buf to send
769 */
770LWS_VISIBLE LWS_EXTERN void
771lws_close_reason(struct lws *wsi, enum lws_close_status status,
772 unsigned char *buf, size_t len);
773
774An extra button is added to the "open and close" test server page that requests
775that the test server close the connection from his end.
776
777The test server code will do so by
778
779 lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY,
780 (unsigned char *)"seeya", 5);
781 return -1;
782
783The browser shows the close code and reason he received
784
785websocket connection CLOSED, code: 1001, reason: seeya
786
Vijay Khurdiyae73d4462016-01-15 16:21:51 +08007874) There's a new context creation time option flag
Andy Green44a7f652015-12-29 11:20:09 +0800788
789LWS_SERVER_OPTION_VALIDATE_UTF8
790
791if you set it in info->options, then TEXT and CLOSE frames will get checked to
792confirm that they contain valid UTF-8. If they don't, the connection will get
793closed by lws.
794
Vijay Khurdiyae73d4462016-01-15 16:21:51 +08007955) ECDH Certs are now supported. Enable the CMake option
796
797cmake .. -DLWS_SSL_SERVER_WITH_ECDH_CERT=1
798
799**and** the info->options flag
800
Andy Greenff696482016-02-17 07:46:27 +0800801LWS_SERVER_OPTION_SSL_ECDH
Vijay Khurdiyae73d4462016-01-15 16:21:51 +0800802
803to build in support and select it at runtime.
804
Andy Greenff696482016-02-17 07:46:27 +08008056) There's a new api lws_parse_uri() that simplifies chopping up
Andy Green809d69a2016-01-14 11:37:56 +0800806https://xxx:yyy/zzz uris into parts nicely. The test client now uses this
Andy Greend3a55052016-01-19 03:34:24 +0800807to allow proper uris as well as the old address style.
808
8097) SMP support is integrated into LWS without any internal threading. It's
810very simple to use, libwebsockets-test-server-pthread shows how to do it,
811use -j <n> argument there to control the number of service threads up to 32.
812
813Two new members are added to the info struct
814
815 unsigned int count_threads;
816 unsigned int fd_limit_per_thread;
817
818leave them at the default 0 to get the normal singlethreaded service loop.
819
820Set count_threads to n to tell lws you will have n simultaneous service threads
821operating on the context.
822
823There is still a single listen socket on one port, no matter how many
824service threads.
825
826When a connection is made, it is accepted by the service thread with the least
827connections active to perform load balancing.
828
829The user code is responsible for spawning n threads running the service loop
830associated to a specific tsi (Thread Service Index, 0 .. n - 1). See
831the libwebsockets-test-server-pthread for how to do.
832
833If you leave fd_limit_per_thread at 0, then the process limit of fds is shared
834between the service threads; if you process was allowed 1024 fds overall then
835each thread is limited to 1024 / n.
836
837You can set fd_limit_per_thread to a nonzero number to control this manually, eg
838the overall supported fd limit is less than the process allowance.
839
840You can control the context basic data allocation for multithreading from Cmake
841using -DLWS_MAX_SMP=, if not given it's set to 32. The serv_buf allocation
842for the threads (currently 4096) is made at runtime only for active threads.
843
844Because lws will limit the requested number of actual threads supported
845according to LWS_MAX_SMP, there is an api lws_get_count_threads(context) to
846discover how many threads were actually allowed when the context was created.
847
848It's required to implement locking in the user code in the same way that
849libwebsockets-test-server-pthread does it, for the FD locking callbacks.
850
Andy Greenba119e92016-01-26 21:40:32 +0800851If LWS_MAX_SMP=1, then there is no code related to pthreads compiled in the
852library. If more than 1, a small amount of pthread mutex code is built into
853the library.
Andy Green809d69a2016-01-14 11:37:56 +0800854
Andy Greenba119e92016-01-26 21:40:32 +08008558) New API
856
857LWS_VISIBLE struct lws *
858lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd)
859
860allows foreign sockets accepted by non-lws code to be adopted by lws as if they
861had just been accepted by lws' own listen socket.
Andy Green3df58002015-12-25 12:44:12 +0800862
Danomi Czaski4e9c7f32016-01-28 09:40:53 +08008639) X-Real-IP: header has been added as WSI_TOKEN_HTTP_X_REAL_IP
864
Andy Green86ed65f2016-02-14 09:27:41 +080086510) Libuv support is added, there are new related user apis
866
867typedef void (lws_uv_signal_cb_t)(uv_loop_t *l, uv_signal_t *w, int revents);
868
869LWS_VISIBLE LWS_EXTERN int
870lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint,
871 lws_uv_signal_cb_t *cb);
872
873LWS_VISIBLE LWS_EXTERN int
874lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi);
875
876LWS_VISIBLE void
877lws_uv_sigint_cb(uv_loop_t *loop, uv_signal_t *watcher, int revents);
878
879and CMAKE option
880
881LWS_WITH_LIBUV
882
Danomi Czaski4e9c7f32016-01-28 09:40:53 +0800883
Andy Green3246ebb2015-12-26 12:03:06 +0800884User api changes
885----------------
886
8871) LWS_SEND_BUFFER_POST_PADDING is now 0 and deprecated. You can remove it; if
888you still use it, obviously it does nothing. Old binary code with nonzero
889LWS_SEND_BUFFER_POST_PADDING is perfectly compatible, the old code just
Andy Green5b85e392015-12-26 13:23:11 +0800890allocated a buffer bigger than the library is going to use.
Andy Green3246ebb2015-12-26 12:03:06 +0800891
Andy Green5b85e392015-12-26 13:23:11 +0800892The example apps no longer use LWS_SEND_BUFFER_POST_PADDING.
Andy Green3246ebb2015-12-26 12:03:06 +0800893
Andy Green4e2ac762015-12-26 20:26:11 +0800894The only path who made use of it was sending with LWS_WRITE_CLOSE --->
Andy Green3246ebb2015-12-26 12:03:06 +0800895
Andy Green1fb95e82015-12-26 17:20:34 +08008962) Because of lws_close_reason() formalizing handling close frames,
897LWS_WRITE_CLOSE is removed from libwebsockets.h. It was only of use to send
898close frames...close frame content should be managed using lws_close_reason()
899now.
900
Andy Green44a7f652015-12-29 11:20:09 +08009013) We check for invalid CLOSE codes and complain about protocol violation in
902our close code. But it changes little since we were in the middle of closing
903anyway.
904
9054) zero-length RX frames and zero length TX frames are now allowed.
906
9075) Pings and close used to be limited to 124 bytes, the correct limit is 125
908so that is now also allowed.
Andy Green3246ebb2015-12-26 12:03:06 +0800909
Steffen Vogelf9267172016-02-09 07:19:15 +01009106) LWS_PRE is provided as a synonym for LWS_SEND_BUFFER_PRE_PADDING, either is
Andy Green67112662016-01-11 11:34:01 +0800911valid to use now.
912
9137) There's generic support for RFC7462 style extension options built into the
914library now. As a consequence, a field "options" is added to lws_extension.
915It can be NULL if there are no options on the extension. Extension internal
916info is part of the public abi because extensions may be implemented outside
917the library.
918
Danomi Czaski4e9c7f32016-01-28 09:40:53 +08009198) WSI_TOKEN_PROXY enum was accidentally defined to collide with another token
920of value 73. That's now corrected and WSI_TOKEN_PROXY moved to his own place at
92177.
922
Andy Green86ed65f2016-02-14 09:27:41 +08009239) With the addition of libuv support, libev is not the only event loop
924library in town and his api names must be elaborated with _ev_
925
926 Callback typedef: lws_signal_cb ---> lws_ev_signal_cb_t
927 lws_sigint_cfg --> lws_ev_sigint_cfg
928 lws_initloop --> lws_ev_initloop
929 lws_sigint_cb --> lws_ev_sigint_cb
930
93110) Libev support is made compatible with multithreaded service,
932lws_ev_initloop (was lws_initloop) gets an extra argument for the
933thread service index (use 0 if you will just have 1 service thread).
934
935LWS_VISIBLE LWS_EXTERN int
Andy Greenff696482016-02-17 07:46:27 +0800936lws_ev_initloop(struct lws_context *context, ev_loop_t *loop, int tsi);
Andy Green86ed65f2016-02-14 09:27:41 +0800937
Andy Green3df58002015-12-25 12:44:12 +0800938
Andy Greenaef3dc42016-05-06 07:45:19 +0800939(for earlier changelogs, see the tagged releases)