blob: 4ce593582d6b5d499321316c5582b84160da0bd1 [file] [log] [blame]
Andy Greena35c86f2013-01-31 10:16:44 +08001Changelog
2---------
3
Andy Greenac032542018-11-16 09:10:41 +08004v3.1.0
5======
6
Andy Green502130d2018-05-10 16:13:26 +08007 - CHANGE: REMOVED: lws_client_connect() and lws_client_connect_extended()
8 compatibility apis for lws_client_connect_via_info() have been marked as
9 deprecated for several versions and are now removed. Use
Andy Greenac032542018-11-16 09:10:41 +080010 lws_client_connect_via_info() directly instead.
Andy Green502130d2018-05-10 16:13:26 +080011
Andy Greenac032542018-11-16 09:10:41 +080012 - CHANGE: CMAKE:
13 - LWS_WITH_HTTP2: now defaults ON
14
Andy Greend9f982a2018-11-19 07:40:47 +080015 - CHANGE: Minimal examples updated to use Content Security Policy best
16 practices, using
17 `LWS_SERVER_OPTION_HTTP_HEADERS_SECURITY_BEST_PRACTICES_ENFORCE` vhost
Andy Green9bed6d62018-11-23 08:47:56 +080018 option flag and disabling of inline style and scripts. A side-effect of
19 this is that buffers used to marshal headers have to be prepared to take
20 more content than previously... LWS_RECOMMENDED_MIN_HEADER_SPACE (2048
21 currently) is available for user (and internal) use to logically tie the
22 buffer size to this usecase (and follow future increases).
Andy Greend9f982a2018-11-19 07:40:47 +080023
Andy Greenac032542018-11-16 09:10:41 +080024 - NEW: CMAKE
25 - LWS_FOR_GITOHASHI: sets various cmake options suitable for gitohashi
26 - LWS_WITH_ASAN: for Linux, enable build with ASAN
27
28 Don't forget LWS_WITH_DISTRO_RECOMMENDED, which enables a wide range of lws
29 options suitable for a distro build of the library.
30
31 - NEW: lws threadpool - lightweight pool of pthreads integrated to lws wsi, with
32 all synchronization to event loop handled internally, queue for excess tasks
33 [threadpool docs](https://libwebsockets.org/git/libwebsockets/tree/lib/misc/threadpool)
34 [threadpool minimal example](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-server/minimal-ws-server-threadpool)
35 Cmake config: `-DLWS_WITH_THREADPOOL=1`
36
37 - NEW: libdbus support integrated on lws event loop
38 [lws dbus docs](https://libwebsockets.org/git/libwebsockets/tree/lib/roles/dbus)
39 [lws dbus client minimal examples](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/dbus-client)
40 [lws dbus server minimal examples](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/dbus-server)
41 Cmake config: `-DLWS_ROLE_DBUS=1`
42
43 - NEW: lws allocated chunks (lwsac) - helpers for optimized mass allocation of small
44 objects inside a few larger malloc chunks... if you need to allocate a lot of
45 inter-related structs for a limited time, this removes per-struct allocation
46 library overhead completely and removes the need for any destruction handling
47 [lwsac docs](https://libwebsockets.org/git/libwebsockets/tree/lib/misc/lwsac)
48 [lwsac minimal example](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/api-tests/api-test-lwsac)
49 Cmake Config: `-DLWS_WITH_LWSAC=1`
50
51 - NEW: lws tokenizer - helper api for robustly tokenizing your own strings without
52 allocating or adding complexity. Configurable by flags for common delimiter
53 sets and comma-separated-lists in the tokenizer. Detects and reports syntax
54 errors.
55 [lws_tokenize docs](https://libwebsockets.org/git/libwebsockets/tree/include/libwebsockets/lws-tokenize.h)
56 [lws_tokenize minimal example / api test](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/api-tests/api-test-lws_tokenize)
57
58 - NEW: lws full-text search - optimized trie generation, serialization,
59 autocomplete suggestion generation and instant global search support extensible
60 to huge corpuses of UTF-8 text while remaining super lightweight on resources.
61 [full-text search docs](https://libwebsockets.org/git/libwebsockets/tree/lib/misc/fts)
62 [full-text search minimal example / api test](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/api-tests/api-test-fts)
63 [demo](https://libwebsockets.org/ftsdemo/)
64 [demo sources](https://libwebsockets.org/git/libwebsockets/tree/plugins/protocol_fulltext_demo.c)
65 Cmake config: `-DLWS_WITH_FTS=1 -DLWS_WITH_LWSAC=1`
66
67 - NEW: gzip + brotli http server-side compression - h1 and h2 automatic advertising
68 of server compression and application to files with mimetypes "text/*",
69 "application/javascript" and "image/svg.xml".
70 Cmake config: `-DLWS_WITH_HTTP_STREAM_COMPRESSION=1`, `-DLWS_WITH_HTTP_BROTLI=1`
71
72 - NEW: managed disk cache - API for managing a directory containing cached files
73 with hashed names, and automatic deletion of LRU files once the cache is
74 above a given limit.
75 [lws diskcache docs](https://libwebsockets.org/git/libwebsockets/tree/include/libwebsockets/lws-diskcache.h)
76 Cmake config: `-DLWS_WITH_DISKCACHE=1`
77
78 - NEW: http reverse proxy - lws mounts support proxying h1 or h2 requests to
79 a local or remote IP, or unix domain socket over h1. This allows microservice
80 type architectures where parts of the common URL space are actually handled
81 by external processes which may be remote or on the same machine.
82 [lws gitohashi serving](https://libwebsockets.org/git/) is handled this way.
83 CMake config: `-DLWS_WITH_HTTP_PROXY=1`
84
85 - NEW: lws_buflist - internally several types of ad-hoc malloc'd buffer have
86 been replaced by a new, exported api `struct lws_buflist`. This allows
87 multiple buffers to be chained and drawn down in strict FIFO order.
88
89 - NEW: In the case of h1 upgrade, the connection header is checked to contain
90 "upgrade". The vhost flag LWS_SERVER_OPTION_VHOST_UPG_STRICT_HOST_CHECK
91 also causes the Host: header to be confirmed to match the vhost name and
92 listen port.
Andy Greenc027c3d2018-11-21 06:46:23 +080093
94 - NEW: If no 404 redirect for `lws_return_http_status()` is specified for the vhost,
95 the status page produced will try to bring in a stylesheet `/error.css`. This allows
96 you to produce styled 404 or other error pages with logos, graphics etc. See
97 https://libwebsockets.org/git/badrepo for an example of what you can do with it.
Andy Green502130d2018-05-10 16:13:26 +080098
Andy Green1c08a962018-05-04 13:27:12 +080099v3.0.0
100======
101
102 - CHANGE: Clients used to call LWS_CALLBACK_CLOSED same as servers...
103 LWS_CALLBACK_CLIENT_CLOSED has been introduced and is called for clients
104 now.
105
106 - CHANGE: LWS_CALLBACK_CLIENT_CONNECTION_ERROR used to only be directed at
107 protocols[0]. However in many cases, the protocol to bind to was provided
108 at client connection info time and the wsi bound accordingly. In those
109 cases, CONNECTION_ERROR is directed at the bound protocol, not protcols[0]
110 any more.
111
112 - CHANGE: CMAKE: the following cmake defaults have changed with this version:
113
114 - LWS_WITH_ZIP_FOPS: now defaults OFF
115 - LWS_WITH_RANGES: now defaults OFF
116 - LWS_WITH_ZLIB: now defaults OFF
117 - LWS_WITHOUT_EXTENSIONS: now defaults ON
118
119 - CHANGE: REMOVED: lws_alloc_vfs_file() (read a file to malloc buffer)
120
121 - CHANGE: REMOVED: lws_read() (no longer useful outside of lws internals)
122
123 - CHANGE: REMOVED: ESP8266... ESP32 is now within the same price range and much
124 more performant
125
126 - CHANGE: soname bump... don't forget to `ldconfig`
127
128 - NEW: all event libraries support "foreign" loop integration where lws itself
129 if just a temporary user of the loop unrelated to the actual loop lifecycle.
130
131 See `minimal-http-server-eventlib-foreign` for example code demonstrating
132 this for all the event libraries.
133
134 Internal loop in lws is also supported and demonstrated by
135 `minimal-http-server-eventlib`.
136
137 - NEW: ws-over-h2 support. This is a new RFC-on-the-way supported by Chrome
138 and shortly firefox that allows ws connections to be multiplexed back to the
139 server on the same tcp + tls wrapper h2 connection that the html and scripts
140 came in on. This is hugely faster that discrete connections.
141
142 - NEW: UDP socket adoption and related event callbacks
143
144 - NEW: Multi-client connection binding, queuing and pipelining support.
145
146 Lws detects multiple client connections to the same server and port, and
147 optimizes how it handles them according to the server type and provided
148 flags. For http/1.0, all occur with individual parallel connections. For
149 http/1.1, you can enable keepalive pipelining, so the connections occur
150 sequentially on a single network connection. For http/2, they all occur
151 as parallel streams within a single h2 network connection.
152
153 See minimal-http-client-multi for example code.
154
155 - NEW: High resolution timer API for wsi, get a callback on your wsi with
156 LWS_CALLBACK_TIMER, set and reset the timer with lws_set_timer_usecs(wsi, us)
157 Actual resolution depends on event backend. Works with all backends, poll,
158 libuv, libevent, and libev.
159
160 - NEW: Protocols can arrange vhost-protocol instance specific callbacks with
161 second resolution using `lws_timed_callback_vh_protocol()`
162
163 - NEW: ACME client plugin for self-service TLS certificates
164
165 - NEW: RFC7517 JSON Web Keys RFC7638 JWK thumbprint, and RFC7515 JSON Web
166 signatures support
167
168 - NEW: lws_cancel_service() now provides a generic way to synchronize events
169 from other threads, which appear as a LWS_CALLBACK_EVENT_WAIT_CANCELLED
170 callback on all protocols. This is compatible with all the event libraries.
171
172 - NEW: support BSD poll() where changes to the poll wait while waiting are
173 undone.
174
175 - NEW: Introduce generic hash, hmac and RSA apis that operate the same
176 regardless of OpenSSL or mbedTLS tls backend
177
178 - NEW: Introduce X509 element query api that works the same regardless of
179 OpenSSL or mbedTLS tls backend
180
181 - NEW: Introduce over 30 "minimal examples" in ./minimal-examples... these
182 replace most of the old test servers
183
184 - test-echo -> minimal-ws-server-echo and minimal-ws-client-echo
185
186 - test-server-libuv / -libevent / -libev ->
187 minimal-https-server-eventlib / -eventlib-foreign / -eventlib-demos
188
189 - test-server-v2.0 -> folded into all the minimal servers
190
191 - test-server direct http serving -> minimal-http-server-dynamic
192
193 The minimal examples allow individual standalone build using their own
194 small CMakeLists.txt.
195
196 - NEW: lws now detects any back-to-back writes that did not go through the
197 event loop inbetween and reports them. This will flag any possibility of
198 failure rather than wait until the problem happens.
199
200 - NEW: CMake has LWS_WITH_DISTRO_RECOMMENDED to select features that are
201 appropriate for distros
202
203 - NEW: Optional vhost URL `error_document_404` if given causes a redirect there
204 instead of serve the default 404 page.
205
206 - NEW: lws_strncpy() wrapper guarantees NUL in copied string even if it was
207 truncated to fit.
208
209 - NEW: for client connections, local protocol binding name can be separated
210 from the ws subprotocol name if needed, using .local_protocol_name
211
212 - NEW: Automatic detection of time discontiguities
213
214 - NEW: Applies TCP_USER_TIMEOUT for Linux tcp keepalive where available
215
216 - QA: 1600 tests run on each commit in Travis CI, including almost all
217 Autobahn in client and server mode, various h2load tests, h2spec, attack.sh
218 the minimal example selftests and others.
219
220 - QA: fix small warnings introduced on gcc8.x (eg, Fedora 28)
221
222 - QA: Add most of -Wextra on gcc (-Wsign-compare, -Wignored-qualifiers,
223 -Wtype-limits, -Wuninitialized)
224
225 - QA: clean out warnings on windows
226
227 - QA: pass all 146 h2spec tests now on strict
228
229 - QA: introduce 35 selftests that operate different minimal examples against
230 each other and confirm the results.
231
232 - QA: LWS_WITH_MINIMAL_EXAMPLES allows mass build of all relevant minimal-
233 examples with the LWS build, for CI and to make all the example binaries
234 available from the lws build dir ./bin
235
236 - REFACTOR: the lws source directory layout in ./lib has been radically
237 improved, and there are now README.md files in selected subdirs with extra
238 documentation of interest to people working on lws itself.
239
240 - REFACTOR: pipelined transactions return to the event loop before starting the
241 next part.
242
243 - REFACTOR: TLS: replace all TLS library constants with generic LWS ones and
244 adapt all the TLS library code to translate to these common ones.
245
246 Isolated all the tls-related private stuff in `./lib/tls/private.h`, and all
247 the mbedTLS stuff in `./lib/tls/mbedtls` + openSSL stuff in
248 `./lib/tls/openssl`
249
250 - REFACTOR: the various kinds of wsi possible with lws have been extracted
251 from the main code and isolated into "roles" in `./lib/roles` which
252 communicate with the core code via an ops struct. Everything related to
253 ah is migrated to the http role.
254
255 wsi modes are eliminated and replaced by the ops pointer for the role the
256 wsi is performing. Generic states for wsi are available to control the
257 lifecycle using core code.
258
259 Adding new "roles" is now much easier with the changes and ops struct to
260 plug into.
261
262 - REFACTOR: reduce four different kinds of buffer management in lws into a
263 generic scatter-gather struct lws_buflist.
264
265 - REFACTOR: close notifications go through event loop
266
267
Andy Greenfcf5b2c2017-10-16 20:09:58 +0800268v2.4.0
269======
270
271 - HTTP/2 server support is now mature and usable! LWS_WITH_HTTP2=1 enables it.
272 Uses ALPN to serve HTTP/2, HTTP/1 and ws[s] connections all from the same
273 listen port seamlessly. (Requires ALPN-capable OpenSSL 1.1 or mbedTLS).
274
275 - LWS_WITH_MBEDTLS=1 at CMake now builds and works against mbedTLS instead of
276 OpenSSL. Most things work identically, although on common targets where
277 OpenSSL has acceleration, mbedTLS is many times slower in operation. However
278 it is a lot smaller codewise.
279
280 - Generic hash apis introduced that work the same on mbedTLS or OpenSSL backend
281
282 - LWS_WITH_PEER_LIMITS tracks IPs across all vhosts and allows restrictions on
283 both the number of simultaneous connections and wsi in use for any single IP
284
285 - lws_ring apis provide a generic single- or multi-tail ringbuffer... mirror
286 protocol now uses this. Features include ring elements may be sized to fit
287 structs in the ringbuffer, callback when no tail any longer needs an element
288 and it can be deleted, and zerocopy options to write new members directly
289 into the ringbuffer, and use the ringbuffer element by address too.
290
291 - abstract ssh 2 server plugin included, with both plugin and standalone
292 demos provided. You can bind the plugin to a vhost and also serve full-
293 strength ssh from the vhost. IO from the ssh server is controlled by an
294 "ops" struct of callbacks for tx, rx, auth etc.
295
296 - Many fixes, cleanups, source refactors and other improvements.
297
298
Andy Greene6bd6292017-07-28 14:13:42 +0800299v2.3.0
300======
301
302 - ESP32 OpenSSL support for client and server
303
304 - ESP32 4 x WLAN credential slots may be configured
305
306 - Libevent event loop support
307
308 - SOCKS5 proxy support
309
310 - lws_meta protocol for websocket connection multiplexing
311
312 - lws_vhost_destroy() added... allows dynamic removal of listening
313 vhosts. Vhosts with shared listen sockets adopt the listen socket
314 automatically if the owner is destroyed.
315
316 - IPv6 on Windows
317
318 - Improved CGI handling suitable for general CGI scripting, eg, PHP
319
320 - Convert even the "old style" test servers to use statically included
321 plugin sources
322
323 - LWS_WITH_STATS cmake option dumps resource usage and timing information
324 every few seconds to debug log, including latency information about
325 delay from asking for writeable callback to getting it
326
327 - Large (> 2GB) files may be served
328
329 - LWS_WITH_HTTP_PROXY Cmake option adds proxying mounts
330
331 - Workaround for libev build by disabling -Werror on the test app
332
333 - HTTP2 support disabled since no way to serve websockets on it
334
335
Andy Green6be573f2017-03-06 15:35:45 +0800336v2.2.0
337======
338
339Major new features
340
341 - A mount can be protected by Basic Auth... in lwsws it looks like this
342
343 ```
344{
345 "mountpoint": "/basic-auth",
346 "origin": "file://_lws_ddir_/libwebsockets-test-server/private",
347 "basic-auth": "/var/www/balogins-private"
348}
349```
350
351The text file named in `basic-auth` contains user:password information
352one per line.
353
354See README.lwsws.md for more information.
355
356 - RFC7233 RANGES support in lws server... both single and multipart.
357 This allows seeking for multimedia file serving and download resume.
358 It's enabled by default but can be disabled by CMake option.
359
360 - On Linux, lwsws can reload configuration without dropping ongoing
361 connections, when sent a SIGHUP. The old configuration drops its
362 listen sockets so the new configuration can listen on them.
363 New connections connect to the server instance with the new
364 configuration. When all old connections eventually close, the old
365 instance automatically exits. This is equivalent to
366 `systemctl reload apache`
367
368 - New `adopt` api allow adoption including SSL negotiation and
369 for raw sockets and file descriptors.
370
371 - Chunked transfer encoding supported for client and server
372
373 - Adaptations to allow operations inside OPTEE Secure World
374
375 - ESP32 initial port - able to do all test server functions. See
376 README.build.md
377
378 - Serving gzipped files from inside a ZIP file is supported... this
379 includes directly serving the gzipped content if the client
380 indicated it could accept it (ie, almost all browsers) saving
381 bandwidth and time. For clients that can't accept it, lws
382 automatically decompresses and serves the content in memory-
383 efficient chunks. Only a few hundred bytes of heap are needed
384 to serve any size file from inside the zip. See README.coding.md
385
386 - RAW file descriptors may now be adopted into the lws event loop,
387 independent of event backend (including poll service).
388 See README.coding.md
389
390 - RAW server socket descriptors may now be enabled on the vhost if
391 the first thing sent on the connection is not a valid http method.
392 The user code can associate these with a specific protocol per
393 vhost, and RAW-specific callbacks appear there for creation, rx,
394 writable and close. See libwebsockets-test-server-v2.0 for an example.
395 See README.coding.md
396
397 - RAW client connections are now possible using the method "RAW".
398 After connection, the socket is associated to the protocol
399 named in the client connection info and RAW-specific callbacks
400 appear there for creation, rx, writable and close.
401 See libwebsockets-test-client (with raw://) for an example.
402 See README.coding.md
403
404
Andy Green73557502016-10-06 21:48:20 +0800405v2.1.0
406======
407
408Major new features
409
410 - Support POST arguments, including multipart and file attachment
411
412 - Move most of lwsws into lws, make the stub CC0
413
414 - Add loopback test plugin to confirm client ws / http coexistence
415
416 - Integrate lwsws testing on Appveyor (ie, windows)
417
418 - Introduce helpers for sql, urlencode and urldecode sanitation
419
420 - Introduce LWS_CALLBACK_HTTP_BIND_PROTOCOL / DROP_PROTOCOL that
421 are compatible with http:/1.1 pipelining and different plugins
422 owning different parts of the URL space
423
424 - lwsgs - Generic Sessions plugin supports serverside sessions,
425 cookies, hashed logins, forgot password etc
426
427 - Added APIs for sending email to SMTP servers
428
429 - Messageboard example plugin for lwsgs
430
431 - Automatic PING sending at fixed intervals and close if no response
432
433 - Change default header limit in ah to 4096 (from 1024)
434
435 - Add SNI matching for wildcards if no specific wildcard vhost name match
436
437 - Convert docs to Doxygen
438
439 - ESP8266 support ^^
440
Enno Boland7731a3e2016-05-05 22:08:41 +0200441Fixes
442-----
443
Andy Green73557502016-10-06 21:48:20 +0800444See git log v2.0.0..
Enno Boland7731a3e2016-05-05 22:08:41 +0200445
Andy Greenfb8be052016-05-12 19:39:29 +0800446
Enno Boland7731a3e2016-05-05 22:08:41 +0200447
Andy Green55006432016-05-05 09:40:18 +0800448v2.0.0
449======
450
451Summary
452-------
453
454 - There are only api additions, the api is compatible with v1.7.x. But
455 there is necessarily an soname bump to 8.
456
457 - If you are using lws client, you mainly need to be aware the option
458 LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT is needed at context-creation time
459 if you will use SSL.
460
461 - If you are using lws for serving, the above is also true but there are
462 many new features to simplify your code (and life). There is a
463 summany online here
464
465 https://libwebsockets.org/lws-2.0-new-features.html
466
467 but basically the keywords are vhosts, mounts and plugins. You can now
468 do the web serving part from lws without any user callback code at all.
469 See ./test-server/test-server-v2.0.c for an example, it has no user
470 code for ws either since it uses the protocol plugins... that one C file
471 is all that is needed to do the whole test server function.
472
473 You now have the option to use a small generic ws-capable webserver
474 "lwsws" and write your ws part as a plugin. That eliminates even
475 cut-and-pasting the test server code and offers more configurable
476 features like control over http cacheability in JSON.
477
478
Andy Green0c3cc2e2016-02-20 09:12:52 +0800479Fixes
480-----
481
Andy Green55006432016-05-05 09:40:18 +0800482These are already in 1.7.x series
483
Andy Green0c3cc2e2016-02-20 09:12:52 +08004841) MAJOR (Windows-only) fix assert firing
485
4862) MAJOR http:/1.1 connections handled by lws_return_http_status() did not
487get sent a content-length resulting in the link hanging until the peer closed
488it. attack.sh updated to add a test for this.
489
Andy Green26d42492016-02-24 12:40:21 +08004903) MINOR An error about hdr struct in _lws_ws_related is corrected, it's not
491known to affect anything until after it was fixed
492
Andy Green5c0bcf42016-02-24 21:27:46 +08004934) MINOR During the close shutdown wait state introduced at v1.7, if something
494requests callback on writeable for the socket it will busywait until the
495socket closes
496
Andy Greendbfbbb42016-02-24 20:58:19 +08004975) MAJOR Although the test server has done it for a few versions already, it
498is now required for the user code to explicitly call
499
500 if (lws_http_transaction_completed(wsi))
501 return -1;
502
503when it finishes replying to a transaction in http. Previously the library
504did it for you, but that disallowed large, long transfers with multiple
505trips around the event loop (and cgi...).
506
Andy Green4ba798d2016-02-25 21:50:49 +08005076) MAJOR connections on ah waiting list that closed did not get removed from
508the waiting list...
509
Andy Green83af28a2016-02-28 10:55:31 +08005107) MAJOR since we added the ability to hold an ah across http keepalive
511transactions where more headers had already arrived, we broke the ability
512to tell if more headers had arrived. Result was if the browser didn't
513close the keepalive, we retained ah for the lifetime of the keepalive,
514using up the pool.
515
Andy Green442e1c82016-02-29 10:10:42 +08005168) MAJOR windows-only-POLLHUP was not coming
517
Andy Green4f5ebec2016-03-09 23:13:31 +08005189) Client should not send ext hdr if no exts
Andy Greendbfbbb42016-02-24 20:58:19 +0800519
Andy Green0c3cc2e2016-02-20 09:12:52 +0800520Changes
521-------
522
5231) MINOR test-server gained some new switches
524
525 -C <file> use external SSL cert file
526 -K <file> use external SSL key file
527 -A <file> use external SSL CA cert file
528
529 -u <uid> set effective uid
530 -g <gid> set effective gid
531
532together you can use them like this to have the test-server work with the
533usual purchased SSL certs from an official CA.
534
535 --ssl -C your.crt -K your.key -A your.cer -u 99 -g 99
536
5372) MINOR the OpenSSL magic to setup ECDH cipher usage is implemented in the
538library, and the ciphers restricted to use ECDH only.
539Using this, the lws test server can score an A at SSLLABS test
540
5413) MINOR STS (SSL always) header is added to the test server if you use --ssl. With
542that, we score A+ at SSLLABS test
543
5444) MINOR daemonize function (disabled at cmake by default) is updated to work
545with systemd
546
5475) MINOR example systemd .service file now provided for test server
548(not installed by default)
549
Andy Green0ad1a6e2016-02-20 14:05:55 +08005506) test server html is updated with tabs and a new live server monitoring
551feature. Input sanitization added to the js.
552
Andy Green2d8d35a2016-02-29 14:19:16 +08005537) client connections attempted when no ah is free no longer fail, they are
554just deferred until an ah becomes available.
555
Andy Greena661ee52016-02-29 13:18:30 +08005568) The test client pays attention to if you give it an http:/ or https://
557protocol string to its argument in URL format. If so, it stays in http[s]
558client mode and doesn't upgrade to ws[s], allowing you to do generic http client
Andy Green5c8906e2016-03-13 16:44:19 +0800559operations. Receiving transfer-encoding: chunked is supported.
Andy Greena661ee52016-02-29 13:18:30 +0800560
Andy Green1e5a9ad2016-03-20 11:59:53 +08005619) If you enable -DLWS_WITH_HTTP_PROXY=1 at cmake, the test server has a
562new URI path http://localhost:7681/proxytest If you visit here, a client
563connection to http://example.com:80 is spawned, and the results piped on
564to your original connection.
565
56610) Also with LWS_WITH_HTTP_PROXY enabled at cmake, lws wants to link to an
567additional library, "libhubbub". This allows lws to do html rewriting on the
568fly, adjusting proxied urls in a lightweight and fast way.
Andy Greenfb5f33b2016-03-01 07:19:01 +0800569
Andy Greenc6fd3602016-03-23 09:22:11 +080057011) There's a new context creation flag LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT,
571this is included automatically if you give any other SSL-related option flag.
572If you give no SSL-related option flag, nor this one directly, then even
573though SSL support may be compiled in, it is never initialized nor used for the
574whole lifetime of the lws context.
575
576Conversely in order to prepare the context to use SSL, even though, eg, you
577are not listening on SSL but will use SSL client connections later, you must
578give this flag explicitly to make sure SSL is initialized.
579
Andy Green2d8d35a2016-02-29 14:19:16 +0800580
Andy Greend7fddad2016-02-18 20:36:55 +0800581User API additions
582------------------
583
Andy Green0c3cc2e2016-02-20 09:12:52 +08005841) MINOR APIBREAK There's a new member in struct lws_context_creation_info, ecdh_curve,
Andy Greend7fddad2016-02-18 20:36:55 +0800585which lets you set the name of the ECDH curve OpenSSL should use. By
586default (if you leave ecdh_curve NULL) it will use "prime256v1"
587
Andy Green51d9afa2016-02-24 11:05:56 +08005882) MINOR NEWAPI It was already possible to adopt a foreign socket that had not
589been read from using lws_adopt_socket() since v1.7. Now you can adopt a
590partially-used socket if you don't need SSL, by passing it what you read
591so it can drain that before reading from the socket.
592
593LWS_VISIBLE LWS_EXTERN struct lws *
594lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd,
595 const char *readbuf, size_t len);
Andy Greend7fddad2016-02-18 20:36:55 +0800596
Andy Green6a8099b2016-02-21 21:25:48 +08005973) MINOR NEWAPI CGI type "network io" subprocess execution is now possible from
598a simple api.
599
600LWS_VISIBLE LWS_EXTERN int
Andy Green1a138852016-03-20 11:55:25 +0800601lws_cgi(struct lws *wsi, char * const *exec_array, int script_uri_path_len,
602 int timeout_secs);
Andy Green6a8099b2016-02-21 21:25:48 +0800603
604LWS_VISIBLE LWS_EXTERN int
605lws_cgi_kill(struct lws *wsi);
606
607To use it, you must first set the cmake option
608
609$ cmake .. -DLWS_WITH_CGI=1
610
611See test-server-http.c and test server path
612
613http://localhost:7681/cgitest
614
615stdin gets http body, you can test it with wget
616
617$ echo hello > hello.txt
618$ wget http://localhost:7681/cgitest --post-file=hello.txt -O- --quiet
619lwstest script
620read="hello"
621
Andy Green1a138852016-03-20 11:55:25 +0800622The test script returns text/html table showing /proc/meminfo. But the cgi
623support is complete enough to run cgit cgi.
624
Andy Greend61bed32016-02-25 15:01:55 +08006254) There is a helper api for forming logging timestamps
626
627LWS_VISIBLE int
628lwsl_timestamp(int level, char *p, int len)
629
630this generates this kind of timestamp for use as logging preamble
631
632lwsts[13116]: [2016/01/25 14:52:52:8386] NOTICE: Initial logging level 7
633
Andy Greena661ee52016-02-29 13:18:30 +08006345) struct lws_client_connect_info has a new member
635
636 const char *method
637
638If it's NULL, then everything happens as before, lws_client_connect_via_info()
639makes a ws or wss connection to the address given.
640
641If you set method to a valid http method like "GET", though, then this method
642is used and the connection remains in http[s], it's not upgraded to ws[s].
643
644So with this, you can perform http[s] client operations as well as ws[s] ones.
645
646There are 4 new related callbacks
647
648 LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP = 44,
649 LWS_CALLBACK_CLOSED_CLIENT_HTTP = 45,
650 LWS_CALLBACK_RECEIVE_CLIENT_HTTP = 46,
651 LWS_CALLBACK_COMPLETED_CLIENT_HTTP = 47,
Andy Green6a8099b2016-02-21 21:25:48 +0800652
Andy Green494418a2016-03-02 09:17:22 +08006536) struct lws_client_connect_info has a new member
654
655 const char *parent_wsi
656
657if non-NULL, the client wsi is set to be a child of parent_wsi. This ensures
658if parent_wsi closes, then the client child is closed just before.
659
Andy Green0f9904f2016-03-17 15:26:49 +08006607) If you're using SSL, there's a new context creation-time option flag
661LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS. If you give this, non-ssl
662connections to the server listen port are accepted and receive a 301
663redirect to / on the same host and port using https://
664
Andy Greenc5376b12016-04-08 09:45:49 +08006658) User code may set per-connection extension options now, using a new api
666"lws_set_extension_option()".
667
668This should be called from the ESTABLISHED callback like this
669
670 lws_set_extension_option(wsi, "permessage-deflate",
671 "rx_buf_size", "12"); /* 1 << 12 */
672
673If the extension is not active (missing or not negotiated for the
674connection, or extensions are disabled on the library) the call is
675just returns -1. Otherwise the connection's extension has its
676named option changed.
677
678The extension may decide to alter or disallow the change, in the
679example above permessage-deflate restricts the size of his rx
680output buffer also considering the protocol's rx_buf_size member.
681
682
Andy Greencd0c6962016-03-28 10:12:37 +0800683New application lwsws
684---------------------
685
686A libwebsockets-based general webserver is built by default now, lwsws.
687
688It's configured by JSON, by default in
689
690 /etc/lwsws/conf
691
692which contains global lws context settings like this
693
694{
695 "global": {
696 "uid": "99",
697 "gid": "99",
698 "interface": "eth0",
699 "count-threads": "1"
700 }
701}
702
703 /etc/lwsws/conf.d/*
704
705which contains zero or more files describing vhosts, like this
706
707{
708 "vhosts": [
709 { "name": "warmcat.com",
710 "port": "443",
711 "host-ssl-key": "/etc/pki/tls/private/warmcat.com.key",
712 "host-ssl-cert": "/etc/pki/tls/certs/warmcat.com.crt",
713 "host-ssl-ca": "/etc/pki/tls/certs/warmcat.com.cer",
714 "mounts": [
715 { "/": [
716 { "home": "file:///var/www/warmcat.com" },
717 { "default": "index.html" }
718 ]
719 }
720 ]
721 }
722 ]
723}
724
725
Andy Green0c3cc2e2016-02-20 09:12:52 +0800726
Andy Green9c60ed92016-02-16 12:32:18 +0800727v1.7.0
728======
729
Andy Green67112662016-01-11 11:34:01 +0800730Extension Changes
731-----------------
732
7331) There is now a "permessage-deflate" / RFC7692 implementation. It's very
734similar to "deflate-frame" we have offered for a long while; deflate-frame is
735now provided as an alias of permessage-deflate.
736
737The main differences are that the new permessage-deflate implementation:
738
739 - properly performs streaming respecting input and output buffer limits. The
740 old deflate-frame implementation could only work on complete deflate input
741 and produce complete inflate output for each frame. The new implementation
742 only mallocs buffers at initialization.
743
744 - goes around the event loop after each input package is processed allowing
745 interleaved output processing. The RX flow control api can be used to
746 force compressed input processing to match the rate of compressed output
747 processing (test--echo shows an example of how to do this).
748
749 - when being "deflate-frame" for compatibility he uses the same default zlib
750 settings as the old "deflate-frame", but instead of exponentially increasing
751 malloc allocations until the whole output will fit, he observes the default
752 input and output chunking buffer sizes of "permessage-deflate", that's
753 1024 in and 1024 out at a time.
754
7552) deflate-stream has been disabled for many versions (for over a year) and is
756now removed. Browsers are now standardizing on "permessage-deflate" / RFC7692
757
7583) struct lws_extension is simplified, and lws extensions now have a public
759api (their callback) for use in user code to compose extensions and options
760the user code wants. lws_get_internal_exts() is deprecated but kept around
761as a NOP. The changes allow one extension implementation to go by different
762names and allows the user client code to control option offers per-ext.
763
764The test client and server are updated to use the new way. If you use
765the old way it should still work, but extensions will be disabled until you
766update your code.
767
768Extensions are now responsible for allocating and per-instance private struct
769at instance construction time and freeing it when the instance is destroyed.
770Not needing to know the size means the extension's struct can be opaque
771to user code.
772
773
Andy Green3df58002015-12-25 12:44:12 +0800774User api additions
775------------------
776
Andy Green200a6a22016-02-15 20:36:02 +08007771) The info struct gained three new members
Andy Green3df58002015-12-25 12:44:12 +0800778
779 - max_http_header_data: 0 for default (1024) or set the maximum amount of known
780 http header payload that lws can deal with. Payload in unknown http
781 headers is dropped silently. If for some reason you need to send huge
782 cookies or other HTTP-level headers, you can now increase this at context-
783 creation time.
784
785 - max_http_header_pool: 0 for default (16) or set the maximum amount of http
786 headers that can be tracked by lws in this context. For the server, if
787 the header pool is completely in use then accepts on the listen socket
788 are disabled until one becomes free. For the client, if you simultaneously
789 have pending connects for more than this number of client connections,
790 additional connects will fail until some of the pending connections timeout
791 or complete.
792
Andy Green200a6a22016-02-15 20:36:02 +0800793 - timeout_secs: 0 for default (currently 20s), or set the library's
794 network activity timeout to the given number of seconds
795
Andy Green3df58002015-12-25 12:44:12 +0800796HTTP header processing in lws only exists until just after the first main
797callback after the HTTP handshake... for ws connections that is ESTABLISHED and
798for HTTP connections the HTTP callback.
799
800So these settings are not related to the maximum number of simultaneous
Andy Green3246ebb2015-12-26 12:03:06 +0800801connections, but the number of HTTP handshakes that may be expected or ongoing,
Andy Green3df58002015-12-25 12:44:12 +0800802or have just completed, at one time. The reason it's useful is it changes the
803memory allocation for header processing to be one-time at context creation
804instead of every time there is a new connection, and gives you control over
805the peak allocation.
806
807Setting max_http_header_pool to 1 is fine it will just queue incoming
808connections before the accept as necessary, you can still have as many
Andy Green5b85e392015-12-26 13:23:11 +0800809simultaneous post-header connections as you like. Since the http header
810processing is completed and the allocation released after ESTABLISHED or the
811HTTP callback, even with a pool of 1 many connections can be handled rapidly.
812
Andy Green066a7a12015-12-26 15:47:06 +08008132) There is a new callback that allows the user code to get acccess to the
814optional close code + aux data that may have been sent by the peer.
815
816LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
817 The peer has sent an unsolicited Close WS packet. @in and
818 @len are the optional close code (first 2 bytes, network
819 order) and the optional additional information which is not
820 defined in the standard, and may be a string or non-human-
821 readble data.
822 If you return 0 lws will echo the close and then close the
Andy Green67112662016-01-11 11:34:01 +0800823 connection. If you return nonzero lws will just close the
824 connection.
Andy Green066a7a12015-12-26 15:47:06 +0800825
826As usual not handling it does the right thing, if you're not interested in it
827just ignore it.
828
829The test server has "open and close" testing buttons at the bottom, if you
830open and close that connection, on close it will send a close code 3000 decimal
831and the string "Bye!" as the aux data.
832
833The test server dumb-increment callback handles this callback reason and prints
834
835lwsts[15714]: LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len 6
836lwsts[15714]: 0: 0x0B
837lwsts[15714]: 1: 0xB8
838lwsts[15714]: 2: 0x42
839lwsts[15714]: 3: 0x79
840lwsts[15714]: 4: 0x65
841lwsts[15714]: 5: 0x21
842
Andy Green1fb95e82015-12-26 17:20:34 +08008433) There is a new API to allow the user code to control the content of the
844close frame sent when about to return nonzero from the user callback to
845indicate the connection should close.
846
847/**
848 * lws_close_reason - Set reason and aux data to send with Close packet
849 * If you are going to return nonzero from the callback
850 * requesting the connection to close, you can optionally
851 * call this to set the reason the peer will be told if
852 * possible.
853 *
854 * @wsi: The websocket connection to set the close reason on
855 * @status: A valid close status from websocket standard
856 * @buf: NULL or buffer containing up to 124 bytes of auxiliary data
857 * @len: Length of data in @buf to send
858 */
859LWS_VISIBLE LWS_EXTERN void
860lws_close_reason(struct lws *wsi, enum lws_close_status status,
861 unsigned char *buf, size_t len);
862
863An extra button is added to the "open and close" test server page that requests
864that the test server close the connection from his end.
865
866The test server code will do so by
867
868 lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY,
869 (unsigned char *)"seeya", 5);
870 return -1;
871
872The browser shows the close code and reason he received
873
874websocket connection CLOSED, code: 1001, reason: seeya
875
Vijay Khurdiyae73d4462016-01-15 16:21:51 +08008764) There's a new context creation time option flag
Andy Green44a7f652015-12-29 11:20:09 +0800877
878LWS_SERVER_OPTION_VALIDATE_UTF8
879
880if you set it in info->options, then TEXT and CLOSE frames will get checked to
881confirm that they contain valid UTF-8. If they don't, the connection will get
882closed by lws.
883
Vijay Khurdiyae73d4462016-01-15 16:21:51 +08008845) ECDH Certs are now supported. Enable the CMake option
885
886cmake .. -DLWS_SSL_SERVER_WITH_ECDH_CERT=1
887
888**and** the info->options flag
889
Andy Greenff696482016-02-17 07:46:27 +0800890LWS_SERVER_OPTION_SSL_ECDH
Vijay Khurdiyae73d4462016-01-15 16:21:51 +0800891
892to build in support and select it at runtime.
893
Andy Greenff696482016-02-17 07:46:27 +08008946) There's a new api lws_parse_uri() that simplifies chopping up
Andy Green809d69a2016-01-14 11:37:56 +0800895https://xxx:yyy/zzz uris into parts nicely. The test client now uses this
Andy Greend3a55052016-01-19 03:34:24 +0800896to allow proper uris as well as the old address style.
897
8987) SMP support is integrated into LWS without any internal threading. It's
899very simple to use, libwebsockets-test-server-pthread shows how to do it,
900use -j <n> argument there to control the number of service threads up to 32.
901
902Two new members are added to the info struct
903
904 unsigned int count_threads;
905 unsigned int fd_limit_per_thread;
906
907leave them at the default 0 to get the normal singlethreaded service loop.
908
909Set count_threads to n to tell lws you will have n simultaneous service threads
910operating on the context.
911
912There is still a single listen socket on one port, no matter how many
913service threads.
914
915When a connection is made, it is accepted by the service thread with the least
916connections active to perform load balancing.
917
918The user code is responsible for spawning n threads running the service loop
919associated to a specific tsi (Thread Service Index, 0 .. n - 1). See
920the libwebsockets-test-server-pthread for how to do.
921
922If you leave fd_limit_per_thread at 0, then the process limit of fds is shared
923between the service threads; if you process was allowed 1024 fds overall then
924each thread is limited to 1024 / n.
925
926You can set fd_limit_per_thread to a nonzero number to control this manually, eg
927the overall supported fd limit is less than the process allowance.
928
929You can control the context basic data allocation for multithreading from Cmake
930using -DLWS_MAX_SMP=, if not given it's set to 32. The serv_buf allocation
931for the threads (currently 4096) is made at runtime only for active threads.
932
933Because lws will limit the requested number of actual threads supported
934according to LWS_MAX_SMP, there is an api lws_get_count_threads(context) to
935discover how many threads were actually allowed when the context was created.
936
937It's required to implement locking in the user code in the same way that
938libwebsockets-test-server-pthread does it, for the FD locking callbacks.
939
Andy Greenba119e92016-01-26 21:40:32 +0800940If LWS_MAX_SMP=1, then there is no code related to pthreads compiled in the
941library. If more than 1, a small amount of pthread mutex code is built into
942the library.
Andy Green809d69a2016-01-14 11:37:56 +0800943
Andy Greenba119e92016-01-26 21:40:32 +08009448) New API
945
946LWS_VISIBLE struct lws *
947lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd)
948
949allows foreign sockets accepted by non-lws code to be adopted by lws as if they
950had just been accepted by lws' own listen socket.
Andy Green3df58002015-12-25 12:44:12 +0800951
Danomi Czaski4e9c7f32016-01-28 09:40:53 +08009529) X-Real-IP: header has been added as WSI_TOKEN_HTTP_X_REAL_IP
953
Andy Green86ed65f2016-02-14 09:27:41 +080095410) Libuv support is added, there are new related user apis
955
956typedef void (lws_uv_signal_cb_t)(uv_loop_t *l, uv_signal_t *w, int revents);
957
958LWS_VISIBLE LWS_EXTERN int
959lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint,
960 lws_uv_signal_cb_t *cb);
961
962LWS_VISIBLE LWS_EXTERN int
963lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi);
964
965LWS_VISIBLE void
966lws_uv_sigint_cb(uv_loop_t *loop, uv_signal_t *watcher, int revents);
967
968and CMAKE option
969
970LWS_WITH_LIBUV
971
Danomi Czaski4e9c7f32016-01-28 09:40:53 +0800972
Andy Green3246ebb2015-12-26 12:03:06 +0800973User api changes
974----------------
975
9761) LWS_SEND_BUFFER_POST_PADDING is now 0 and deprecated. You can remove it; if
977you still use it, obviously it does nothing. Old binary code with nonzero
978LWS_SEND_BUFFER_POST_PADDING is perfectly compatible, the old code just
Andy Green5b85e392015-12-26 13:23:11 +0800979allocated a buffer bigger than the library is going to use.
Andy Green3246ebb2015-12-26 12:03:06 +0800980
Andy Green5b85e392015-12-26 13:23:11 +0800981The example apps no longer use LWS_SEND_BUFFER_POST_PADDING.
Andy Green3246ebb2015-12-26 12:03:06 +0800982
Andy Green4e2ac762015-12-26 20:26:11 +0800983The only path who made use of it was sending with LWS_WRITE_CLOSE --->
Andy Green3246ebb2015-12-26 12:03:06 +0800984
Andy Green1fb95e82015-12-26 17:20:34 +08009852) Because of lws_close_reason() formalizing handling close frames,
986LWS_WRITE_CLOSE is removed from libwebsockets.h. It was only of use to send
987close frames...close frame content should be managed using lws_close_reason()
988now.
989
Andy Green44a7f652015-12-29 11:20:09 +08009903) We check for invalid CLOSE codes and complain about protocol violation in
991our close code. But it changes little since we were in the middle of closing
992anyway.
993
9944) zero-length RX frames and zero length TX frames are now allowed.
995
9965) Pings and close used to be limited to 124 bytes, the correct limit is 125
997so that is now also allowed.
Andy Green3246ebb2015-12-26 12:03:06 +0800998
Steffen Vogelf9267172016-02-09 07:19:15 +01009996) LWS_PRE is provided as a synonym for LWS_SEND_BUFFER_PRE_PADDING, either is
Andy Green67112662016-01-11 11:34:01 +08001000valid to use now.
1001
10027) There's generic support for RFC7462 style extension options built into the
1003library now. As a consequence, a field "options" is added to lws_extension.
1004It can be NULL if there are no options on the extension. Extension internal
1005info is part of the public abi because extensions may be implemented outside
1006the library.
1007
Danomi Czaski4e9c7f32016-01-28 09:40:53 +080010088) WSI_TOKEN_PROXY enum was accidentally defined to collide with another token
1009of value 73. That's now corrected and WSI_TOKEN_PROXY moved to his own place at
101077.
1011
Andy Green86ed65f2016-02-14 09:27:41 +080010129) With the addition of libuv support, libev is not the only event loop
1013library in town and his api names must be elaborated with _ev_
1014
1015 Callback typedef: lws_signal_cb ---> lws_ev_signal_cb_t
1016 lws_sigint_cfg --> lws_ev_sigint_cfg
1017 lws_initloop --> lws_ev_initloop
1018 lws_sigint_cb --> lws_ev_sigint_cb
1019
102010) Libev support is made compatible with multithreaded service,
1021lws_ev_initloop (was lws_initloop) gets an extra argument for the
1022thread service index (use 0 if you will just have 1 service thread).
1023
1024LWS_VISIBLE LWS_EXTERN int
Andy Greenff696482016-02-17 07:46:27 +08001025lws_ev_initloop(struct lws_context *context, ev_loop_t *loop, int tsi);
Andy Green86ed65f2016-02-14 09:27:41 +08001026
Andy Green3df58002015-12-25 12:44:12 +08001027
Andy Greenaef3dc42016-05-06 07:45:19 +08001028(for earlier changelogs, see the tagged releases)