blob: e98e6c152819a14c313514295ef2ce68f1c85586 [file] [log] [blame]
Andy Greena35c86f2013-01-31 10:16:44 +08001Changelog
2---------
3
Andy Greenfcf5b2c2017-10-16 20:09:58 +08004v2.4.0
5======
6
7 - HTTP/2 server support is now mature and usable! LWS_WITH_HTTP2=1 enables it.
8 Uses ALPN to serve HTTP/2, HTTP/1 and ws[s] connections all from the same
9 listen port seamlessly. (Requires ALPN-capable OpenSSL 1.1 or mbedTLS).
10
11 - LWS_WITH_MBEDTLS=1 at CMake now builds and works against mbedTLS instead of
12 OpenSSL. Most things work identically, although on common targets where
13 OpenSSL has acceleration, mbedTLS is many times slower in operation. However
14 it is a lot smaller codewise.
15
16 - Generic hash apis introduced that work the same on mbedTLS or OpenSSL backend
17
18 - LWS_WITH_PEER_LIMITS tracks IPs across all vhosts and allows restrictions on
19 both the number of simultaneous connections and wsi in use for any single IP
20
21 - lws_ring apis provide a generic single- or multi-tail ringbuffer... mirror
22 protocol now uses this. Features include ring elements may be sized to fit
23 structs in the ringbuffer, callback when no tail any longer needs an element
24 and it can be deleted, and zerocopy options to write new members directly
25 into the ringbuffer, and use the ringbuffer element by address too.
26
27 - abstract ssh 2 server plugin included, with both plugin and standalone
28 demos provided. You can bind the plugin to a vhost and also serve full-
29 strength ssh from the vhost. IO from the ssh server is controlled by an
30 "ops" struct of callbacks for tx, rx, auth etc.
31
32 - Many fixes, cleanups, source refactors and other improvements.
33
34
Andy Greene6bd6292017-07-28 14:13:42 +080035v2.3.0
36======
37
38 - ESP32 OpenSSL support for client and server
39
40 - ESP32 4 x WLAN credential slots may be configured
41
42 - Libevent event loop support
43
44 - SOCKS5 proxy support
45
46 - lws_meta protocol for websocket connection multiplexing
47
48 - lws_vhost_destroy() added... allows dynamic removal of listening
49 vhosts. Vhosts with shared listen sockets adopt the listen socket
50 automatically if the owner is destroyed.
51
52 - IPv6 on Windows
53
54 - Improved CGI handling suitable for general CGI scripting, eg, PHP
55
56 - Convert even the "old style" test servers to use statically included
57 plugin sources
58
59 - LWS_WITH_STATS cmake option dumps resource usage and timing information
60 every few seconds to debug log, including latency information about
61 delay from asking for writeable callback to getting it
62
63 - Large (> 2GB) files may be served
64
65 - LWS_WITH_HTTP_PROXY Cmake option adds proxying mounts
66
67 - Workaround for libev build by disabling -Werror on the test app
68
69 - HTTP2 support disabled since no way to serve websockets on it
70
71
Andy Green6be573f2017-03-06 15:35:45 +080072v2.2.0
73======
74
75Major new features
76
77 - A mount can be protected by Basic Auth... in lwsws it looks like this
78
79 ```
80{
81 "mountpoint": "/basic-auth",
82 "origin": "file://_lws_ddir_/libwebsockets-test-server/private",
83 "basic-auth": "/var/www/balogins-private"
84}
85```
86
87The text file named in `basic-auth` contains user:password information
88one per line.
89
90See README.lwsws.md for more information.
91
92 - RFC7233 RANGES support in lws server... both single and multipart.
93 This allows seeking for multimedia file serving and download resume.
94 It's enabled by default but can be disabled by CMake option.
95
96 - On Linux, lwsws can reload configuration without dropping ongoing
97 connections, when sent a SIGHUP. The old configuration drops its
98 listen sockets so the new configuration can listen on them.
99 New connections connect to the server instance with the new
100 configuration. When all old connections eventually close, the old
101 instance automatically exits. This is equivalent to
102 `systemctl reload apache`
103
104 - New `adopt` api allow adoption including SSL negotiation and
105 for raw sockets and file descriptors.
106
107 - Chunked transfer encoding supported for client and server
108
109 - Adaptations to allow operations inside OPTEE Secure World
110
111 - ESP32 initial port - able to do all test server functions. See
112 README.build.md
113
114 - Serving gzipped files from inside a ZIP file is supported... this
115 includes directly serving the gzipped content if the client
116 indicated it could accept it (ie, almost all browsers) saving
117 bandwidth and time. For clients that can't accept it, lws
118 automatically decompresses and serves the content in memory-
119 efficient chunks. Only a few hundred bytes of heap are needed
120 to serve any size file from inside the zip. See README.coding.md
121
122 - RAW file descriptors may now be adopted into the lws event loop,
123 independent of event backend (including poll service).
124 See README.coding.md
125
126 - RAW server socket descriptors may now be enabled on the vhost if
127 the first thing sent on the connection is not a valid http method.
128 The user code can associate these with a specific protocol per
129 vhost, and RAW-specific callbacks appear there for creation, rx,
130 writable and close. See libwebsockets-test-server-v2.0 for an example.
131 See README.coding.md
132
133 - RAW client connections are now possible using the method "RAW".
134 After connection, the socket is associated to the protocol
135 named in the client connection info and RAW-specific callbacks
136 appear there for creation, rx, writable and close.
137 See libwebsockets-test-client (with raw://) for an example.
138 See README.coding.md
139
140
Andy Green73557502016-10-06 21:48:20 +0800141v2.1.0
142======
143
144Major new features
145
146 - Support POST arguments, including multipart and file attachment
147
148 - Move most of lwsws into lws, make the stub CC0
149
150 - Add loopback test plugin to confirm client ws / http coexistence
151
152 - Integrate lwsws testing on Appveyor (ie, windows)
153
154 - Introduce helpers for sql, urlencode and urldecode sanitation
155
156 - Introduce LWS_CALLBACK_HTTP_BIND_PROTOCOL / DROP_PROTOCOL that
157 are compatible with http:/1.1 pipelining and different plugins
158 owning different parts of the URL space
159
160 - lwsgs - Generic Sessions plugin supports serverside sessions,
161 cookies, hashed logins, forgot password etc
162
163 - Added APIs for sending email to SMTP servers
164
165 - Messageboard example plugin for lwsgs
166
167 - Automatic PING sending at fixed intervals and close if no response
168
169 - Change default header limit in ah to 4096 (from 1024)
170
171 - Add SNI matching for wildcards if no specific wildcard vhost name match
172
173 - Convert docs to Doxygen
174
175 - ESP8266 support ^^
176
Enno Boland7731a3e2016-05-05 22:08:41 +0200177Fixes
178-----
179
Andy Green73557502016-10-06 21:48:20 +0800180See git log v2.0.0..
Enno Boland7731a3e2016-05-05 22:08:41 +0200181
Andy Greenfb8be052016-05-12 19:39:29 +0800182
Enno Boland7731a3e2016-05-05 22:08:41 +0200183
Andy Green55006432016-05-05 09:40:18 +0800184v2.0.0
185======
186
187Summary
188-------
189
190 - There are only api additions, the api is compatible with v1.7.x. But
191 there is necessarily an soname bump to 8.
192
193 - If you are using lws client, you mainly need to be aware the option
194 LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT is needed at context-creation time
195 if you will use SSL.
196
197 - If you are using lws for serving, the above is also true but there are
198 many new features to simplify your code (and life). There is a
199 summany online here
200
201 https://libwebsockets.org/lws-2.0-new-features.html
202
203 but basically the keywords are vhosts, mounts and plugins. You can now
204 do the web serving part from lws without any user callback code at all.
205 See ./test-server/test-server-v2.0.c for an example, it has no user
206 code for ws either since it uses the protocol plugins... that one C file
207 is all that is needed to do the whole test server function.
208
209 You now have the option to use a small generic ws-capable webserver
210 "lwsws" and write your ws part as a plugin. That eliminates even
211 cut-and-pasting the test server code and offers more configurable
212 features like control over http cacheability in JSON.
213
214
Andy Green0c3cc2e2016-02-20 09:12:52 +0800215Fixes
216-----
217
Andy Green55006432016-05-05 09:40:18 +0800218These are already in 1.7.x series
219
Andy Green0c3cc2e2016-02-20 09:12:52 +08002201) MAJOR (Windows-only) fix assert firing
221
2222) MAJOR http:/1.1 connections handled by lws_return_http_status() did not
223get sent a content-length resulting in the link hanging until the peer closed
224it. attack.sh updated to add a test for this.
225
Andy Green26d42492016-02-24 12:40:21 +08002263) MINOR An error about hdr struct in _lws_ws_related is corrected, it's not
227known to affect anything until after it was fixed
228
Andy Green5c0bcf42016-02-24 21:27:46 +08002294) MINOR During the close shutdown wait state introduced at v1.7, if something
230requests callback on writeable for the socket it will busywait until the
231socket closes
232
Andy Greendbfbbb42016-02-24 20:58:19 +08002335) MAJOR Although the test server has done it for a few versions already, it
234is now required for the user code to explicitly call
235
236 if (lws_http_transaction_completed(wsi))
237 return -1;
238
239when it finishes replying to a transaction in http. Previously the library
240did it for you, but that disallowed large, long transfers with multiple
241trips around the event loop (and cgi...).
242
Andy Green4ba798d2016-02-25 21:50:49 +08002436) MAJOR connections on ah waiting list that closed did not get removed from
244the waiting list...
245
Andy Green83af28a2016-02-28 10:55:31 +08002467) MAJOR since we added the ability to hold an ah across http keepalive
247transactions where more headers had already arrived, we broke the ability
248to tell if more headers had arrived. Result was if the browser didn't
249close the keepalive, we retained ah for the lifetime of the keepalive,
250using up the pool.
251
Andy Green442e1c82016-02-29 10:10:42 +08002528) MAJOR windows-only-POLLHUP was not coming
253
Andy Green4f5ebec2016-03-09 23:13:31 +08002549) Client should not send ext hdr if no exts
Andy Greendbfbbb42016-02-24 20:58:19 +0800255
Andy Green0c3cc2e2016-02-20 09:12:52 +0800256Changes
257-------
258
2591) MINOR test-server gained some new switches
260
261 -C <file> use external SSL cert file
262 -K <file> use external SSL key file
263 -A <file> use external SSL CA cert file
264
265 -u <uid> set effective uid
266 -g <gid> set effective gid
267
268together you can use them like this to have the test-server work with the
269usual purchased SSL certs from an official CA.
270
271 --ssl -C your.crt -K your.key -A your.cer -u 99 -g 99
272
2732) MINOR the OpenSSL magic to setup ECDH cipher usage is implemented in the
274library, and the ciphers restricted to use ECDH only.
275Using this, the lws test server can score an A at SSLLABS test
276
2773) MINOR STS (SSL always) header is added to the test server if you use --ssl. With
278that, we score A+ at SSLLABS test
279
2804) MINOR daemonize function (disabled at cmake by default) is updated to work
281with systemd
282
2835) MINOR example systemd .service file now provided for test server
284(not installed by default)
285
Andy Green0ad1a6e2016-02-20 14:05:55 +08002866) test server html is updated with tabs and a new live server monitoring
287feature. Input sanitization added to the js.
288
Andy Green2d8d35a2016-02-29 14:19:16 +08002897) client connections attempted when no ah is free no longer fail, they are
290just deferred until an ah becomes available.
291
Andy Greena661ee52016-02-29 13:18:30 +08002928) The test client pays attention to if you give it an http:/ or https://
293protocol string to its argument in URL format. If so, it stays in http[s]
294client mode and doesn't upgrade to ws[s], allowing you to do generic http client
Andy Green5c8906e2016-03-13 16:44:19 +0800295operations. Receiving transfer-encoding: chunked is supported.
Andy Greena661ee52016-02-29 13:18:30 +0800296
Andy Green1e5a9ad2016-03-20 11:59:53 +08002979) If you enable -DLWS_WITH_HTTP_PROXY=1 at cmake, the test server has a
298new URI path http://localhost:7681/proxytest If you visit here, a client
299connection to http://example.com:80 is spawned, and the results piped on
300to your original connection.
301
30210) Also with LWS_WITH_HTTP_PROXY enabled at cmake, lws wants to link to an
303additional library, "libhubbub". This allows lws to do html rewriting on the
304fly, adjusting proxied urls in a lightweight and fast way.
Andy Greenfb5f33b2016-03-01 07:19:01 +0800305
Andy Greenc6fd3602016-03-23 09:22:11 +080030611) There's a new context creation flag LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT,
307this is included automatically if you give any other SSL-related option flag.
308If you give no SSL-related option flag, nor this one directly, then even
309though SSL support may be compiled in, it is never initialized nor used for the
310whole lifetime of the lws context.
311
312Conversely in order to prepare the context to use SSL, even though, eg, you
313are not listening on SSL but will use SSL client connections later, you must
314give this flag explicitly to make sure SSL is initialized.
315
Andy Green2d8d35a2016-02-29 14:19:16 +0800316
Andy Greend7fddad2016-02-18 20:36:55 +0800317User API additions
318------------------
319
Andy Green0c3cc2e2016-02-20 09:12:52 +08003201) MINOR APIBREAK There's a new member in struct lws_context_creation_info, ecdh_curve,
Andy Greend7fddad2016-02-18 20:36:55 +0800321which lets you set the name of the ECDH curve OpenSSL should use. By
322default (if you leave ecdh_curve NULL) it will use "prime256v1"
323
Andy Green51d9afa2016-02-24 11:05:56 +08003242) MINOR NEWAPI It was already possible to adopt a foreign socket that had not
325been read from using lws_adopt_socket() since v1.7. Now you can adopt a
326partially-used socket if you don't need SSL, by passing it what you read
327so it can drain that before reading from the socket.
328
329LWS_VISIBLE LWS_EXTERN struct lws *
330lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd,
331 const char *readbuf, size_t len);
Andy Greend7fddad2016-02-18 20:36:55 +0800332
Andy Green6a8099b2016-02-21 21:25:48 +08003333) MINOR NEWAPI CGI type "network io" subprocess execution is now possible from
334a simple api.
335
336LWS_VISIBLE LWS_EXTERN int
Andy Green1a138852016-03-20 11:55:25 +0800337lws_cgi(struct lws *wsi, char * const *exec_array, int script_uri_path_len,
338 int timeout_secs);
Andy Green6a8099b2016-02-21 21:25:48 +0800339
340LWS_VISIBLE LWS_EXTERN int
341lws_cgi_kill(struct lws *wsi);
342
343To use it, you must first set the cmake option
344
345$ cmake .. -DLWS_WITH_CGI=1
346
347See test-server-http.c and test server path
348
349http://localhost:7681/cgitest
350
351stdin gets http body, you can test it with wget
352
353$ echo hello > hello.txt
354$ wget http://localhost:7681/cgitest --post-file=hello.txt -O- --quiet
355lwstest script
356read="hello"
357
Andy Green1a138852016-03-20 11:55:25 +0800358The test script returns text/html table showing /proc/meminfo. But the cgi
359support is complete enough to run cgit cgi.
360
Andy Greend61bed32016-02-25 15:01:55 +08003614) There is a helper api for forming logging timestamps
362
363LWS_VISIBLE int
364lwsl_timestamp(int level, char *p, int len)
365
366this generates this kind of timestamp for use as logging preamble
367
368lwsts[13116]: [2016/01/25 14:52:52:8386] NOTICE: Initial logging level 7
369
Andy Greena661ee52016-02-29 13:18:30 +08003705) struct lws_client_connect_info has a new member
371
372 const char *method
373
374If it's NULL, then everything happens as before, lws_client_connect_via_info()
375makes a ws or wss connection to the address given.
376
377If you set method to a valid http method like "GET", though, then this method
378is used and the connection remains in http[s], it's not upgraded to ws[s].
379
380So with this, you can perform http[s] client operations as well as ws[s] ones.
381
382There are 4 new related callbacks
383
384 LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP = 44,
385 LWS_CALLBACK_CLOSED_CLIENT_HTTP = 45,
386 LWS_CALLBACK_RECEIVE_CLIENT_HTTP = 46,
387 LWS_CALLBACK_COMPLETED_CLIENT_HTTP = 47,
Andy Green6a8099b2016-02-21 21:25:48 +0800388
Andy Green494418a2016-03-02 09:17:22 +08003896) struct lws_client_connect_info has a new member
390
391 const char *parent_wsi
392
393if non-NULL, the client wsi is set to be a child of parent_wsi. This ensures
394if parent_wsi closes, then the client child is closed just before.
395
Andy Green0f9904f2016-03-17 15:26:49 +08003967) If you're using SSL, there's a new context creation-time option flag
397LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS. If you give this, non-ssl
398connections to the server listen port are accepted and receive a 301
399redirect to / on the same host and port using https://
400
Andy Greenc5376b12016-04-08 09:45:49 +08004018) User code may set per-connection extension options now, using a new api
402"lws_set_extension_option()".
403
404This should be called from the ESTABLISHED callback like this
405
406 lws_set_extension_option(wsi, "permessage-deflate",
407 "rx_buf_size", "12"); /* 1 << 12 */
408
409If the extension is not active (missing or not negotiated for the
410connection, or extensions are disabled on the library) the call is
411just returns -1. Otherwise the connection's extension has its
412named option changed.
413
414The extension may decide to alter or disallow the change, in the
415example above permessage-deflate restricts the size of his rx
416output buffer also considering the protocol's rx_buf_size member.
417
418
Andy Greencd0c6962016-03-28 10:12:37 +0800419New application lwsws
420---------------------
421
422A libwebsockets-based general webserver is built by default now, lwsws.
423
424It's configured by JSON, by default in
425
426 /etc/lwsws/conf
427
428which contains global lws context settings like this
429
430{
431 "global": {
432 "uid": "99",
433 "gid": "99",
434 "interface": "eth0",
435 "count-threads": "1"
436 }
437}
438
439 /etc/lwsws/conf.d/*
440
441which contains zero or more files describing vhosts, like this
442
443{
444 "vhosts": [
445 { "name": "warmcat.com",
446 "port": "443",
447 "host-ssl-key": "/etc/pki/tls/private/warmcat.com.key",
448 "host-ssl-cert": "/etc/pki/tls/certs/warmcat.com.crt",
449 "host-ssl-ca": "/etc/pki/tls/certs/warmcat.com.cer",
450 "mounts": [
451 { "/": [
452 { "home": "file:///var/www/warmcat.com" },
453 { "default": "index.html" }
454 ]
455 }
456 ]
457 }
458 ]
459}
460
461
Andy Green0c3cc2e2016-02-20 09:12:52 +0800462
Andy Green9c60ed92016-02-16 12:32:18 +0800463v1.7.0
464======
465
Andy Green67112662016-01-11 11:34:01 +0800466Extension Changes
467-----------------
468
4691) There is now a "permessage-deflate" / RFC7692 implementation. It's very
470similar to "deflate-frame" we have offered for a long while; deflate-frame is
471now provided as an alias of permessage-deflate.
472
473The main differences are that the new permessage-deflate implementation:
474
475 - properly performs streaming respecting input and output buffer limits. The
476 old deflate-frame implementation could only work on complete deflate input
477 and produce complete inflate output for each frame. The new implementation
478 only mallocs buffers at initialization.
479
480 - goes around the event loop after each input package is processed allowing
481 interleaved output processing. The RX flow control api can be used to
482 force compressed input processing to match the rate of compressed output
483 processing (test--echo shows an example of how to do this).
484
485 - when being "deflate-frame" for compatibility he uses the same default zlib
486 settings as the old "deflate-frame", but instead of exponentially increasing
487 malloc allocations until the whole output will fit, he observes the default
488 input and output chunking buffer sizes of "permessage-deflate", that's
489 1024 in and 1024 out at a time.
490
4912) deflate-stream has been disabled for many versions (for over a year) and is
492now removed. Browsers are now standardizing on "permessage-deflate" / RFC7692
493
4943) struct lws_extension is simplified, and lws extensions now have a public
495api (their callback) for use in user code to compose extensions and options
496the user code wants. lws_get_internal_exts() is deprecated but kept around
497as a NOP. The changes allow one extension implementation to go by different
498names and allows the user client code to control option offers per-ext.
499
500The test client and server are updated to use the new way. If you use
501the old way it should still work, but extensions will be disabled until you
502update your code.
503
504Extensions are now responsible for allocating and per-instance private struct
505at instance construction time and freeing it when the instance is destroyed.
506Not needing to know the size means the extension's struct can be opaque
507to user code.
508
509
Andy Green3df58002015-12-25 12:44:12 +0800510User api additions
511------------------
512
Andy Green200a6a22016-02-15 20:36:02 +08005131) The info struct gained three new members
Andy Green3df58002015-12-25 12:44:12 +0800514
515 - max_http_header_data: 0 for default (1024) or set the maximum amount of known
516 http header payload that lws can deal with. Payload in unknown http
517 headers is dropped silently. If for some reason you need to send huge
518 cookies or other HTTP-level headers, you can now increase this at context-
519 creation time.
520
521 - max_http_header_pool: 0 for default (16) or set the maximum amount of http
522 headers that can be tracked by lws in this context. For the server, if
523 the header pool is completely in use then accepts on the listen socket
524 are disabled until one becomes free. For the client, if you simultaneously
525 have pending connects for more than this number of client connections,
526 additional connects will fail until some of the pending connections timeout
527 or complete.
528
Andy Green200a6a22016-02-15 20:36:02 +0800529 - timeout_secs: 0 for default (currently 20s), or set the library's
530 network activity timeout to the given number of seconds
531
Andy Green3df58002015-12-25 12:44:12 +0800532HTTP header processing in lws only exists until just after the first main
533callback after the HTTP handshake... for ws connections that is ESTABLISHED and
534for HTTP connections the HTTP callback.
535
536So these settings are not related to the maximum number of simultaneous
Andy Green3246ebb2015-12-26 12:03:06 +0800537connections, but the number of HTTP handshakes that may be expected or ongoing,
Andy Green3df58002015-12-25 12:44:12 +0800538or have just completed, at one time. The reason it's useful is it changes the
539memory allocation for header processing to be one-time at context creation
540instead of every time there is a new connection, and gives you control over
541the peak allocation.
542
543Setting max_http_header_pool to 1 is fine it will just queue incoming
544connections before the accept as necessary, you can still have as many
Andy Green5b85e392015-12-26 13:23:11 +0800545simultaneous post-header connections as you like. Since the http header
546processing is completed and the allocation released after ESTABLISHED or the
547HTTP callback, even with a pool of 1 many connections can be handled rapidly.
548
Andy Green066a7a12015-12-26 15:47:06 +08005492) There is a new callback that allows the user code to get acccess to the
550optional close code + aux data that may have been sent by the peer.
551
552LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
553 The peer has sent an unsolicited Close WS packet. @in and
554 @len are the optional close code (first 2 bytes, network
555 order) and the optional additional information which is not
556 defined in the standard, and may be a string or non-human-
557 readble data.
558 If you return 0 lws will echo the close and then close the
Andy Green67112662016-01-11 11:34:01 +0800559 connection. If you return nonzero lws will just close the
560 connection.
Andy Green066a7a12015-12-26 15:47:06 +0800561
562As usual not handling it does the right thing, if you're not interested in it
563just ignore it.
564
565The test server has "open and close" testing buttons at the bottom, if you
566open and close that connection, on close it will send a close code 3000 decimal
567and the string "Bye!" as the aux data.
568
569The test server dumb-increment callback handles this callback reason and prints
570
571lwsts[15714]: LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len 6
572lwsts[15714]: 0: 0x0B
573lwsts[15714]: 1: 0xB8
574lwsts[15714]: 2: 0x42
575lwsts[15714]: 3: 0x79
576lwsts[15714]: 4: 0x65
577lwsts[15714]: 5: 0x21
578
Andy Green1fb95e82015-12-26 17:20:34 +08005793) There is a new API to allow the user code to control the content of the
580close frame sent when about to return nonzero from the user callback to
581indicate the connection should close.
582
583/**
584 * lws_close_reason - Set reason and aux data to send with Close packet
585 * If you are going to return nonzero from the callback
586 * requesting the connection to close, you can optionally
587 * call this to set the reason the peer will be told if
588 * possible.
589 *
590 * @wsi: The websocket connection to set the close reason on
591 * @status: A valid close status from websocket standard
592 * @buf: NULL or buffer containing up to 124 bytes of auxiliary data
593 * @len: Length of data in @buf to send
594 */
595LWS_VISIBLE LWS_EXTERN void
596lws_close_reason(struct lws *wsi, enum lws_close_status status,
597 unsigned char *buf, size_t len);
598
599An extra button is added to the "open and close" test server page that requests
600that the test server close the connection from his end.
601
602The test server code will do so by
603
604 lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY,
605 (unsigned char *)"seeya", 5);
606 return -1;
607
608The browser shows the close code and reason he received
609
610websocket connection CLOSED, code: 1001, reason: seeya
611
Vijay Khurdiyae73d4462016-01-15 16:21:51 +08006124) There's a new context creation time option flag
Andy Green44a7f652015-12-29 11:20:09 +0800613
614LWS_SERVER_OPTION_VALIDATE_UTF8
615
616if you set it in info->options, then TEXT and CLOSE frames will get checked to
617confirm that they contain valid UTF-8. If they don't, the connection will get
618closed by lws.
619
Vijay Khurdiyae73d4462016-01-15 16:21:51 +08006205) ECDH Certs are now supported. Enable the CMake option
621
622cmake .. -DLWS_SSL_SERVER_WITH_ECDH_CERT=1
623
624**and** the info->options flag
625
Andy Greenff696482016-02-17 07:46:27 +0800626LWS_SERVER_OPTION_SSL_ECDH
Vijay Khurdiyae73d4462016-01-15 16:21:51 +0800627
628to build in support and select it at runtime.
629
Andy Greenff696482016-02-17 07:46:27 +08006306) There's a new api lws_parse_uri() that simplifies chopping up
Andy Green809d69a2016-01-14 11:37:56 +0800631https://xxx:yyy/zzz uris into parts nicely. The test client now uses this
Andy Greend3a55052016-01-19 03:34:24 +0800632to allow proper uris as well as the old address style.
633
6347) SMP support is integrated into LWS without any internal threading. It's
635very simple to use, libwebsockets-test-server-pthread shows how to do it,
636use -j <n> argument there to control the number of service threads up to 32.
637
638Two new members are added to the info struct
639
640 unsigned int count_threads;
641 unsigned int fd_limit_per_thread;
642
643leave them at the default 0 to get the normal singlethreaded service loop.
644
645Set count_threads to n to tell lws you will have n simultaneous service threads
646operating on the context.
647
648There is still a single listen socket on one port, no matter how many
649service threads.
650
651When a connection is made, it is accepted by the service thread with the least
652connections active to perform load balancing.
653
654The user code is responsible for spawning n threads running the service loop
655associated to a specific tsi (Thread Service Index, 0 .. n - 1). See
656the libwebsockets-test-server-pthread for how to do.
657
658If you leave fd_limit_per_thread at 0, then the process limit of fds is shared
659between the service threads; if you process was allowed 1024 fds overall then
660each thread is limited to 1024 / n.
661
662You can set fd_limit_per_thread to a nonzero number to control this manually, eg
663the overall supported fd limit is less than the process allowance.
664
665You can control the context basic data allocation for multithreading from Cmake
666using -DLWS_MAX_SMP=, if not given it's set to 32. The serv_buf allocation
667for the threads (currently 4096) is made at runtime only for active threads.
668
669Because lws will limit the requested number of actual threads supported
670according to LWS_MAX_SMP, there is an api lws_get_count_threads(context) to
671discover how many threads were actually allowed when the context was created.
672
673It's required to implement locking in the user code in the same way that
674libwebsockets-test-server-pthread does it, for the FD locking callbacks.
675
Andy Greenba119e92016-01-26 21:40:32 +0800676If LWS_MAX_SMP=1, then there is no code related to pthreads compiled in the
677library. If more than 1, a small amount of pthread mutex code is built into
678the library.
Andy Green809d69a2016-01-14 11:37:56 +0800679
Andy Greenba119e92016-01-26 21:40:32 +08006808) New API
681
682LWS_VISIBLE struct lws *
683lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd)
684
685allows foreign sockets accepted by non-lws code to be adopted by lws as if they
686had just been accepted by lws' own listen socket.
Andy Green3df58002015-12-25 12:44:12 +0800687
Danomi Czaski4e9c7f32016-01-28 09:40:53 +08006889) X-Real-IP: header has been added as WSI_TOKEN_HTTP_X_REAL_IP
689
Andy Green86ed65f2016-02-14 09:27:41 +080069010) Libuv support is added, there are new related user apis
691
692typedef void (lws_uv_signal_cb_t)(uv_loop_t *l, uv_signal_t *w, int revents);
693
694LWS_VISIBLE LWS_EXTERN int
695lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint,
696 lws_uv_signal_cb_t *cb);
697
698LWS_VISIBLE LWS_EXTERN int
699lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi);
700
701LWS_VISIBLE void
702lws_uv_sigint_cb(uv_loop_t *loop, uv_signal_t *watcher, int revents);
703
704and CMAKE option
705
706LWS_WITH_LIBUV
707
Danomi Czaski4e9c7f32016-01-28 09:40:53 +0800708
Andy Green3246ebb2015-12-26 12:03:06 +0800709User api changes
710----------------
711
7121) LWS_SEND_BUFFER_POST_PADDING is now 0 and deprecated. You can remove it; if
713you still use it, obviously it does nothing. Old binary code with nonzero
714LWS_SEND_BUFFER_POST_PADDING is perfectly compatible, the old code just
Andy Green5b85e392015-12-26 13:23:11 +0800715allocated a buffer bigger than the library is going to use.
Andy Green3246ebb2015-12-26 12:03:06 +0800716
Andy Green5b85e392015-12-26 13:23:11 +0800717The example apps no longer use LWS_SEND_BUFFER_POST_PADDING.
Andy Green3246ebb2015-12-26 12:03:06 +0800718
Andy Green4e2ac762015-12-26 20:26:11 +0800719The only path who made use of it was sending with LWS_WRITE_CLOSE --->
Andy Green3246ebb2015-12-26 12:03:06 +0800720
Andy Green1fb95e82015-12-26 17:20:34 +08007212) Because of lws_close_reason() formalizing handling close frames,
722LWS_WRITE_CLOSE is removed from libwebsockets.h. It was only of use to send
723close frames...close frame content should be managed using lws_close_reason()
724now.
725
Andy Green44a7f652015-12-29 11:20:09 +08007263) We check for invalid CLOSE codes and complain about protocol violation in
727our close code. But it changes little since we were in the middle of closing
728anyway.
729
7304) zero-length RX frames and zero length TX frames are now allowed.
731
7325) Pings and close used to be limited to 124 bytes, the correct limit is 125
733so that is now also allowed.
Andy Green3246ebb2015-12-26 12:03:06 +0800734
Steffen Vogelf9267172016-02-09 07:19:15 +01007356) LWS_PRE is provided as a synonym for LWS_SEND_BUFFER_PRE_PADDING, either is
Andy Green67112662016-01-11 11:34:01 +0800736valid to use now.
737
7387) There's generic support for RFC7462 style extension options built into the
739library now. As a consequence, a field "options" is added to lws_extension.
740It can be NULL if there are no options on the extension. Extension internal
741info is part of the public abi because extensions may be implemented outside
742the library.
743
Danomi Czaski4e9c7f32016-01-28 09:40:53 +08007448) WSI_TOKEN_PROXY enum was accidentally defined to collide with another token
745of value 73. That's now corrected and WSI_TOKEN_PROXY moved to his own place at
74677.
747
Andy Green86ed65f2016-02-14 09:27:41 +08007489) With the addition of libuv support, libev is not the only event loop
749library in town and his api names must be elaborated with _ev_
750
751 Callback typedef: lws_signal_cb ---> lws_ev_signal_cb_t
752 lws_sigint_cfg --> lws_ev_sigint_cfg
753 lws_initloop --> lws_ev_initloop
754 lws_sigint_cb --> lws_ev_sigint_cb
755
75610) Libev support is made compatible with multithreaded service,
757lws_ev_initloop (was lws_initloop) gets an extra argument for the
758thread service index (use 0 if you will just have 1 service thread).
759
760LWS_VISIBLE LWS_EXTERN int
Andy Greenff696482016-02-17 07:46:27 +0800761lws_ev_initloop(struct lws_context *context, ev_loop_t *loop, int tsi);
Andy Green86ed65f2016-02-14 09:27:41 +0800762
Andy Green3df58002015-12-25 12:44:12 +0800763
Andy Greenaef3dc42016-05-06 07:45:19 +0800764(for earlier changelogs, see the tagged releases)