blob: a7eac226248572278187829785fe0b94895f4bf0 [file] [log] [blame]
Andy Greena35c86f2013-01-31 10:16:44 +08001Changelog
2---------
3
Andy Green3df58002015-12-25 12:44:12 +08004User api additions
5------------------
6
7The info struct gained two new members
8
9 - max_http_header_data: 0 for default (1024) or set the maximum amount of known
10 http header payload that lws can deal with. Payload in unknown http
11 headers is dropped silently. If for some reason you need to send huge
12 cookies or other HTTP-level headers, you can now increase this at context-
13 creation time.
14
15 - max_http_header_pool: 0 for default (16) or set the maximum amount of http
16 headers that can be tracked by lws in this context. For the server, if
17 the header pool is completely in use then accepts on the listen socket
18 are disabled until one becomes free. For the client, if you simultaneously
19 have pending connects for more than this number of client connections,
20 additional connects will fail until some of the pending connections timeout
21 or complete.
22
23HTTP header processing in lws only exists until just after the first main
24callback after the HTTP handshake... for ws connections that is ESTABLISHED and
25for HTTP connections the HTTP callback.
26
27So these settings are not related to the maximum number of simultaneous
28connections but the number of HTTP handshakes that may be expected or ongoing,
29or have just completed, at one time. The reason it's useful is it changes the
30memory allocation for header processing to be one-time at context creation
31instead of every time there is a new connection, and gives you control over
32the peak allocation.
33
34Setting max_http_header_pool to 1 is fine it will just queue incoming
35connections before the accept as necessary, you can still have as many
36simultaneous post-header connections as you like.
37
38
Andy Green9e8d1482015-12-18 11:01:03 +080039v1.6.0-chrome48-firefox42
40=======================
41
42Major API improvements
43----------------------
44
45v1.6.0 has many cleanups and improvements in the API. Although at first it
46looks pretty drastic, user code will only need four actions to update it.
47
48 - Do the three search/replaces in your user code, /libwebsocket_/lws_/,
49 /libwebsockets_/lws_/, and /struct\ libwebsocket/struct\ lws/
50
51 - Remove the context parameter from your user callbacks
52
53 - Remove context as the first parameter from the "Eleven APIS" listed in the
54 User Api Changes section
55
56 - Add lws_get_context(wsi) as the first parameter on the "Three APIS" listed
57 in the User Api Changes section, and anywhere else you still need context
58
59That's it... generally only a handful of the 14 affected APIs are actually in
60use in your user code and you can find them quickest by compiling and visiting
61the errors each in turn. And the end results are much cleaner, more
62predictable and maintainable.
63
64
Andy Green4e442b72015-12-10 07:58:58 +080065User api additions
66------------------
67
Andy Green3f628702015-12-14 07:16:32 +0800681) lws now exposes his internal platform file abstraction in a way that can be
Andy Green4e442b72015-12-10 07:58:58 +080069both used by user code to make it platform-agnostic, and be overridden or
70subclassed by user code. This allows things like handling the URI "directory
71space" as a virtual filesystem that may or may not be backed by a regular
72filesystem. One example use is serving files from inside large compressed
73archive storage without having to unpack anything except the file being
74requested.
75
76The test server shows how to use it, basically the platform-specific part of
77lws prepares a file operations structure that lives in the lws context.
78
Andy Green3f599962015-12-14 07:21:42 +080079Helpers are provided to also leverage these platform-independent file handling
80apis
Andy Green4e442b72015-12-10 07:58:58 +080081
82static inline lws_filefd_type
Andy Green3f599962015-12-14 07:21:42 +080083lws_plat_file_open(struct lws *wsi, const char *filename,
Andy Green4e442b72015-12-10 07:58:58 +080084 unsigned long *filelen, int flags)
Andy Green4e442b72015-12-10 07:58:58 +080085static inline int
Andy Green3f599962015-12-14 07:21:42 +080086lws_plat_file_close(struct lws *wsi, lws_filefd_type fd)
Andy Green4e442b72015-12-10 07:58:58 +080087
88static inline unsigned long
Andy Green3f599962015-12-14 07:21:42 +080089lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset)
Andy Green4e442b72015-12-10 07:58:58 +080090
91static inline int
Andy Green3f599962015-12-14 07:21:42 +080092lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
93 unsigned char *buf, unsigned long len)
Andy Green4e442b72015-12-10 07:58:58 +080094
95static inline int
Andy Green3f599962015-12-14 07:21:42 +080096lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
97 unsigned char *buf, unsigned long len)
Andy Green4e442b72015-12-10 07:58:58 +080098
99The user code can also override or subclass the file operations, to either
100wrap or replace them. An example is shown in test server.
101
Andy Green3f599962015-12-14 07:21:42 +0800102A wsi can be associated with the file activity, allowing per-connection
103authentication and state to be used when interpreting the file request.
104
Andy Green3f628702015-12-14 07:16:32 +08001052) A new API void * lws_wsi_user(struct lws *wsi) lets you get the pointer to
106the user data associated with the wsi, just from the wsi.
107
Andy Green9e8d1482015-12-18 11:01:03 +08001083) URI argument handling. Libwebsockets parses and protects URI arguments
109like test.html?arg1=1&arg2=2, it decodes %xx uriencoding format and reduces
110path attacks like ../.../../etc/passwd so they cannot go behind the web
111server's /. There is a list of confirmed attacks we're proof against in
112./test-server/attack.sh.
113
114There is a new API lws_hdr_copy_fragment that should be used now to access
115the URI arguments (it returns the fragments length)
116
117 while (lws_hdr_copy_fragment(wsi, buf, sizeof(buf),
118 WSI_TOKEN_HTTP_URI_ARGS, n) > 0) {
119 lwsl_info("URI Arg %d: %s\n", ++n, buf);
120 }
121
122For the example above, calling with n=0 will return "arg1=1" and n=1 "arg2=2".
123All legal uriencodings will have been reduced in those strings.
124
125lws_hdr_copy_fragment() returns the length of the x=y fragment, so it's also
126possible to deal with arguments containing %00. If you don't care about that,
127the returned string has '\0' appended to simplify processing.
128
Andy Green4e442b72015-12-10 07:58:58 +0800129
Andy Green6d417202015-12-04 10:39:23 +0800130User api changes
131----------------
132
Andy Green1a366bf2015-12-14 07:02:51 +08001331) Three APIS
134
135 - lws_callback_on_writable_all_protocol(const struct lws_protocols *protocol)
136 - lws_callback_all_protocol(const struct lws_protocols *protocol)
137 - lws_rx_flow_allow_all_protocol(lws_rx_flow_allow_all_protocol)
138
139Now take an additional pointer to the lws_context in their first argument.
140
141The reason for this change is struct lws_protocols has been changed to remove
142members that lws used for private storage: so the protocols struct in now
143truly const and may be reused serially or simultaneously by different contexts.
144
Andy Green11c05bf2015-12-16 18:19:08 +08001452) Eleven APIs
146
147LWS_VISIBLE LWS_EXTERN int
148lws_add_http_header_by_name(struct lws_context *context,
149 struct lws *wsi,
150 const unsigned char *name,
151 const unsigned char *value,
152 int length,
153 unsigned char **p,
154 unsigned char *end);
155LWS_VISIBLE LWS_EXTERN int
156lws_finalize_http_header(struct lws_context *context,
157 struct lws *wsi,
158 unsigned char **p,
159 unsigned char *end);
160LWS_VISIBLE LWS_EXTERN int
161lws_add_http_header_by_token(struct lws_context *context,
162 struct lws *wsi,
163 enum lws_token_indexes token,
164 const unsigned char *value,
165 int length,
166 unsigned char **p,
167 unsigned char *end);
168LWS_VISIBLE LWS_EXTERN int
169lws_add_http_header_content_length(struct lws_context *context,
170 struct lws *wsi,
171 unsigned long content_length,
172 unsigned char **p,
173 unsigned char *end);
174LWS_VISIBLE LWS_EXTERN int
175lws_add_http_header_status(struct lws_context *context, struct lws *wsi,
176 unsigned int code, unsigned char **p,
177 unsigned char *end);
178
179LWS_VISIBLE LWS_EXTERN int
180lws_serve_http_file(struct lws_context *context, struct lws *wsi,
181 const char *file, const char *content_type,
182 const char *other_headers, int other_headers_len);
183LWS_VISIBLE LWS_EXTERN int
184lws_serve_http_file_fragment(struct lws_context *context, struct lws *wsi);
185
186LWS_VISIBLE LWS_EXTERN int
187lws_return_http_status(struct lws_context *context, struct lws *wsi,
188 unsigned int code, const char *html_body);
189
190LWS_VISIBLE LWS_EXTERN int
191lws_callback_on_writable(const struct lws_context *context, struct lws *wsi);
192
193LWS_VISIBLE LWS_EXTERN void
194lws_get_peer_addresses(struct lws_context *context, struct lws *wsi,
195 lws_sockfd_type fd, char *name, int name_len,
196 char *rip, int rip_len);
197
198LWS_VISIBLE LWS_EXTERN int
199lws_read(struct lws_context *context, struct lws *wsi,
200 unsigned char *buf, size_t len);
201
202no longer require their initial struct lws_context * parameter.
203
2043) Several older apis start with libwebsocket_ or libwebsockets_ while newer ones
Andy Green6d417202015-12-04 10:39:23 +0800205all begin lws_. These apis have been changed to all begin with lws_.
206
Andy Green11c05bf2015-12-16 18:19:08 +0800207To convert, search-replace
Andy Green6d417202015-12-04 10:39:23 +0800208
Andy Green11c05bf2015-12-16 18:19:08 +0800209 - libwebsockets_/lws_
210 - libwebsocket_/lws_
211 - struct\ libwebsocket/struct\ lws
Andy Green00c6d152015-12-17 07:54:44 +0800212
2134) context parameter removed from user callback.
214
215Since almost all apis no longer need the context as a parameter, it's no longer
216provided at the user callback directly.
217
218However if you need it, for ALL callbacks wsi is valid and has a valid context
Andy Green6d645392015-12-17 18:25:25 +0800219pointer you can recover using lws_get_context(wsi).
Andy Green6d417202015-12-04 10:39:23 +0800220
221
Andy Greenab620ff2015-10-28 08:39:09 +0800222v1.5-chrome47-firefox41
223=======================
MGadkari020c53c2015-08-21 16:15:36 +0530224
225User api changes
226----------------
227
228LWS_CALLBACK_CLIENT_CONNECTION_ERROR may provide an error string if in is
229non-NULL. If so, the string has length len.
230
Andy Green6d59f592015-10-15 09:12:58 +0800231LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED is available to relax the requirement
232for peer certs if you are using the option to require client certs.
233
Andy Green4c79ee72015-10-15 11:20:40 +0800234LWS_WITHOUT_BUILTIN_SHA1 cmake option forces lws to use SHA1() defined
235externally, eg, byOpenSSL, and disables build of libwebsockets_SHA1()
236
237
Andy Green16fb0132015-03-28 11:35:40 +0800238v1.4-chrome43-firefox36
239=======================
Olehfaeac3c2014-07-29 23:18:41 +0800240
241User api additions
242------------------
243
244There's a new member in the info struct used to control context creation,
245ssl_private_key_password, which allows passing into lws the passphrase on
246an SSL cetificate
247
Andy Greeneabed8d2014-08-11 12:11:36 +0800248There's a new member in struct protocols, id, which is ignored by lws but can
249be used by the user code to mark the selected protocol by user-defined version
250or capabliity flag information, for the case multiple versions of a protocol are
251supported.
252
Andy Greenb128ccc2014-08-16 09:54:27 +0800253int lws_is_ssl(wsi) added to allow user code to know if the connection was made
254over ssl or not. If LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT is used, both
255ssl and non-ssl connections are possible and may need to be treated differently
256in the user code.
257
Andy Green14425ea2014-08-18 22:49:39 +0800258int lws_partial_buffered(wsi) added... should be checked after any
259libwebsocket_write that will be followed by another libwebsocket_write inside
260the same writeable callback. If set, you can't do any more writes until the
261writeable callback is called again. If you only do one write per writeable callback,
262you can ignore this.
263
Andy Green917f43a2014-10-12 14:31:47 +0800264HTTP2-related: HTTP2 changes how headers are handled, lws now has new version-
265agnositic header creation APIs. These do the right thing depending on each
266connection's HTTP version without the user code having to know or care, except
267to make sure to use the new APIs for headers (test-server is updated to use
268them already, so look there for examples)
269
270The APIs "render" the headers into a user-provided buffer and bump *p as it
271is used. If *p reaches end, then the APIs return nonzero for error.
272
273LWS_VISIBLE LWS_EXTERN int
274lws_add_http_header_status(struct libwebsocket_context *context,
275 struct libwebsocket *wsi,
276 unsigned int code,
277 unsigned char **p,
278 unsigned char *end);
279
280Start a response header reporting status like 200, 500, etc
281
282LWS_VISIBLE LWS_EXTERN int
283lws_add_http_header_by_name(struct libwebsocket_context *context,
284 struct libwebsocket *wsi,
285 const unsigned char *name,
286 const unsigned char *value,
287 int length,
288 unsigned char **p,
289 unsigned char *end);
290
291Add a header like name: value in HTTP1.x
292
293LWS_VISIBLE LWS_EXTERN int
294lws_finalize_http_header(struct libwebsocket_context *context,
295 struct libwebsocket *wsi,
296 unsigned char **p,
297 unsigned char *end);
298
299Finish off the headers, like add the extra \r\n in HTTP1.x
300
301LWS_VISIBLE LWS_EXTERN int
302lws_add_http_header_by_token(struct libwebsocket_context *context,
303 struct libwebsocket *wsi,
304 enum lws_token_indexes token,
305 const unsigned char *value,
306 int length,
307 unsigned char **p,
308 unsigned char *end);
309
310Add a header by using a lws token as the name part. In HTTP2, this can be
311compressed to one or two bytes.
312
Olehfaeac3c2014-07-29 23:18:41 +0800313
Andy Green822241c2014-08-18 22:21:51 +0800314User api removal
315----------------
316
317protocols struct member no_buffer_all_partial_tx is removed. Under some
Peter Pentchevbb085da2015-12-03 15:55:11 +0200318conditions like rewriting extension such as compression in use, the built-in
Andy Green822241c2014-08-18 22:21:51 +0800319partial send buffering is the only way to deal with the problem, so turning
320it off is deprecated.
321
322
Andy Green917f43a2014-10-12 14:31:47 +0800323User api changes
324----------------
325
326HTTP2-related: API libwebsockets_serve_http_file() takes an extra parameter at
327the end now
328
329int other_headers_len)
330
331If you are providing other headers, they must be generated using the new
332HTTP-version-agnostic APIs, and you must provide the length of them using this
333additional parameter.
334
joseph.urciuoli4d9c8fc2014-10-16 08:53:19 +0800335struct lws_context_creation_info now has an additional member
336SSL_CTX *provided_client_ssl_ctx you may set to an externally-initialized
337SSL_CTX managed outside lws. Defaulting to zero keeps the existing behaviour of
338lws managing the context, if you memset the struct to 0 or have as a filescope
339initialized struct in bss, no need to change anything.
340
Andy Green822241c2014-08-18 22:21:51 +0800341
Andy Greenc1fdd102014-07-06 09:56:11 +0800342v1.3-chrome37-firefox30
343=======================
344
345 .gitignore | 1 -
346 CMakeLists.txt | 447 +++--
347 README.build | 35 +-
348 README.coding | 14 +
349 changelog | 66 +
350 cmake/LibwebsocketsConfig.cmake.in | 17 +
351 cmake/LibwebsocketsConfigVersion.cmake.in | 11 +
352 config.h.cmake | 18 +
353 cross-ming.cmake | 31 +
354 cross-openwrt-makefile | 91 +
355 lib/client-handshake.c | 205 ++-
356 lib/client-parser.c | 58 +-
357 lib/client.c | 158 +-
358 lib/context.c | 341 ++++
359 lib/extension-deflate-frame.c | 2 +-
360 lib/extension.c | 178 ++
361 lib/handshake.c | 287 +---
362 lib/lextable.h | 338 ++++
363 lib/libev.c | 175 ++
364 lib/libwebsockets.c | 2089 +++--------------------
365 lib/libwebsockets.h | 253 ++-
366 lib/lws-plat-unix.c | 404 +++++
367 lib/lws-plat-win.c | 358 ++++
368 lib/minilex.c | 530 +++---
369 lib/output.c | 445 ++---
370 lib/parsers.c | 682 ++++----
371 lib/pollfd.c | 239 +++
372 lib/private-libwebsockets.h | 501 +++++-
373 lib/server-handshake.c | 274 +--
374 lib/server.c | 858 ++++++++--
375 lib/service.c | 517 ++++++
376 lib/sha-1.c | 38 +-
377 lib/ssl-http2.c | 78 +
378 lib/ssl.c | 571 +++++++
379 test-server/attack.sh | 101 +-
380 test-server/test-client.c | 9 +-
381 test-server/test-echo.c | 17 +-
382 test-server/test-fraggle.c | 7 -
383 test-server/test-ping.c | 12 +-
384 test-server/test-server.c | 330 ++--
385 test-server/test.html | 4 +-
386 win32port/client/client.vcxproj | 259 ---
387 win32port/client/client.vcxproj.filters | 39 -
388 .../libwebsocketswin32.vcxproj.filters | 93 -
389 win32port/server/server.vcxproj | 276 ---
390 win32port/server/server.vcxproj.filters | 51 -
391 win32port/win32helpers/gettimeofday.h | 59 +-
392 win32port/win32helpers/netdb.h | 1 -
393 win32port/win32helpers/strings.h | 0
394 win32port/win32helpers/sys/time.h | 1 -
395 win32port/win32helpers/unistd.h | 0
396 win32port/win32helpers/websock-w32.c | 104 --
397 win32port/win32helpers/websock-w32.h | 62 -
398 win32port/win32port.sln | 100 --
399 win32port/zlib/gzio.c | 3 +-
400 55 files changed, 6779 insertions(+), 5059 deletions(-)
401
Andy Green79002562013-11-09 11:04:35 +0800402
kapejodce64fb02013-11-19 13:38:16 +0100403User api additions
404------------------
405
406POST method is supported
407
408The protocol 0 / HTTP callback can now get two new kinds of callback,
409LWS_CALLBACK_HTTP_BODY (in and len are a chunk of the body of the HTTP request)
410and LWS_CALLBACK_HTTP_BODY_COMPLETION (the expected amount of body has arrived
411and been passed to the user code already). These callbacks are used with the
412post method (see the test server for details).
413
414The period between the HTTP header completion and the completion of the body
415processing is protected by a 5s timeout.
416
417The chunks are stored in a malloc'd buffer of size protocols[0].rx_buffer_size.
418
419
James Devine5b34c972013-12-14 11:41:29 +0800420New server option you can enable from user code
421LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT allows non-SSL connections to
422also be accepted on an SSL listening port. It's disabled unless you enable
423it explicitly.
424
425
Andy Green7a132792013-12-18 09:48:26 +0800426Two new callbacks are added in protocols[0] that are optional for allowing
427limited thread access to libwebsockets, LWS_CALLBACK_LOCK_POLL and
428LWS_CALLBACK_UNLOCK_POLL.
429
430If you use them, they protect internal and external poll list changes, but if
431you want to use external thread access to libwebsocket_callback_on_writable()
432you have to implement your locking here even if you don't use external
433poll support.
434
435If you will use another thread for this, take a lot of care about managing
436your list of live wsi by doing it from ESTABLISHED and CLOSED callbacks
437(with your own locking).
438
Andrew Canaday9769f4f2014-03-23 13:25:07 +0800439If you configure cmake with -DLWS_WITH_LIBEV=1 then the code allowing the libev
440eventloop instead of the default poll() one will also be compiled in. But to
441use it, you must also set the LWS_SERVER_OPTION_LIBEV flag on the context
442creation info struct options member.
Andy Green7a132792013-12-18 09:48:26 +0800443
Andy Greenc1fdd102014-07-06 09:56:11 +0800444IPV6 is supported and enabled by default except for Windows, you can disable
445the support at build-time by giving -DLWS_IPV6=, and disable use of it even if
James Devine3f13ea22014-03-24 16:09:25 +0800446compiled in by making sure the flag LWS_SERVER_OPTION_DISABLE_IPV6 is set on
447the context creation info struct options member.
448
Andy Greenc1fdd102014-07-06 09:56:11 +0800449You can give LWS_SERVER_OPTION_DISABLE_OS_CA_CERTS option flag to
450guarantee the OS CAs will not be used, even if that support was selected at
451build-time.
452
453Optional "token limits" may be enforced by setting the member "token_limits"
454in struct lws_context_creation_info to point to a struct lws_token_limits.
455NULL means no token limits used for compatibility.
456
Andy Green7a132792013-12-18 09:48:26 +0800457
Andy Green79002562013-11-09 11:04:35 +0800458User api changes
459----------------
460
461Extra optional argument to libwebsockets_serve_http_file() allows injecion
462of HTTP headers into the canned response. Eg, cookies may be added like
463that without getting involved in having to send the header by hand.
464
Patrick Gansterer148b9452014-02-28 02:31:23 +0100465A new info member http_proxy_address may be used at context creation time to
466set the http proxy. If non-NULL, it overrides http_proxy environment var.
Andy Green79002562013-11-09 11:04:35 +0800467
Andy Greend2ec7ad2014-03-15 10:39:29 +0800468Cmake supports LWS_SSL_CLIENT_USE_OS_CA_CERTS defaulting to on, which gets
469the client to use the OS CA Roots. If you're worried somebody with the
470ability to forge for force creation of a client cert from the root CA in
471your OS, you should disable this since your selfsigned $0 cert is a lot safer
472then...
473
Andy Green79002562013-11-09 11:04:35 +0800474
Andy Green81877e62013-10-26 20:36:08 +0800475v1.23-chrome32-firefox24
476========================
477
478 Android.mk | 29 +
479 CMakeLists.txt | 573 ++++++++----
480 COPYING | 503 -----------
481 INSTALL | 365 --------
482 Makefile.am | 13 -
483 README.build | 371 ++------
484 README.coding | 63 ++
485 autogen.sh | 1578 ---------------------------------
486 changelog | 69 ++
487 cmake/FindGit.cmake | 163 ++++
488 cmake/FindOpenSSLbins.cmake | 15 +-
489 cmake/UseRPMTools.cmake | 176 ++++
490 config.h.cmake | 25 +-
491 configure.ac | 226 -----
492 cross-arm-linux-gnueabihf.cmake | 28 +
493 lib/Makefile.am | 89 --
494 lib/base64-decode.c | 98 +-
495 lib/client-handshake.c | 123 ++-
496 lib/client-parser.c | 19 +-
497 lib/client.c | 145 ++-
498 lib/daemonize.c | 4 +-
499 lib/extension.c | 2 +-
500 lib/getifaddrs.h | 4 +-
501 lib/handshake.c | 76 +-
502 lib/libwebsockets.c | 491 ++++++----
503 lib/libwebsockets.h | 164 ++--
504 lib/output.c | 214 ++++-
505 lib/parsers.c | 102 +--
506 lib/private-libwebsockets.h | 66 +-
507 lib/server-handshake.c | 5 +-
508 lib/server.c | 29 +-
509 lib/sha-1.c | 2 +-
510 libwebsockets-api-doc.html | 249 +++---
511 libwebsockets.pc.in | 11 -
512 libwebsockets.spec | 14 +-
513 m4/ignore-me | 2 -
514 scripts/FindLibWebSockets.cmake | 33 +
515 scripts/kernel-doc | 1 +
516 test-server/Makefile.am | 131 ---
517 test-server/leaf.jpg | Bin 0 -> 2477518 bytes
518 test-server/test-client.c | 78 +-
519 test-server/test-echo.c | 33 +-
520 test-server/test-fraggle.c | 26 +-
521 test-server/test-ping.c | 15 +-
522 test-server/test-server.c | 197 +++-
523 test-server/test.html | 5 +-
524 win32port/win32helpers/gettimeofday.c | 74 +-
525 win32port/win32helpers/websock-w32.h | 6 +-
526 48 files changed, 2493 insertions(+), 4212 deletions(-)
527
Andy Green54cb3462013-02-14 22:23:54 +0800528
529User api additions
530------------------
531
532 - You can now call libwebsocket_callback_on_writable() on http connectons,
533 and get a LWS_CALLBACK_HTTP_WRITEABLE callback, the same way you can
534 regulate writes with a websocket protocol connection.
535
Andy Green2672fb22013-02-22 09:54:35 +0800536 - A new member in the context creation parameter struct "ssl_cipher_list" is
537 added, replacing CIPHERS_LIST_STRING. NULL means use the ssl library
538 default list of ciphers.
539
Andy Green58f214e2013-03-09 13:03:53 +0800540 - Not really an api addition, but libwebsocket_service_fd() will now zero
541 the revents field of the pollfd it was called with if it handled the
542 descriptor. So you can tell if it is a non-lws fd by checking revents
543 after the service call... if it's still nonzero, the descriptor
544 belongs to you and you need to take care of it.
545
Andy Greenb55451c2013-03-16 12:32:27 +0800546 - libwebsocket_rx_flow_allow_all_protocol(protocol) will unthrottle all
547 connections with the established protocol. It's designed to be
548 called from user server code when it sees it can accept more input
549 and may have throttled connections using the server rx flow apis
550 while it was unable to accept any other input The user server code
551 then does not have to try to track while connections it choked, this
552 will free up all of them in one call.
553
Andy Green0c9563b2013-06-10 22:54:40 +0800554 - there's a new, optional callback LWS_CALLBACK_CLOSED_HTTP which gets
555 called when an HTTP protocol socket closes
556
Andy Green96d48fd2013-09-18 08:32:55 +0800557 - for LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION callback, the user_space alloc
558 has already been done before the callback happens. That means we can
559 use the user parameter to the callback to contain the user pointer, and
560 move the protocol name to the "in" parameter. The docs for this
561 callback are also updated to reflect how to check headers in there.
562
Andy Green5dc62ea2013-09-20 20:26:12 +0800563 - libwebsocket_client_connect() is now properly nonblocking and async. See
564 README.coding and test-client.c for information on the callbacks you
565 can rely on controlling the async connection period with.
566
Andy Green81877e62013-10-26 20:36:08 +0800567 - if your OS does not support the http_proxy environment variable convention
568 (eg, reportedly OSX), you can use a new api libwebsocket_set_proxy()
Peter Pentchevbb085da2015-12-03 15:55:11 +0200569 to set the proxy details in between context creation and the connection
Andy Green81877e62013-10-26 20:36:08 +0800570 action. For OSes that support http_proxy, that's used automatically.
Andy Greenb55451c2013-03-16 12:32:27 +0800571
Andy Green50097dd2013-02-15 22:36:30 +0800572User api changes
573----------------
574
575 - the external poll callbacks now get the socket descriptor coming from the
576 "in" parameter. The user parameter provides the user_space for the
577 wsi as it normally does on the other callbacks.
Edwin van den Oetelaar8c8a8e12013-02-20 20:56:59 +0800578 LWS_CALLBACK_FILTER_NETWORK_CONNECTION also has the socket descriptor
579 delivered by @in now instead of @user.
Andy Green50097dd2013-02-15 22:36:30 +0800580
Andy Greenfc7c5e42013-02-23 10:50:10 +0800581 - libwebsocket_write() now returns -1 for error, or the amount of data
582 actually accepted for send. Under load, the OS may signal it is
583 ready to send new data on the socket, but have only a restricted
584 amount of memory to buffer the packet compared to usual.
585
Andy Green50097dd2013-02-15 22:36:30 +0800586
Andy Greendc914cf2013-02-18 16:54:26 +0800587User api removal
588----------------
589
590 - libwebsocket_ensure_user_space() is removed from the public api, if you
591 were using it to get user_space, you need to adapt your code to only
592 use user_space inside the user callback.
593
Andy Green2672fb22013-02-22 09:54:35 +0800594 - CIPHERS_LIST_STRING is removed
595
Andy Green0097a992013-03-09 13:06:37 +0800596 - autotools build has been removed. See README.build for info on how to
597 use CMake for your platform
598
Andy Green54cb3462013-02-14 22:23:54 +0800599
Andy Green53a46782013-02-14 11:23:49 +0800600v1.21-chrome26-firefox18
601========================
602
603 - Fixes buffer overflow bug in max frame size handling if you used the
604 default protocol buffer size. If you declared rx_buffer_size in your
605 protocol, which is recommended anyway, your code was unaffected.
606
Andy Green182cb9a2013-02-13 11:54:08 +0800607v1.2-chrome26-firefox18
608=======================
609
610Diffstat
611--------
612
613 .gitignore | 16 +++
614 CMakeLists.txt | 544 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
615 LICENSE | 526 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
616 Makefile.am | 1 +
617 README | 20 +++
618 README.build | 258 ++++++++++++++++++++++++++++++++-----
619 README.coding | 52 ++++++++
620 changelog | 136 ++++++++++++++++++++
621 cmake/FindOpenSSLbins.cmake | 33 +++++
622 config.h.cmake | 173 +++++++++++++++++++++++++
623 configure.ac | 22 +++-
624 lib/Makefile.am | 20 ++-
625 lib/base64-decode.c | 2 +-
626 lib/client-handshake.c | 190 +++++++++++-----------------
627 lib/client-parser.c | 88 +++++++------
628 lib/client.c | 384 ++++++++++++++++++++++++++++++-------------------------
629 lib/daemonize.c | 32 +++--
630 lib/extension-deflate-frame.c | 58 +++++----
631 lib/extension-deflate-stream.c | 19 ++-
632 lib/extension-deflate-stream.h | 4 +-
633 lib/extension.c | 11 +-
634 lib/getifaddrs.c | 315 +++++++++++++++++++++++-----------------------
635 lib/getifaddrs.h | 30 ++---
636 lib/handshake.c | 124 +++++++++++-------
637 lib/libwebsockets.c | 736 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------
638 lib/libwebsockets.h | 237 ++++++++++++++++++++++------------
639 lib/output.c | 192 +++++++++++-----------------
640 lib/parsers.c | 966 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------
641 lib/private-libwebsockets.h | 225 +++++++++++++++++++++------------
642 lib/server-handshake.c | 82 ++++++------
643 lib/server.c | 96 +++++++-------
644 libwebsockets-api-doc.html | 189 ++++++++++++++++++----------
645 libwebsockets.spec | 17 +--
646 test-server/attack.sh | 148 ++++++++++++++++++++++
647 test-server/test-client.c | 125 +++++++++---------
648 test-server/test-echo.c | 31 +++--
649 test-server/test-fraggle.c | 32 ++---
650 test-server/test-ping.c | 52 ++++----
651 test-server/test-server.c | 129 ++++++++++++-------
652 win32port/libwebsocketswin32/libwebsocketswin32.vcxproj | 279 ----------------------------------------
653 win32port/libwebsocketswin32/libwebsocketswin32.vcxproj.filters | 23 +++-
654 41 files changed, 4398 insertions(+), 2219 deletions(-)
655
Andy Green7b405452013-02-01 10:50:15 +0800656
657User api additions
658------------------
659
660 - lws_get_library_version() returns a const char * with a string like
661 "1.1 9e7f737", representing the library version from configure.ac
662 and the git HEAD hash the library was built from
663
Andy Greena47865f2013-02-10 09:39:47 +0800664 - TCP Keepalive can now optionally be applied to all lws sockets, on Linux
665 also with controllable timeout, number of probes and probe interval.
666 (On BSD type OS, you can only use system default settings for the
667 timing and retries, although enabling it is supported by setting
668 ka_time to nonzero, the exact value has no meaning.)
669 This enables detection of idle connections which are logically okay,
670 but are in fact dead, due to network connectivity issues at the server,
Andy Greena690cd02013-02-09 12:25:31 +0800671 client, or any intermediary. By default it's not enabled, but you
672 can enable it by setting a non-zero timeout (in seconds) at the new
673 ka_time member at context creation time.
674
Andy Greena7109e62013-02-11 12:05:54 +0800675 - Two new optional user callbacks added, LWS_CALLBACK_PROTOCOL_DESTROY which
676 is called one-time per protocol as the context is being destroyed, and
677 LWS_CALLBACK_PROTOCOL_INIT which is called when the context is created
678 and the protocols are added, again it's a one-time affair.
679 This lets you manage per-protocol allocations properly including
680 cleaning up after yourself when the server goes down.
Andy Green7b405452013-02-01 10:50:15 +0800681
Andy Greened334462013-02-07 21:14:33 +0800682User api changes
683----------------
684
Andy Green1b265272013-02-09 14:01:09 +0800685 - libwebsocket_create_context() has changed from taking a ton of parameters
686 to just taking a pointer to a struct containing the parameters. The
687 struct lws_context_creation_info is in libwebsockets.h, the members
688 are in the same order as when they were parameters to the call
689 previously. The test apps are all updated accordingly so you can
690 see example code there.
691
Andy Greened334462013-02-07 21:14:33 +0800692 - Header tokens are now deleted after the websocket connection is
Andy Green54495112013-02-06 21:10:16 +0900693 established. Not just the header data is saved, but the pointer and
694 length array is also removed from (union) scope saving several hundred
695 bytes per connection once it is established
696
697 - struct libwebsocket_protocols has a new member rx_buffer_size, this
698 controls rx buffer size per connection of that protocol now. Sources
699 for apps built against older versions of the library won't declare
700 this in their protocols, defaulting it to 0. Zero buffer is legal,
701 it causes a default buffer to be allocated (currently 4096)
702
703 If you want to receive only atomic frames in your user callback, you
704 should set this to greater than your largest frame size. If a frame
705 comes that exceeds that, no error occurs but the callback happens as
706 soon as the buffer limit is reached, and again if it is reached again
707 or the frame completes. You can detect that has happened by seeing
708 there is still frame content pending using
709 libwebsockets_remaining_packet_payload()
710
711 By correctly setting this, you can save a lot of memory when your
712 protocol has small frames (see the test server and client sources).
713
Andy Green16ab3182013-02-10 18:02:31 +0800714 - LWS_MAX_HEADER_LEN now defaults to 1024 and is the total amount of known
715 header payload lws can cope with, that includes the GET URL, origin
716 etc. Headers not understood by lws are ignored and their payload
717 not included in this.
718
Andy Green54495112013-02-06 21:10:16 +0900719
720User api removals
721-----------------
722
Andy Green16ab3182013-02-10 18:02:31 +0800723 - The configuration-time option MAX_USER_RX_BUFFER has been replaced by a
724 buffer size chosen per-protocol. For compatibility, there's a default
725 of 4096 rx buffer, but user code should set the appropriate size for
726 the protocol frames.
727
728 - LWS_INITIAL_HDR_ALLOC and LWS_ADDITIONAL_HDR_ALLOC are no longer needed
729 and have been removed. There's a new header management scheme that
730 handles them in a much more compact way.
Andy Greened334462013-02-07 21:14:33 +0800731
Andy Green70edd6f2013-02-12 10:15:25 +0800732 - libwebsockets_hangup_on_client() is removed. If you want to close the
733 connection you must do so from the user callback and by returning
734 -1 from there.
735
Andy Green508946c2013-02-12 10:19:08 +0800736 - libwebsocket_close_and_free_session() is now private to the library code
737 only and not exposed for user code. If you want to close the
738 connection, you must do so from the user callback by returning -1
739 from there.
740
Andy Greened334462013-02-07 21:14:33 +0800741
Andy Greendf60b0c2013-02-06 19:57:12 +0900742New features
743------------
744
Andy Green9b09dc02013-02-08 12:48:36 +0800745 - Cmake project file added, aimed initially at Windows support: this replaces
Andy Green16ab3182013-02-10 18:02:31 +0800746 the visual studio project files that were in the tree until now.
Andy Greendf60b0c2013-02-06 19:57:12 +0900747
Andy Greenc3ef0d62013-02-12 10:50:49 +0800748 - CyaSSL now supported in place of OpenSSL (--use-cyassl on configure)
749
Andy Green9b09dc02013-02-08 12:48:36 +0800750 - PATH_MAX or MAX_PATH no longer needed
Andy Greendf60b0c2013-02-06 19:57:12 +0900751
Andy Green54495112013-02-06 21:10:16 +0900752 - cutomizable frame rx buffer size by protocol
753
Andy Greenc3ef0d62013-02-12 10:50:49 +0800754 - optional TCP keepalive so dead peers can be detected, can be enabled at
755 context-creation time
756
757 - valgrind-clean: no SSL or CyaSSL: completely clean. With OpenSSL, 88 bytes
758 lost at OpenSSL library init and symptomless reports of uninitialized
759 memory usage... seems to be a known and ignored problem at OpenSSL
760
Andy Greena3957ef2013-02-11 09:31:43 +0800761 - By default debug is enabled and the library is built for -O0 -g to faclitate
762 that. Use --disable-debug configure option to build instead with -O4
763 and no -g (debug info), obviously providing best performance and
764 reduced binary size.
Andy Green7b405452013-02-01 10:50:15 +0800765
Andy Green895d56d2013-02-11 09:32:53 +0800766 - 1.0 introduced some code to try to not deflate small frames, however this
767 seems to break when confronted with a mixture of frames above and
768 below the threshold, so it's removed. Veto the compression extension
769 in your user callback if you will typically have very small frames.
770
Andy Green16ab3182013-02-10 18:02:31 +0800771 - There are many memory usage improvements, both a reduction in malloc/
772 realloc and architectural changes. A websocket connection now
773 consumes only 296 bytes with SSL or 272 bytes without on x86_64,
774 during header processing an additional 1262 bytes is allocated in a
775 single malloc, but is freed when the websocket connection starts.
776 The RX frame buffer defined by the protocol in user
777 code is also allocated per connection, this represents the largest
778 frame you can receive atomically in that protocol.
779
Andy Greenc3ef0d62013-02-12 10:50:49 +0800780 - On ARM9 build, just http+ws server no extensions or ssl, <12Kbytes .text
781 and 112 bytes per connection (+1328 only during header processing)
782
Andy Green895d56d2013-02-11 09:32:53 +0800783
Andy Greenbd1132f2013-01-31 19:53:05 +0800784v1.1-chrome26-firefox18
Andy Greena35c86f2013-01-31 10:16:44 +0800785=======================
786
787Diffstat
788--------
789
790 Makefile.am | 4 +
791 README-test-server | 291 ---
792 README.build | 239 ++
793 README.coding | 138 ++
794 README.rst | 72 -
795 README.test-apps | 272 +++
796 configure.ac | 116 +-
797 lib/Makefile.am | 55 +-
798 lib/base64-decode.c | 5 +-
799 lib/client-handshake.c | 121 +-
800 lib/client-parser.c | 394 ++++
801 lib/client.c | 807 +++++++
802 lib/daemonize.c | 212 ++
803 lib/extension-deflate-frame.c | 132 +-
804 lib/extension-deflate-stream.c | 12 +-
805 lib/extension-x-google-mux.c | 1223 ----------
806 lib/extension-x-google-mux.h | 96 -
807 lib/extension.c | 8 -
808 lib/getifaddrs.c | 271 +++
809 lib/getifaddrs.h | 76 +
810 lib/handshake.c | 582 +----
811 lib/libwebsockets.c | 2493 ++++++---------------
812 lib/libwebsockets.h | 115 +-
813 lib/md5.c | 217 --
814 lib/minilex.c | 440 ++++
815 lib/output.c | 628 ++++++
816 lib/parsers.c | 2016 +++++------------
817 lib/private-libwebsockets.h | 284 +--
818 lib/server-handshake.c | 275 +++
819 lib/server.c | 377 ++++
820 libwebsockets-api-doc.html | 300 +--
821 m4/ignore-me | 2 +
822 test-server/Makefile.am | 111 +-
823 test-server/libwebsockets.org-logo.png | Bin 0 -> 7029 bytes
824 test-server/test-client.c | 45 +-
825 test-server/test-echo.c | 330 +++
826 test-server/test-fraggle.c | 20 +-
827 test-server/test-ping.c | 22 +-
828 test-server/test-server-extpoll.c | 554 -----
829 test-server/test-server.c | 349 ++-
830 test-server/test.html | 3 +-
831 win32port/zlib/ZLib.vcxproj | 749 ++++---
832 win32port/zlib/ZLib.vcxproj.filters | 188 +-
833 win32port/zlib/adler32.c | 348 ++-
834 win32port/zlib/compress.c | 160 +-
835 win32port/zlib/crc32.c | 867 ++++----
836 win32port/zlib/crc32.h | 882 ++++----
837 win32port/zlib/deflate.c | 3799 +++++++++++++++-----------------
838 win32port/zlib/deflate.h | 688 +++---
839 win32port/zlib/gzclose.c | 50 +-
840 win32port/zlib/gzguts.h | 325 ++-
841 win32port/zlib/gzlib.c | 1157 +++++-----
842 win32port/zlib/gzread.c | 1242 ++++++-----
843 win32port/zlib/gzwrite.c | 1096 +++++----
844 win32port/zlib/infback.c | 1272 ++++++-----
845 win32port/zlib/inffast.c | 680 +++---
846 win32port/zlib/inffast.h | 22 +-
847 win32port/zlib/inffixed.h | 188 +-
848 win32port/zlib/inflate.c | 2976 +++++++++++++------------
849 win32port/zlib/inflate.h | 244 +-
850 win32port/zlib/inftrees.c | 636 +++---
851 win32port/zlib/inftrees.h | 124 +-
852 win32port/zlib/trees.c | 2468 +++++++++++----------
853 win32port/zlib/trees.h | 256 +--
854 win32port/zlib/uncompr.c | 118 +-
855 win32port/zlib/zconf.h | 934 ++++----
856 win32port/zlib/zlib.h | 3357 ++++++++++++++--------------
857 win32port/zlib/zutil.c | 642 +++---
858 win32port/zlib/zutil.h | 526 ++---
859 69 files changed, 19556 insertions(+), 20145 deletions(-)
860
861user api changes
862----------------
863
864 - libwebsockets_serve_http_file() now takes a context as first argument
865
866 - libwebsockets_get_peer_addresses() now takes a context and wsi as first
867 two arguments
868
869
870user api additions
871------------------
872
873 - lwsl_...() logging apis, default to stderr but retargetable by user code;
874 may be used also by user code
875
876 - lws_set_log_level() set which logging apis are able to emit (defaults to
877 notice, warn, err severities), optionally set the emit callback
878
879 - lwsl_emit_syslog() helper callback emits to syslog
880
881 - lws_daemonize() helper code that forks the app into a headless daemon
882 properly, maintains a lock file with pid in suitable for sysvinit etc to
883 control lifecycle
884
885 - LWS_CALLBACK_HTTP_FILE_COMPLETION callback added since http file
886 transfer is now asynchronous (see test server code)
887
888 - lws_frame_is_binary() from a wsi pointer, let you know if the received
889 data was sent in BINARY mode
890
891
892user api removals
893-----------------
894
895 - libwebsockets_fork_service_loop() - no longer supported (had intractable problems)
896 arrange your code to act from the user callback instead from same
897 process context as the service loop
898
899 - libwebsockets_broadcast() - use libwebsocket_callback_on_writable[_all_protocol]()
900 instead from same process context as the service loop. See the test apps
901 for examples.
902
903 - x-google-mux() removed until someone wants it
904
905 - pre -v13 (ancient) protocol support removed
906
907
908New features
909------------
910
911 - echo test server and client compatible with echo.websocket.org added
912
913 - many new configure options (see README.build) to reduce footprint of the
914 library to what you actually need, eg, --without-client and
915 --without-server
916
917 - http + websocket server can build to as little as 12K .text for ARM
918
919 - no more MAX_CLIENTS limitation; adapts to support the max number of fds
920 allowed to the process by ulimit, defaults to 1024 on Fedora and
921 Ubuntu. Use ulimit to control this without needing to configure
922 the library. Code here is smaller and faster.
923
924 - adaptive ratio of listen socket to connection socket service allows
925 good behaviour under Apache ab test load. Tested with thousands
926 of simultaneous connections
927
928 - reduction in per-connection memory footprint by moving to a union to hold
929 mutually-exclusive state for the connection
930
931 - robustness: Out of Memory taken care of for all allocation code now
932
933 - internal getifaddrs option if your toolchain lacks it (some uclibc)
934
935 - configurable memory limit for deflate operations
936
937 - improvements in SSL code nonblocking operation, possible hang solved,
938 some SSL operations broken down into pollable states so there is
939 no library blocking, timeout coverage for SSL_connect
940
941 - extpoll test server merged into single test server source
942
943 - robustness: library should deal with all recoverable socket conditions
944
945 - rx flowcontrol for backpressure notification fixed and implmeneted
946 correctly in the test server
947
948 - optimal lexical parser added for header processing; all headers in a
949 single 276-byte state table
950
951 - latency tracking api added (configure --with-latency)
952
953 - Improved in-tree documentation, REAME.build, README.coding,
954 README.test-apps, changelog
955
956 - Many small fixes
957
958
959v1.0-chrome25-firefox17 (6cd1ea9b005933f)