platform/upstream/libwebsockets.git
8 years agodocumentation convert to doxygen
Andy Green [Mon, 20 Jun 2016 09:05:31 +0000 (17:05 +0800)]
documentation convert to doxygen

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoprotocol-lws-messageboard
Andy Green [Wed, 15 Jun 2016 04:24:38 +0000 (12:24 +0800)]
protocol-lws-messageboard

This is a simple messageboard built on top of lwsgs

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_bind_protocol
Andy Green [Sat, 18 Jun 2016 01:00:04 +0000 (09:00 +0800)]
lws_bind_protocol

When using http/1.1+ keepalive and mounts, the relationship between
a connection and a protocol becomes dynamic.  The same connection might
visit different bits of the url space served by different mounts using
different protocols.

This patch ensures protocols can cleanly manage their per-connection
allocations by using the following callbacks when the protocol changes

 LWS_CALLBACK_HTTP_BIND_PROTOCOL
 LWS_CALLBACK_HTTP_DROP_PROTOCOL

For example if the pss wants to malloc stuff at runtime, it should do it
in LWS_CALLBACK_HTTP_BIND_PROTOCOL or later, and clean it up in
...DROP_PROTOCOL.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoprotocol generic sessions
Andy Green [Thu, 19 May 2016 07:28:31 +0000 (15:28 +0800)]
protocol generic sessions

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_json_escape
Andy Green [Fri, 17 Jun 2016 02:05:23 +0000 (10:05 +0800)]
lws_json_escape

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolejp conf report human readable errors
Andy Green [Fri, 17 Jun 2016 22:36:37 +0000 (06:36 +0800)]
lejp conf report human readable errors

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_now_secs
Andy Green [Fri, 17 Jun 2016 01:41:22 +0000 (09:41 +0800)]
lws_now_secs

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoModified the 64 connections "backup" so that there is no wait if any event
OndraCo [Thu, 16 Jun 2016 05:02:31 +0000 (13:02 +0800)]
Modified the 64 connections "backup" so that there is no wait if any event
is already ready.

8 years agoAdded a back-up in case of more than 64 connections.
OndraCo [Thu, 16 Jun 2016 05:02:20 +0000 (13:02 +0800)]
Added a back-up in case of more than 64 connections.

8 years agolws_callback_vhost_protocols
Andy Green [Wed, 15 Jun 2016 02:46:58 +0000 (10:46 +0800)]
lws_callback_vhost_protocols

This gives protocols a way to talk to each other via per-vhost callbacks,
one per protocol (including the sender).

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_process_html_args
Andy Green [Sun, 12 Jun 2016 01:56:39 +0000 (09:56 +0800)]
lws_process_html_args

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agointroduce urlencode decode and sql escape public apis
Andy Green [Wed, 8 Jun 2016 02:07:02 +0000 (10:07 +0800)]
introduce urlencode decode and sql escape public apis

This adds

 - simple lws_urlencode()
 - simple lws_urldecode()
 - simple lws_sql_purify

Those expect the data to all be there and process it up until
the first '\0'.

There is also a larger opaque apis for handling POST_BODY urldecode.  To
enable these, you need to give cmake -DLWS_WITH_STATEFUL_URLDECODE=1 (or
arrange any larger feature that relies on it sets that in CMakeLists.txt)

 - stateful urldecode with parameter array

These have create / process / destroy semantics on a struct that maintains
decode state.

Stateful urldecode is capable of dealing with large POST data in multiple
POST_BODY callbacks cleanly, eg, file transfer by POST.

Stateful urldecode with parameter array wraps the above with a canned
callback that stores the urldecoded data and indexes them in a pointer
array matching an array of parameter names.

You may also pass it an optional callback when creating it, that will recieve
uploaded file content.

The test html is updated to support both urlencoded and multipart forms,
with some javascript to do clientside validation of an arbitrary 100KB
file size limit (there is no file size limit in the apis).

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agofix for https connection code
Gadkari Mugdha [Mon, 13 Jun 2016 09:23:44 +0000 (17:23 +0800)]
fix for https connection code

8 years agoopenssl allow set clear of ssl options from info
Andy Green [Fri, 10 Jun 2016 00:37:26 +0000 (08:37 +0800)]
openssl allow set clear of ssl options from info

