Commit graph

123 commits

Author SHA1 Message Date
Martin Milata
2238857ea4 Subject: ssl: stop spinning on close 2017-04-19 20:53:51 +08:00
Andy Green
be333ac420 pollout: handle request for pollout during pollout service 2017-04-05 08:30:04 +08:00
Andy Green
f80967b6c1 service: always restrict rx to serve_buf_size 2017-03-28 08:52:20 +08:00
Andy Green
d2d87776f9 pmd: handle case we are already on drain list
Provide internal helper for adding to list that takes care of the
case we are already on the list.

https://github.com/warmcat/libwebsockets/issues/847
2017-03-26 10:11:06 +08:00
Andy Green
42ea3bd703 ext: pmd: improve dealing with partial input usage with drain
https://github.com/warmcat/libwebsockets/issues/841
2017-03-20 19:34:49 +08:00
Silas Parker
906f137794 ssl: close sometimes continuously asserting POLLIN until timeout
https://github.com/warmcat/libwebsockets/issues/831
2017-03-10 07:48:27 +08:00
Andy Green
205ccedf6e raw: enable server and client raw sockets 2017-03-07 16:06:05 +08:00
Andy Green
21d83b44ea test-client: only take data from LWS_CALLBACK_RECEIVE_CLIENT_HTTP 2017-03-06 14:46:03 +08:00
Michael Behrns-Miller [case-ubuntu]
2495afa604 Subject: Buffer index protection in the case where client does not
receive content length from HTTP server
2017-03-03 05:41:39 +08:00
Andy Green
be8d791b5e adoption: make union for socket and file fds
This lets lws support adopting raw file FDs and raw socket fds.

A test plugin creates a FIFO and prints data sent on it, using
the lws event loop.
2017-03-01 10:01:53 +08:00
Andy Green
297c0313fa raw: adoption and processing 2017-02-21 07:47:35 +08:00
Andy Green
c7c4ae0aa4 ESP32 platform
This is enough for all the test app features to work on ESP32 without
SSL.
2017-02-18 17:27:22 +08:00
Andy Green
1d393aba9e client: close without spinning
https://github.com/warmcat/libwebsockets/issues/789
2017-02-18 17:27:22 +08:00
Martin Milata
be1f0a3a92 Subject: gcc format strings: Make GCC check format strings, fix found problems 2017-02-05 21:32:30 +08:00
Andy Green
51c96d8c2a plat-optee and boringssl adaptations 2017-01-17 07:01:02 +08:00
Andy Green
e680fb9193 win32 fixes
https://github.com/warmcat/libwebsockets/issues/750
2017-01-17 06:51:11 +08:00
Andy Green
b3c2427cfd client: MORE_SERVICE is not an error 2017-01-04 19:59:38 +08:00
Andy Green
dd0dfaecb7 ESP8266: LWS_POSIX fixes for basic auth and deprecated context 2016-12-22 11:32:34 +08:00
Andy Green
be9fb919d1 context deprecation
1) This makes lwsws run a parent process with the original permissions.
But this process is only able to respond to SIGHUP, it doesn't do anything
else.

2) You can send this parent process a SIGHUP now to cause it to

 - close listening sockets in existing lwsws processes

 - mark those processes as to exit when the number of active connections
   on the falls to zero

 - spawn a fresh child process from scratch, using latest configuration
   file content, latest plugins, etc.  It can now reopen listening sockets
   if it chooses to, or open different listen ports or whatever.

Notes:

1) lws_context_destroy() has been split into two pieces... the reason for
the split is the first part closes the per-vhost protocols, but since
they may have created libuv objects in the per-vhost protocol storage,
these cannot be freed until after the loop has been run.

That's the purpose of the second part of the context destruction,
lws_context_destroy2().

For compatibility, if you are not using libuv, the first part calls the
second part.  However if you are using libuv, you must now call the
second part from your own main.c after the first part.
2016-12-20 14:37:07 +08:00
Andy Green
b46c401245 alias lws_plat_service_tsi to lws_service_tsi in public api
Via Dosvald

lws_service_tsi() which has been around a while actually just
calls through to lws_plat_service_tsi(), meaning there is no
need to expose both apis.

