Commit graph

2143 commits

Author SHA1 Message Date
Andy Green
72502e86f5 coverity 169276-9 - false positive assuming 8b char: char limits index size 2016-08-28 09:49:30 +08:00
Andy Green
d11bee7fc5 coverity 169274 - lwsgt dirlisting ignore files that cant be statted 2016-08-28 09:44:15 +08:00
Andy Green
01020b60f6 coverity 169273 - off-by-one on cgi chunking swallow limit 2016-08-28 09:44:15 +08:00
Andy Green
d6761e87b5 coverity 169272 - off-by-one possible on CGI buffer limit 2016-08-28 09:44:15 +08:00
Andy Green
d8e051dd97 coverity 169271 - take care about sockfd of -1 on close 2016-08-28 09:44:15 +08:00
Andy Green
2f863cf59a coverity 169269 - dont issue NULL cce 2016-08-28 09:44:15 +08:00
Andy Green
cd02a15669 coverity 169268 + 169270- dead code plus repeat NULL check on error path 2016-08-28 09:44:15 +08:00
Andy Green
e0212b8c85 coverity 169275 - lwsgt check string bounds 2016-08-28 09:44:15 +08:00
Andy Green
16f3e4cacf coverity 169267 - lwsgt strncpy may fill buffer without NUL 2016-08-28 09:10:40 +08:00
Andy Green
e35d91a860 per-vhost headers and lwsws conf support
This l;ets you add per-vhost arbitrary headers on served files, eg

     "headers": [{
        "X-Content-Type-Options": "nosniff",
        "X-XSS-Protection": "1; mode=block",
        "x-frame-options": "SAMEORIGIN"
        }],
2016-08-27 17:07:06 +08:00
Patrick Gansterer
46646f9ebf Update badges in README.md
Fix the link to Appveyor and use SVG images.
2016-08-27 05:57:18 +08:00
Patrick Gansterer
396b58ce70 Remove unneeded #include <stdint.h>
This fixes the build for Visual Studio 2008.
2016-08-26 18:31:09 +08:00
Andy Green
a5ec7212ff test html: js date uses ms 2016-08-23 18:29:17 +08:00
Andy Green
6fe25fd1fd cgi-retain-timeout-after-POST-send
Sending the POST data isn't enough to let us off the hook for timeout checks, if we
are doing a CGI on it.
2016-08-23 14:20:11 +08:00
Andy Green
b49b0fbafa quench logging 2016-08-22 07:07:10 +08:00
Andy Green
1172a89bb3 cgi: deal with all methods correctly 2016-08-20 06:46:17 +08:00
Andy Green
90f513b209 uv: dont handle SIGSEGV, SIGFPE
https://github.com/warmcat/libwebsockets/issues/609
2016-08-20 05:47:29 +08:00
Patrick Gansterer
fa9ebb394f Remove context from lws_context_per_thread for non-libuv builds
The variable is never read when built without libuv.
2016-08-14 20:55:24 +08:00
Patrick Gansterer
5162d876fd Add error handling for SSL_new() of clients
Do not access wsi->ssl if SSL_new() failed and log the error.
2016-08-14 19:53:20 +08:00
Patrick Gansterer
d0abf9bb5e Fix signature of lws_create_vhost() in README.coding.md 2016-08-14 19:48:59 +08:00
Patrick Gansterer
387e50bd8f Allow serving files without known mimetype
RFC2616 only says that any HTTP/1.1 message containing an entity-body
SHOULD include a Content-Type header field defining the media type of
that body.
RFC2119 defines SHOULD as: This word mean that there may exist valid
reasons in particular circumstances to ignore a particular item, but
the full implications must be understood and carefully weighed before
choosing a different course.

AG: this isn't an oversight, it's paranoia about sending out /etc/passwd
or /etc/shadow accidentally.

I agree it should be allowed if people really want to override it.  But
the default should remain like it is I think.