8 years agonon-openssl: only check for openssl ecdh in openssl builds
Karl Palsson [Mon, 6 Jun 2016 15:03:09 +0000 (15:03 +0000)]
non-openssl: only check for openssl ecdh in openssl builds

See also
https://github.com/warmcat/libwebsockets/issues/559

Signed-off-by: Karl Palsson <karlp@etactica.com>
8 years agoclient CONNECTION_ERROR also allow in LWSS_CLIENT_UNCONNECTED
Andy Green [Tue, 7 Jun 2016 09:20:36 +0000 (17:20 +0800)]
client CONNECTION_ERROR also allow in LWSS_CLIENT_UNCONNECTED

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_write escalate pending truncated to make the
Andy Green [Tue, 7 Jun 2016 08:46:41 +0000 (16:46 +0800)]
lws_write escalate pending truncated to make the

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agosmtp
Andy Green [Tue, 7 Jun 2016 01:49:59 +0000 (09:49 +0800)]
smtp

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoAndroid: update to use SDK Python script
Alexander Bruines [Mon, 6 Jun 2016 18:30:03 +0000 (20:30 +0200)]
Android: update to use SDK Python script

The latest Android SDK updates deprecate the shell script
 used to create a standalone toolchain. This patch updates the Makefile for
 the Android test-client to use the new Python script to create the standalone
 toolchains.

8 years agoARRAY_SIZE dont redefine
Andy Green [Mon, 6 Jun 2016 12:35:23 +0000 (20:35 +0800)]
ARRAY_SIZE dont redefine

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoavoid illegal sockfd on timeout
Andy Green [Fri, 3 Jun 2016 14:21:14 +0000 (22:21 +0800)]
avoid illegal sockfd on timeout

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoipv6only add lejp conf and flag docs
Andy Green [Sat, 4 Jun 2016 01:01:28 +0000 (09:01 +0800)]
ipv6only add lejp conf and flag docs

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoipv6 don't ignore info.iface
Denis Osvald [Sat, 4 Jun 2016 00:37:50 +0000 (08:37 +0800)]
ipv6 don't ignore info.iface

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
8 years agoallow modifying ipv4 mapping option (IPV6_V6ONLY)
Denis Osvald [Sat, 4 Jun 2016 00:37:39 +0000 (08:37 +0800)]
allow modifying ipv4 mapping option (IPV6_V6ONLY)

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
8 years agovhost creation print ipv6
Denis Osvald [Sat, 4 Jun 2016 00:37:31 +0000 (08:37 +0800)]
vhost creation print ipv6

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
8 years agofixup! ipv6 move disable to vhost option
Denis Osvald [Sat, 4 Jun 2016 00:37:19 +0000 (08:37 +0800)]
fixup! ipv6 move disable to vhost option

client ipv6 check vhost not context

8 years agofixup! ipv6 move disable to vhost option
Denis Osvald [Fri, 3 Jun 2016 15:40:12 +0000 (17:40 +0200)]
fixup! ipv6 move disable to vhost option

fix missing backslash in multiline macro

8 years agoipv6 move disable to vhost option
Andy Green [Fri, 3 Jun 2016 13:19:40 +0000 (21:19 +0800)]
ipv6 move disable to vhost option

Server ipv6 support disable is now controlled by vhost->options rather
than context->options, allowing it to be set per-vhost.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_get_urlarg_by_name
Andy Green [Fri, 3 Jun 2016 01:04:15 +0000 (09:04 +0800)]
lws_get_urlarg_by_name

Adds a convenient way to directly get the value of a URL
argument like ...?x=y&v=1, regardless of position in the
parameter list.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoadd max_http_header_data2 and upgrade internal offsets from short to int
Andy Green [Thu, 2 Jun 2016 04:32:38 +0000 (12:32 +0800)]
add max_http_header_data2 and upgrade internal offsets from short to int

https://github.com/warmcat/libwebsockets/issues/550

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoRevert changes in daemonize.c from commit 22d6f39e7fb270d0c011bae820d2f8adc8b19061
Martin C Drohmann [Wed, 1 Jun 2016 19:12:44 +0000 (12:12 -0700)]
Revert changes in daemonize.c from commit 22d6f39e7fb270d0c011bae820d2f8adc8b19061

