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