Rename the internal lws_plat_service_tsi() to _lws_plat_service_tsi()
and replace the api export with a #define to lws_service_tsi for
compatibility's sake.
2016-12-16 22:08:12 +08:00
Denis Osvald
4be9a5234d publicly document lws_service_fd timeout servicing
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-10-07 17:34:25 +08:00
Andy Green
443b31d012 extpoll: expose forced service apis 2016-10-07 03:19:45 +08:00
Peter Pentchev
fb71b790cd Subject: Fix some typographical and grammatical errors. 2016-10-03 21:31:27 +08:00
Andy Green
723b3f16fa client http: extra read notification after close
https://github.com/warmcat/libwebsockets/issues/620
2016-09-06 15:36:51 +08:00
Andy Green
95fff47a91 client-add-PUSH-http-body-capability
Support HTTP body sending on client connections.

Add demo to test-client.

Run the normal test server, then

$ libwebsockets-test-client http://localhost:7681/formtest -o

It will post the string "hello" to the POST test using application/x-www-form-urlencoded

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

Also ensures any of the Client HTTP transient modes will call back LWS_CALLBACK_CLOSED_CLIENT_HTTP
if they close

https://github.com/warmcat/libwebsockets/issues/600
2016-08-10 21:23:01 +08:00
Andy Green
7acf76cd3d esp8266 initial support 2016-08-10 21:20:23 +08:00
Andy Green
f32d25051c ws ping pong on idle connections
This adds a new member to the context creation info struct "ws_ping_pong_interval".

If nonzero, it sets the number of seconds that established ws connections are
allowed to be idle before a PING is forced to be sent.  If zero (the default) then
tracking of idle connection is disabled for backwards compatibility.

Timeouts cover both the period between decision to send the ping and it being
sent (because it needs the socket to become writeable), and the period between
the ping being sent and the PONG coming back.

INFO debug logs are issues when the timeout stuff is operating.

You can test the server side by running the test server hacked to set ws_ping_pong_interval
and debug log mask of 15.  Both the mirror protocol and the server-status protocol are
idle if nothing is happening and will trigger the PING / PONG testing.  (You can also
test using lwsws and /etc/lwsws/conf with "ws-pingpong-secs": "20" in the global section)

For client, run the test client with -n -P 20 for 20s interval.  -n stops the test client
writing using the mirror protocol, so it will be idle and trigger the PING / PONGs.

The timeout interval may be up to +10s late, as lws checks for affected connections every
10s.
2016-08-10 21:20:23 +08:00
Andy Green
81c221ed35 CLIENT_CONNECTION_ERROR add strings
This clears up a couple of issues with client connect.

 - if CLIENT_CONNECTION_ERROR is coming, which of the many
   ways the rejection may have happened is documented in the
   in argument.  It's still possible if it just got hung up on
   in will be NULL, but now it has MANY more canned strings
   describing the issue available at the callback

	"getaddrinfo (ipv6) failed"
	"unknown address family"
	"getaddrinfo (ipv4) failed"
	"set socket opts failed"
	"insert wsi failed"
	"lws_ssl_client_connect1 failed"
	"lws_ssl_client_connect2 failed"
	"Peer hung up"
	"read failed"
	"HS: URI missing"
	"HS: Redirect code but no Location"
	"HS: URI did not parse"
	"HS: Redirect failed"
	"HS: Server did not return 200"
	"HS: OOM"
	"HS: disallowed by client filter"
	"HS: disallowed at ESTABLISHED"
	"HS: ACCEPT missing"
	"HS: ws upgrade response not 101"
	"HS: UPGRADE missing"
	"HS: Upgrade to something other than websocket"
	"HS: CONNECTION missing"
	"HS: UPGRADE malformed"
	"HS: PROTOCOL malformed"
	"HS: Cannot match protocol"
	"HS: EXT: list too big"
	"HS: EXT: failed setting defaults"
	"HS: EXT: failed parsing defaults"
	"HS: EXT: failed parsing options"
	"HS: EXT: Rejects server options"
	"HS: EXT: unknown ext"
	"HS: Accept hash wrong"
	"HS: Rejected by filter cb"
	"HS: OOM"
	"HS: SO_SNDBUF failed"
	"HS: Rejected at CLIENT_ESTABLISHED"

 - until now the user code did not get the new wsi that was created
    in the client connection action until it returned.  However the
    client connection action may provoke callbacks like
    CLIENT_CONNECTION_ERROR before then, if multiple client connections
    are initiated it makes it unknown to user code which one the callback
    applies to.  The wsi is provided in the callback but it has not yet
    returned from the client connect api to give that wsi to the user code.

    To solve that there is a new member added to client connect info struct,
    pwsi, which lets you pass a pointer to a struct wsi * in the user code
    that will get filled in with the new wsi.  That happens before any
    callbacks could be provoked, and it is updated to NULL if the connect
    action fails before returning from the client connect api.