8 years agoupdate document for lws_get_context
Young [Tue, 31 May 2016 13:50:22 +0000 (21:50 +0800)]
update document for lws_get_context

8 years agolwsl_timestamp month off by one
Fabian Kurz [Wed, 1 Jun 2016 00:32:18 +0000 (08:32 +0800)]
lwsl_timestamp month off by one

8 years agoAdroid test-server client
Alexander Bruines [Sat, 28 May 2016 11:31:35 +0000 (13:31 +0200)]
Adroid test-server client

8 years agolwsws conf.c migrate to lib
Andy Green [Thu, 26 May 2016 13:12:11 +0000 (21:12 +0800)]
lwsws conf.c migrate to lib

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoplugins add win modifiers before libwebsockets.h for dll export flag
Andy Green [Wed, 25 May 2016 23:51:58 +0000 (07:51 +0800)]
plugins add win modifiers before libwebsockets.h for dll export flag

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agowindows adapt plugin name format vs functions
Andy Green [Wed, 25 May 2016 13:43:58 +0000 (21:43 +0800)]
windows adapt plugin name format vs functions

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agowindows call plugins init on win32 plat
Andy Green [Wed, 25 May 2016 11:42:35 +0000 (19:42 +0800)]
windows call plugins init on win32 plat

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_get_peer_simple move to user api
Andy Green [Wed, 25 May 2016 00:04:52 +0000 (08:04 +0800)]
lws_get_peer_simple move to user api

https://github.com/warmcat/libwebsockets/issues/537

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoupdate discard pre 2016 date if post 2016 date seen
Andy Green [Tue, 24 May 2016 09:44:35 +0000 (17:44 +0800)]
update discard pre 2016 date if post 2016 date seen

Otherwise lwsws started at boot on a system without an RTC
may feel it was started in 1970, and when the clock is set
by ntpd a little later, has been up for 16,000 days...

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws fix settable conf dir and error paths
Andy Green [Sat, 21 May 2016 23:01:35 +0000 (07:01 +0800)]
lwsws fix settable conf dir and error paths

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoclean correct file comment at top and remove pointless LWS_CALLBACK_HTTP
Andy Green [Sat, 21 May 2016 07:18:30 +0000 (15:18 +0800)]
clean correct file comment at top and remove pointless LWS_CALLBACK_HTTP

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_ssl_client_connect2 remove duplicate close on error path
Andy Green [Thu, 19 May 2016 09:27:15 +0000 (17:27 +0800)]
lws_ssl_client_connect2 remove duplicate close on error path

https://github.com/warmcat/libwebsockets/issues/532

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoreplace LWS_MAX_SOCKET_IO_BUF with context creation info pt_serv_buf_size
Andy Green [Thu, 19 May 2016 04:34:35 +0000 (12:34 +0800)]
replace LWS_MAX_SOCKET_IO_BUF with context creation info pt_serv_buf_size

This makes it easy for user code to choose the size of the per-thread
buffer used by various things in lws, including file transfer chunking.

Previously it was 4096, if you leave info.pt_serv_buf_size as zero that
is still the default.

With some caveats, you can increase transfer efficiency by increasing it
to, eg, 128KiB, if that makes sense for your memory situation.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws localhost example conf add testcgi
Andy Green [Tue, 17 May 2016 13:53:53 +0000 (21:53 +0800)]
lwsws localhost example conf add testcgi

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolejp string chunk 255
Andy Green [Tue, 17 May 2016 13:27:24 +0000 (21:27 +0800)]
lejp string chunk 255

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolejp check callback errors and use reject path
Andy Green [Tue, 17 May 2016 13:22:06 +0000 (21:22 +0800)]
lejp check callback errors and use reject path

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agodeprecate misnamed lws_vhost_get add lws_get_vhost
Andy Green [Tue, 17 May 2016 05:47:44 +0000 (13:47 +0800)]
deprecate misnamed lws_vhost_get add lws_get_vhost

All the other simple accessors begin lws_get_...

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agodeprecate duplicated lws_protocol_get
Andy Green [Tue, 17 May 2016 05:33:58 +0000 (13:33 +0800)]
deprecate duplicated lws_protocol_get

Use the identical lws_get_protocol()

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws update example conf to be 7681 no ssl test server
Andy Green [Tue, 17 May 2016 00:54:42 +0000 (08:54 +0800)]
lwsws update example conf to be 7681 no ssl test server