I adapted the patch to allow the extra mimetype "*": "" to be declared on
a mount, as a wildcard match that serves the file without a Content-Type.
2016-08-14 19:28:29 +08:00
Andy Green
3ffd0eb84a server max protocol element 64
https://github.com/warmcat/libwebsockets/issues/601
2016-08-11 05:36:08 +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
bbf93693d8 client fixups after esp8266 2016-08-10 21:23:01 +08:00
Andy Green
7acf76cd3d esp8266 initial support 2016-08-10 21:20:23 +08:00
Andy Green
f7a1c7ed47 base64 decode fix lengths 2016-08-10 21:20:23 +08:00
Andy Green
4606ad4377 ah detach: don't print held time if actually detached
Confusingly an ah held time was printed for a previously detached ah.

Clear down the time field when detaching the ah so this can't happen any more.
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
0fa6821214 Plugin server-status cleanup 2016-08-10 21:20:23 +08:00
Andy Green
2671b7469a plugins-dim-webpage-when-connection-lost 2016-07-14 08:57:28 +08:00
Andy Green
722cc4a366 plugin table dirlisting 2016-07-14 08:57:28 +08:00
Andy Green
02f880d9b6 doxygen use sections 2016-07-14 08:57:28 +08:00
Mike Messina
efef6bf9a0 Recheck slot when an FD gets closed and make formatting consistent 2016-07-14 08:57:28 +08:00
mmessina
fc0e52da9e Use one event for all sockets to avoid 64 limit and fix the single dispatch issue 2016-07-14 08:57:28 +08:00
Andy Green
5f73048d58 SNI-vhost-matching-fallback-to-wildcard 2016-07-14 08:57:28 +08:00
Andy Green
5ab523ec3f ah change default header len to 4096 and pool size 4
Users are starting to appear with clients sending more than the default max header
content buffer of 1024... with the advent of the ah pool the old reasons for keeping this
modest no longer apply, so up it to 4096 and reduce the default pool size to 4 from 16 to
keep the overall memory usage the same.
2016-07-14 08:57:28 +08:00
Andy Green
2b304a933f EXTPOLL export LWS_POLLXXX and document .events must be .revents 2016-07-14 08:57:28 +08:00
Andy Green
675c349cc5 client ssl add flag to control server cert hostname check 2016-07-14 08:57:28 +08:00
Andy Green
fee9f006f6 defer ESTABLISHED until after mode is WS_SERVING 2016-07-14 08:57:28 +08:00
Andy Green
0aa382f6fb lejp-conf: substitute _lws_ddir_ with install dir 2016-07-14 08:57:28 +08:00
Andy Green
cd6a70672b lejp_conf: pmo as alias for cgi-env
Since cgi-env only applies for cgi types, we can
re-use it for generic per-mount options (pmo)
2016-07-14 08:57:28 +08:00
Andy Green
ae0d8d74f9 win32-clean-and-use-do-while 2016-07-14 08:57:28 +08:00
Andy Green
906006e21e lws_get_mimetype 2016-07-14 08:57:27 +08:00
Andy Green
8860eddeb2 peer closes during partial buffered just hang up
https://github.com/warmcat/libwebsockets/issues/573
2016-07-14 08:57:27 +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
e8439168dc remove polarssl mbedtls support
Just remove it from cmake
2016-07-14 08:57:27 +08:00
Andy Green
f25eefdd41 reduce log spew and document test-server variants 2016-07-14 08:57:27 +08:00
Robin Rowe
8fdff1053c fix __x86_64__ check
https://github.com/warmcat/libwebsockets/issues/574
2016-07-14 08:57:27 +08:00
Andy Green
9ec76d4b72 test-libev add server-status protocol 2016-07-14 08:57:27 +08:00
Andy Green
e7bf0aa1dc client confirm server hostname in cert
Openssl v1.0.2 and above have support for checking the hostname
the client side connected to against the hostname on the cert the
server presented.

This enables that feature if the necessary API is available in the
openssl version, meaning the connection will fail at ssl negotiation if the
cert isn't for the requested server

It's very easy to test, add a fake entry to /etc/hosts for the server IP with
a different name, using that will fail at ssl but using the correct dns name
matching the certificate will work.
2016-07-14 08:57:27 +08:00