Commit graph

1880 commits

Author SHA1 Message Date
Andy Green
f5efa74cb7 cgi post
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-13 11:53:40 +08:00
Andy Green
22d6f39e7f http2 update integration
https://github.com/warmcat/libwebsockets/issues/489

This

1) fixes the vhost changes on master

2) works around the ah pool changes

3) fixes some other build problems that appeared

4) hacks out physical flow control for internal streams

5) updates the advertised protocol to h2 needed by, eg, chrome 51

That gets it able to serve small (<4K, ie, one packet) files over http2

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-13 11:53:40 +08:00
Andy Green
a5e73a1a4b lwsws cgi integration
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-13 11:53:40 +08:00
Andy Green
6e7b79b263 lwsws specifically signed char return lejp
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-13 11:53:40 +08:00
Andy Green
0a183545b2 lwsws conf and plugins convert to libuv apis
After discussion here

https://libwebsockets.org/pipermail/libwebsockets/2016-April/002268.html

scandir usage in

 - lwsws conf.c
 - lws plugin support

and

 - lws plugin apis for dl

are converted to us libuv apis so they can work cross-platform easily.

lws itself remains not requiring libuv, although it's an option.

 - LWS_WITH_LWSWS
 - LWS_WITH_PLUGINS

now force LWS_WITH_LIBUV if selected... both of these are new features
only in master atm and both are off by default in CMake.

There's a complication libuv can be too old to offer the necessary apis,
this is the case in Travis Trusty instance.  In that case, UV_VERSION_MAJOR ==0,
then the unix-only plugin implementation is used instead.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-13 11:53:40 +08:00
Andy Green
e01a551a17 vhost if explicit vhosts only enable protocols with pvo mentions
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-13 11:53:16 +08:00
Andy Green
d459a6fadc lwsws redirect and correct vhost selection before accept
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-08 18:38:06 +08:00
Andy Green
37098ae2a2 lwsws protocol filter and options
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-08 16:13:14 +08:00
Meir Yanovich
efcf496b45 windows snprintf is _snprintf
https://github.com/warmcat/libwebsockets/issues/411#issuecomment-207290650
2016-04-08 16:11:27 +08:00
Galen Ma
da77a6007d android fix rlimit
https://github.com/warmcat/libwebsockets/issues/488
2016-04-08 16:02:59 +08:00
Andy Green
c5376b141a extensions add api for user code option manipulation
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-08 09:45:49 +08:00
Andy Green
150233d61f urldecode forbid malformed
And update attack.sh to confirm the new test cases

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-07 10:08:35 +08:00
Andy Green
fd12fc2781 plugins also link lwsws against websockets_shared
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-07 09:38:08 +08:00
Denis Osvald
8d21c350fc plugins link libwebsockets dynamically
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-04-07 09:38:08 +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
09998e3ad8 libuv add idle processing to force service where needed
https://github.com/warmcat/libwebsockets/issues/485

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
Meir Yanovich
2e15d0ad57 win32 libuv build notes 2016-04-05 19:19:46 +08:00
Meir Yanovich
d5ff4bf1bc win32 needs strange strftime args 2016-04-05 19:15:34 +08:00
Andy Green
a19ff9b24d uri processing reject paths not starting with slash
https://github.com/warmcat/libwebsockets/issues/481

Return 403 Forbidden if we don't end up with a uri path starting with /

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-05 06:58:04 +08:00
Andy Green
45dead99e0 libuv report init failure
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-05 06:57:02 +08:00
Andy Green
f29fbdf78a test server libevuv set LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT on ssl
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-05 06:56:59 +08:00
Meir Yanovich
9694ebefe8 libuv win32 fixes 2
https://github.com/warmcat/libwebsockets/issues/411#issuecomment-204284368
2016-04-01 15:56:48 +08:00
Andy Green
1c428c3154 test server align rxbuf with permessage deflate rx buf size
Add a test html button that will send 9KB of junk to confirm it

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

permessage-deflate now checks the protocol rx buffer size for being
>=128, if not, permessage-deflate is disabled on that connection.

If it is >=128 but less than the zlib decompress buffer size, the
zlib decompress buffer size for that connection is reduced to the
nearest power of two of the protocol rx buf size.

To test this, dumb_increment is left violating the >= 128 rx buffer
size and permessage-deflte can be seen to be disabled on his
connections in the test html.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-01 08:47:05 +08:00
Andy Green
bbcd24167f libuv win32 fixes
Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-31 20:12:14 +08:00
Andy Green
02ff145f50 cmake libuv fix include forcing path
Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-31 09:02:25 +08:00
V.Krishn
7d5b1531ef Fix build with musl libc
Fix building libwebsockets with the musl C libary.

<sys/cdefs.h> is an internal glibc header and should be avoided in user code.