It's going to be much easier to transition to lwsws
if the example config exactly matches what used to be
seen from the default test server.

# mkdir -p /etc/lwsws/conf.d /var/log/lwsws
# cp ./lwsws/etc-lwsws-conf-EXAMPLE /etc/lwsws/conf
# cp ./lwsws/etc-lwsws-conf.d-localhost-EXAMPLE /etc/lwsws/conf.d/test-server
# sudo lwsws

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agooutput size trimming with default rxbuf fix
Andy Green [Sun, 15 May 2016 00:59:48 +0000 (08:59 +0800)]
output size trimming with default rxbuf fix

5e203f78e21ee3313d763d8ee6d499fa0163f51a accidentally
trashed the "zero rz_buffer_size means 4096" handling
for tx chunking.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agowin fix warnings from appveyor
Andy Green [Sun, 15 May 2016 00:29:37 +0000 (08:29 +0800)]
win fix warnings from appveyor

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoappveyor libuv integration
Andy Green [Sat, 14 May 2016 02:34:12 +0000 (10:34 +0800)]
appveyor libuv integration

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws conf mount extra mimetypes
Andy Green [Sat, 14 May 2016 02:00:21 +0000 (10:00 +0800)]
lwsws conf mount extra mimetypes

This patch adds the ability to provide extra mimtypes on a mount.

lwsws conf learns how to do them.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolejp handle name elements starting with dot
Andy Green [Sat, 14 May 2016 02:22:19 +0000 (10:22 +0800)]
lejp handle name elements starting with dot

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws conf allow setting cipher list and ecdh curve
Andy Green [Sat, 14 May 2016 01:50:34 +0000 (09:50 +0800)]
lwsws conf allow setting cipher list and ecdh curve

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agowin32 more build fixes
Andy Green [Fri, 13 May 2016 22:49:29 +0000 (06:49 +0800)]
win32 more build fixes

After alexgille

https://github.com/warmcat/libwebsockets/issues/526

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolws_context_init_client_ssl ssl lib init already done in context
Andy Green [Fri, 13 May 2016 10:15:08 +0000 (18:15 +0800)]
lws_context_init_client_ssl ssl lib init already done in context

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoaccess_log ensure no reuse of freed log area
Andy Green [Fri, 13 May 2016 02:57:23 +0000 (10:57 +0800)]
access_log ensure no reuse of freed log area

Valgrind caught http/1.1 pipelining using dead user agent alloc
for logging... NULL it when we free it since the wsi can be
reused with keepalive

==16208== Invalid free() / delete / delete[] / realloc()
==16208==    at 0x4847ACC: free (vg_replace_malloc.c:530)
==16208==    by 0x4888DC3: _realloc (alloc.c:8)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x487DBCB: lws_access_log (libwebsockets.c:2352)
==16208==    by 0x48956DF: lws_http_transaction_completed (server.c:1245)
==16208==    by 0x4893757: lws_http_serve (server.c:340)
==16208==    by 0x48946EF: lws_http_action (server.c:748)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==  Address 0x552e5f8 is 0 bytes inside a block of size 86 free'd
==16208==    at 0x4847ACC: free (vg_replace_malloc.c:530)
==16208==    by 0x4888DC3: _realloc (alloc.c:8)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x487DBCB: lws_access_log (libwebsockets.c:2352)
==16208==    by 0x48956DF: lws_http_transaction_completed (server.c:1245)
==16208==    by 0x4893757: lws_http_serve (server.c:340)
==16208==    by 0x48946EF: lws_http_action (server.c:748)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==  Block was alloc'd at
==16208==    at 0x4846498: malloc (vg_replace_malloc.c:298)
==16208==    by 0x4848D57: realloc (vg_replace_malloc.c:785)
==16208==    by 0x4888DA7: _realloc (alloc.c:6)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x4893EAF: lws_http_action (server.c:565)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==    by 0x48994B7: lws_io_cb (libuv.c:101)
==16208==    by 0x4AE7B1F: ??? (in /usr/lib/libuv.so.1.0.0)

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agodummy http protocol should always do 404
Andy Green [Fri, 13 May 2016 02:31:52 +0000 (10:31 +0800)]
dummy http protocol should always do 404