2016-07-14 08:57:27 +08:00
Andy Green
014481e912 documentation convert to doxygen
Signed-off-by: Andy Green <andy@warmcat.com>
2016-07-14 08:57:27 +08:00
Andy Green
7201057d28 avoid illegal sockfd on timeout
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-04 09:02:09 +08:00
Andy Green
3a42fb545a 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>
2016-05-24 17:44:35 +08:00
Andy Green
e7c1c757cd 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>
2016-05-19 12:34:35 +08:00
Andy Green
97164368dd asserts log which
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-13 10:27:48 +08:00
Andy Green
b6d229d726 check oom on lws_malloc
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-12 21:04:33 +08:00
Andy Green
f1fd882d57 client fix reaction to tls failure
https://github.com/warmcat/libwebsockets/issues/508

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-03 07:26:10 +08:00
Andy Green
5bf2ce193b debug spew reduce
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-23 07:14:03 +08:00
Andy Green
c673125ce0 client http
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-18 20:05:43 +08:00
Andy Green
f5efa74cb7 cgi post
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-13 11:53:40 +08:00
Andy Green
020770566e plugins
This adds support for dynamically loaded plugins at runtime, which
can expose their own protocols or extensions transparently.

With these changes lwsws defaults to OFF in cmake, and if enabled it
automatically enables plugins and libuv support.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-07 09:38:08 +08:00
Andy Green
e8009155ba lws_service_adjust_timeout optimize
Make it exit quicker if something is pending

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-07 09:38:08 +08:00
Andy Green
513580d1bd revert 622d9f2 ssl pending handcrank
https://github.com/warmcat/libwebsockets/issues/483

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-05 19:43:07 +08:00
Andy Green
1a13885afd cgi env
Improve cgi support so it's capable of running cgit
2016-03-21 15:17:33 +08:00
Andy Green
1e5a9ad2dc proxy rewrite
If you enable -DLWS_WITH_HTTP_PROXY=1 at cmake, the test server has a
new URI path http://localhost:7681/proxytest If you visit here, a client
connection to http://example.com:80 is spawned, and the results piped on
to your original connection.

Also with LWS_WITH_HTTP_PROXY enabled at cmake, lws wants to link to an
additional library, "libhubbub".  This allows lws to do html rewriting on the
fly, adjusting proxied urls in a lightweight and fast way.
2016-03-20 11:59:53 +08:00
Andy Green
5c8906e931 client chunked transfer encoding
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-19 17:21:45 +08:00
Andy Green
c3c2d6d953 cgi header processing
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-19 17:21:45 +08:00
Andy Green
7bc87ab662 clean signed mismatches and protect ssl specific code
https://github.com/warmcat/libwebsockets/issues/466

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-18 23:55:59 +08:00
Andy Green
5960158958 clang fixes 1
https://github.com/warmcat/libwebsockets/issues/461

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-15 21:49:32 +08:00
Andy Green
494418abac add explicit parent child wsi relationships
wsi can have a full tree relationship with each other using
linked lists.  closing the parent ensures the children are
closed first.

Convert cgi to use this instead of his cgi-specific sub-wsi
management.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-02 18:57:41 +08:00
Daniel Santos
f3d1d41bdd satisfy apparently bogus compiler warning somewhere 2016-03-01 07:50:17 +08:00
Andy Green
a661ee5d53 client support http without ws
Server support for http[s] as well as ws[s] is implicit.
But until now client only supported ws[s].

This allows the user code to pass an explicit http method
like "GET" in the connect_info, disabling the ws upgrade logic.

Then you can also use lws client as http client, not just ws.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-29 18:41:36 +08:00