__P() was used for compatibility with some old K&R C compilers, when there were
no prototypes (which were introduced to C with C89). As supporting legacy
non-ANSI compilers is nowadays not necessary anymore get rid of the unnecessary
function prototype using __P().
2016-03-30 06:25:19 +08:00
Andy Green
1a3f17700e mbedtls and polarssl first part
polarssl is the old name for mbedtls.  Unfortunately the two are confused in eg,
Fedora.  For our purposes, polarssl or mbedtls < 2.0 has includes in
/usr/include/polarssl and polarssl_ apis and we call that "polarssl".

polarssl or mbedtls >=2.0 has includes in /usr/include/mbedtls and mbedtls_ apis,
we call that "mbedtls".

This has to be spelled out clearly because eg Fedora has a package "mbedtls" which
is 1.3.x and has the polarssl_ apis and include path.  We will deal with that as
"polarssl" despite the package name then.

This patch lets you use LWS_USE_POLARSSL or LWS_USE_MBEDTLS and set the include and
library path like this

cmake .. -DLWS_USE_POLARSSL=1 -DLWS_POLARSSL_INCLUDE_DIRS=/usr/include -DLWS_POLARSSL_LIBRARIES=/usr/lib64/libmbedtls.so.9

This patch adds the cmake support and adapts [private-]libwebsockets.h but doesn't
modify the apis in ssl[-*].c yet.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-29 21:49:18 +08:00
Andy Green
f632e449de revert cmake remove targets from install path
Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-29 21:44:30 +08:00
Andy Green
7fe02e3af5 ssl split out common server and client ssl sources
Most of ssl.c is under a #ifdef for client or server disabled...
let's get rid of it and have CMake just build the appropriate
files

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-29 08:51:42 +08:00
Andy Green
eefb13a0a7 ssl migrate client pieces to ssl.c
Some ssl-specific code was still hiding out in client.c instead of
going in ssl.c

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-28 12:43:55 +08:00
Andy Green
cd0c696a0d lwsws Libwebsockets Web Server
This makes a start on the LibWebSockets WebServer.

The app cmake build support and JSON config parsing are implemented and
the app can start, create the vhosts, listen and serve file:// mounts on
them.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-28 10:49:57 +08:00
Andy Green
d526c50c22 introduce vhosts
This patch splits out some lws_context members into a new lws_vhost struct.

 - ssl state and options per vhost
 - SSL_CTX for serving and client per vhost
 - protocols[] per vhost
 - extensions[] per vhost

lws_context maintains a linked list of lws_vhosts.

The same lws_context_creation_info struct is used to regulate both the
context creation and to create vhosts: for backward compatibility if you
didn't provide the new LWS_SERVER_OPTION_EXPLICIT_VHOSTS option, then
a default vhost is created at context creation time using the same info
data as the context itself.

If you will have multiple vhosts though, you should give the
LWS_SERVER_OPTION_EXPLICIT_VHOSTS option at context creation time,
create the context first and then the vhosts afterwards using

  lws_create_vhost(contest, &info);

Although there is a lot of housekeeping to implement this change, there
is almost no additional overhead if you don't use multiple vhosts and
very little api impact (no changes to test apps).

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-28 10:15:25 +08:00
Andy Green
e2cf3e1cc0 SNI for server side: receive callback
This takes tha callback and binds the lws_context to the SSL_CTX so we can
get the lws_context in the callback.

It just logs the incoming hostname atm.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-26 09:27:34 +08:00
Andy Green
476329f3f8 http2 build with alpn capable ssl no debug
Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-25 21:01:11 +08:00
Andy Green
c6fd360160 LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT to default to runtime ssl disable
https://github.com/warmcat/libwebsockets/issues/468

Adds lws_check_opt() to regularize multibit flag checking.

There's a new context creation flag LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT,
this is included automatically if you give any other SSL-related option flag.
If you give no SSL-related option flag, nor this one directly, then even
though SSL support may be compiled in, it is never initialized nor used for the
whole lifetime of the lws context.

Conversely in order to prepare the context to use SSL, even though, eg, you
are not listening on SSL but will use SSL client connections later, you can
give this flag explicitly to make sure SSL is initialized.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-23 09:22:11 +08:00
Denis Osvald
f107e4bb85 libuv: sigint API cleanup
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-03-23 07:46:39 +08:00
Denis Osvald
de9f794b27 libuv: handle signals only if requested
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-03-23 07:44:06 +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
8007cc6829 b64decode correct decode of some strings
https://github.com/warmcat/libwebsockets/issues/467

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-19 07:43:22 +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
Alex Hultman
cea07d6f1f lws_write restrict chunk size 2016-03-18 15:02:27 +08:00
Andy Green
0f9904fedf ssl option for auto redir to https
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-17 15:27:18 +08:00
Alex Hultman
599cad9436 Optimize payload exhaustion
https://github.com/warmcat/libwebsockets/pull/462

AG refactor and do loop unrolling
2016-03-17 09:41:44 +08:00
Andy Green
e32c0ba29b appveyor update 1.0.2g
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-17 08:57:33 +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