We only got here if no mount matched, so we should
affirmitively send a 404

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoasserts log which
Andy Green [Fri, 13 May 2016 02:27:48 +0000 (10:27 +0800)]
asserts log which

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoFix leak caused by undestroyed pthread mutex
Sterling Jensen [Fri, 13 May 2016 01:22:35 +0000 (20:22 -0500)]
Fix leak caused by undestroyed pthread mutex

8 years agowin32 libuv related build fixes
Andy Green [Fri, 13 May 2016 00:20:12 +0000 (08:20 +0800)]
win32 libuv related build fixes

https://github.com/warmcat/libwebsockets/issues/526

On master, cleanups and refactor mean the last two problems already
don't exist (array is gone from main.c and http.c is deleted)

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoprotocol_client_loopback_test
Andy Green [Thu, 12 May 2016 11:45:04 +0000 (19:45 +0800)]
protocol_client_loopback_test

This is used to confirm that SSL client connections can coexist with
a vhost doing serving.

To set it up,

/*
 * This is a bit fiddly...
 *
 * 0) If you want the wss:// test to work, make sure the vhost is marked with
 *    enable-client-ssl if using lwsws, or call lws_init_vhost_client_ssl() on
 *    the vhost if you're doing it by hand.
 *
 * 1) enable the protocol on a vhost
 *
 *      "ws-protocols": [{
 *     "client-loopback-test": {
 *      "status": "ok"
 *     },  ...
 *
 *     the vhost should listen on 80 (ws://) or 443 (wss://)
 *
 * 2) mount the http part of the test one level down on the same vhost, eg
 *   {
 *      "mountpoint": "/c",
 *      "origin": "callback://client-loopback-test"
 *   }
 *
 * 3) Use a browser to visit the mountpoint with a URI attached for looping
 *    back, eg, if testing on localhost
 *
 *    http://localhost/c/ws://localhost
 *    https://localhost/c/wss://localhost
 *
 * 4) The HTTP part of this test protocol will try to do the requested
 *    ws client connection, to the same test protocol on the same
 *    server.
 */

Results should look like this

lwsws[29938]: client connection to localhost:443 with ssl: 1 started
lwsws[29938]: server part: LWS_CALLBACK_ESTABLISHED
lwsws[29938]: checking client ext permessage-deflate
lwsws[29938]: instantiating client ext permessage-deflate
lwsws[29938]: Client connection established
lwsws[29938]: Client connection received 7 from server 'Made it'

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoadd lws_init_vhost_client_ssl api to allow client ssl use on a vhost
Andy Green [Thu, 12 May 2016 11:39:29 +0000 (19:39 +0800)]
add lws_init_vhost_client_ssl api to allow client ssl use on a vhost

Also add lwsws "enable-client-ssl": "1" vhost option to match.

Client cert iclient ssl is not supported in lwsws, if someone wants it, it can be added.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agocheck oom on lws_malloc
Andy Green [Thu, 12 May 2016 13:04:33 +0000 (21:04 +0800)]
check oom on lws_malloc

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agowindows no chown on log file generation
Andy Green [Wed, 11 May 2016 10:59:27 +0000 (18:59 +0800)]
windows no chown on log file generation

https://github.com/warmcat/libwebsockets/issues/524

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agooutput allow LWS_PRE+4 on top of rx_buffer_size for max send chunk
Andy Green [Tue, 10 May 2016 13:35:38 +0000 (21:35 +0800)]
output allow LWS_PRE+4 on top of rx_buffer_size for max send chunk

https://github.com/warmcat/libwebsockets/issues/522

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws remove all protocols use lws default http
Andy Green [Tue, 10 May 2016 02:16:52 +0000 (10:16 +0800)]
lwsws remove all protocols use lws default http

Actually lwsws doesn't need his own protocol handler even for http
any more.  The default http handler in lws should do everything.

Move the cgi routing into lws default http protocol handler, and
delete lwsws one.  Remove all protocols from lwsws so the lws
default one gets used.

With this, and the earlier move of lejp into lws, lwsws itself
becomes 15.5KB of x86_64 (mainly conf parsing).

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws cleanup and allocate config strings dynamically
Andy Green [Tue, 10 May 2016 02:42:19 +0000 (10:42 +0800)]
lwsws cleanup and allocate config strings dynamically

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolwsws remove non libuv SIGINT handler
Andy Green [Tue, 10 May 2016 02:31:16 +0000 (10:31 +0800)]
lwsws remove non libuv SIGINT handler

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolejp bring into lws
Andy Green [Tue, 10 May 2016 01:47:10 +0000 (09:47 +0800)]
lejp bring into lws

lejp is already in lws as part of lwsws.  However it's too generally useful
to just put directly in lwsws, it will lead to multiple copies of the source
in differet subprojects.

This moves it directly into lws, lwsws now gets it from there.

Like lwsws, by default at cmake it is disabled.  Selecting LWS_WITH_LWSWS now
selects LWS_WITH_LEJP and you can set that at cmake individually as well.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agologging migrate user stimulated logging to info
Andy Green [Mon, 9 May 2016 05:31:43 +0000 (13:31 +0800)]
logging migrate user stimulated logging to info

https://github.com/warmcat/libwebsockets/issues/520

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoadd protocol plugin for post demo
Andy Green [Mon, 9 May 2016 01:37:01 +0000 (09:37 +0800)]
add protocol plugin for post demo

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoPOST handling dont autocomplete transaction
Andy Green [Mon, 9 May 2016 01:37:44 +0000 (09:37 +0800)]
POST handling dont autocomplete transaction

Until now lws has finished the HTTP transaction when the POST body was
completely received.

However that needlessly makes it impossible to send a HTTP 200 and a
response without a redirect.

This changes lws behaviour after sending the LWS_CALLBACK_HTTP_BODY_COMPLETION
callback to no longer terminate the HTTP transaction.

If you want the old behaviour, you can terminate the transaction with
lws_http_transaction_completed() in the LWS_CALLBACK_HTTP_BODY_COMPLETION
callback.

Otherwise it's now possible to call lws_callback_on_writable() from
LWS_CALLBACK_HTTP_BODY_COMPLETION.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolibuv tidy up destroy and disable timer races during shutdown
Andy Green [Sun, 8 May 2016 09:07:46 +0000 (17:07 +0800)]
libuv tidy up destroy and disable timer races during shutdown

Also don't make us wait 1s for init to finish.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoclient fix for operation with libuv
Andy Green [Sun, 8 May 2016 09:03:01 +0000 (17:03 +0800)]
client fix for operation with libuv

 - libuv socket init binding was missing for client

 - failures like no ws protocol match are deferred until the
   ah is bound.  Check for these failures and make sure we
   tell the guy trying to set up the client connection the
   wsi is NULL if it has already failed and closed.

 - pfd.events was not initialized for the client init path

With this general client function is more robust but also
client connections work properly with libuv.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agocontext only destroy protocols if init got sent
Andy Green [Sun, 8 May 2016 09:00:38 +0000 (17:00 +0800)]
context only destroy protocols if init got sent

If for some reason we exit before the protocol init action
(which is delayed for libuv) we should not send the protocol
destroy messages

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoclient handle connection fail at second phase properly
Andy Green [Sun, 8 May 2016 08:58:18 +0000 (16:58 +0800)]
client handle connection fail at second phase properly

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agotest server post also take care about POST len termination
Andy Green [Sun, 8 May 2016 08:56:34 +0000 (16:56 +0800)]
test server post also take care about POST len termination

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoupdate api docs v2.0
Andy Green [Sat, 7 May 2016 06:24:36 +0000 (14:24 +0800)]
update api docs v2.0

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agofix %3d handling in path part and add attack.sh
Andy Green [Sat, 7 May 2016 00:31:33 +0000 (08:31 +0800)]
fix %3d handling in path part and add attack.sh

https://github.com/warmcat/libwebsockets/issues/518

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoprotocol plugins default also add example in test server v2.0
Andy Green [Fri, 6 May 2016 07:56:13 +0000 (15:56 +0800)]
protocol plugins default also add example in test server v2.0

This shows how to deliver per-vhost, per-protocol option
name:value pairs using code.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoprotocol plugins set default
Andy Green [Fri, 6 May 2016 06:24:59 +0000 (14:24 +0800)]
protocol plugins set default

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agomimetypes add additional canned
Andy Green [Fri, 6 May 2016 00:02:57 +0000 (08:02 +0800)]
mimetypes add additional canned

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoMSVC from 2015 up has vsnprintf
OndraCo [Thu, 5 May 2016 11:56:07 +0000 (13:56 +0200)]
MSVC from 2015 up has vsnprintf

8 years agoDisabled static link handling for WIN_CE to temporarily avoid the fact that it has...
OndraCo [Thu, 5 May 2016 11:28:04 +0000 (13:28 +0200)]
Disabled static link handling for WIN_CE to temporarily avoid the fact that it has no stat struct

8 years agoChanges to enable WIN CE support
OndraCo [Thu, 5 May 2016 10:57:11 +0000 (12:57 +0200)]
Changes to enable WIN CE support

8 years agolib/server.c: fix ipv6 support
Enno Boland [Thu, 5 May 2016 20:09:54 +0000 (22:09 +0200)]
lib/server.c: fix ipv6 support

8 years agolib/ssl.c: fix libre- and boringssl
Enno Boland [Thu, 5 May 2016 20:08:41 +0000 (22:08 +0200)]
lib/ssl.c: fix libre- and boringssl

8 years agosnip changelog back to 1.7
Andy Green [Thu, 5 May 2016 23:45:19 +0000 (07:45 +0800)]
snip changelog back to 1.7

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agov2.0.0
Andy Green [Thu, 5 May 2016 01:40:18 +0000 (09:40 +0800)]
v2.0.0

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agorecv revert treating zero as hangup
Andy Green [Thu, 5 May 2016 01:06:09 +0000 (09:06 +0800)]
recv revert treating zero as hangup

While checking with ab, I found
commit 30cdb3ac8f24a4c289a3b4e8a41d6c5f2e6ec959
Author: Justin Chen <justinchen00@github.invalid.com>
Date:   Thu Apr 14 21:40:53 2016 +0800

    recv treat zero return as error

    https://github.com/warmcat/libwebsockets/issues/475

turned ab performance to crap, reverting it made everything fast again.

recv manpage says there is three ways to get zero returned

1)       When a stream socket peer has performed an orderly shutdown, the return value will be 0  (the  traditional  "end-of-file"
       return).

2)       Datagram  sockets  in  various  domains  (e.g., the UNIX and Internet domains) permit zero-length datagrams.  When such a
       datagram is received, the return value is 0.

3)       The value 0 may also be returned if the requested number of bytes to receive from a stream socket was 0.

we can't just assume it means the peer shut down.

If the peer shut down, then the event loop should get an event on the socket like POLLHUP and deal with it that way.

So the patch mentioned above is simply reverted here.

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agostats upgrade rx tx to long long
Andy Green [Wed, 4 May 2016 07:59:27 +0000 (15:59 +0800)]
stats upgrade rx tx to long long

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agocgi add generic wait as antizombie defence
Andy Green [Wed, 4 May 2016 04:23:27 +0000 (12:23 +0800)]
cgi add generic wait as antizombie defence

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoclean build warning on windows
Andy Green [Wed, 4 May 2016 03:11:15 +0000 (11:11 +0800)]
clean build warning on windows

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agoappveyor openssl 1.0.2h
Andy Green [Wed, 4 May 2016 02:36:23 +0000 (10:36 +0800)]
appveyor openssl 1.0.2h

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agolibuv fixes for foreign loop test
Andy Green [Wed, 4 May 2016 00:27:56 +0000 (08:27 +0800)]
libuv fixes for foreign loop test

Signed-off-by: Andy Green <andy@warmcat.com>
8 years agotest server foreign loop
Denis Osvald [Tue, 3 May 2016 13:21:18 +0000 (15:21 +0200)]
test server foreign loop

AG: adapt to use switch on existing test-server-libuv app
AG: correct the foreign lifecycle to be valgrind clean

This adds a switch -f --foreign that makes the test-server-libuv test
create his own libuv loop outside of lws, and use lws on it before
destroying lws and then his own loop.

If selected, the foreign loop runs for 5s before lws and 10s after
lws is stopped, for testing purposes.

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
8 years agoclient provide user_space on LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER
Andy Green [Tue, 3 May 2016 13:39:16 +0000 (21:39 +0800)]
client provide user_space on LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER

https://github.com/warmcat/libwebsockets/issues/509

Signed-off-by: Andy Green <andy@warmcat.com>