1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
Commit graph

3150 commits

Author SHA1 Message Date
Andy Green
47e10ab200 dbus-ws-proxy
This builds on the new dbus role support to provide a minimal example proxy
between ws and dbus.

A client app is provided that asks the proxy to connect to libwebsockets.org
and proxy the drawing data from the mirror example there back to the dbus
client using dbus messages.
2018-10-13 08:16:27 +08:00
Andy Green
31dfc4aa12 role: dbus
This adds support for the integrating libdbus into the lws event loop.

Unlike the other roles, lws doesn't completely adopt the fd and libdbus insists
to retain control over the fd lifecycle.  However libdbus provides apis for
foreign code (lws) to provide event loop services to libdbus for the fd.

Accordingly, unlike the other roles rx and writeable are not subsumed into
lws callback messages and the events remain the property of libdbus.

A context struct wrapper is provided that is available in the libdbus
callbacks to bridge between the lws and dbus worlds, along with
a minimal example dbus client and server.
2018-10-13 08:16:27 +08:00
Anzey
bbbdc85421 ws: protocol list whitespace fix
https://github.com/warmcat/libwebsockets/issues/1423#issuecomment-427690736
2018-10-13 08:16:27 +08:00
Andy Green
bdaa339a6e README.ci.md 2018-10-13 08:16:27 +08:00
Andy Green
96628be371 callbacks: fix reuse of callback 75 2018-10-13 08:16:27 +08:00
Andy Green
df3e29ea16 README.vulnerability-reporting.md 2018-10-13 08:16:27 +08:00
Andy Green
fb2d13b462 README.contributing.md 2018-10-13 08:16:27 +08:00
Andy Green
074b8f3881 client: oom4: unify with __lws_free_wsi 2018-10-07 13:12:44 +08:00
Andy Green
f2888ca29d README.md: CII best practices badge 2018-10-07 13:12:41 +08:00
Andy Green
2f8efa1082 auth: record basic auth user
This causes the WSI_TOKEN_HTTP_AUTHORIZATION content to be
replaced by the plaintext username that succeeded to be
authenticated.
2018-10-02 10:52:09 +08:00
Andy Green
5760a562d8 ws-over-h2: unbreak 2018-10-02 05:42:56 +08:00
negativekelvin
9b35bc171b esp32: blows if allowed lejp 2018-10-01 15:50:50 +08:00
Andy Green
242f72ddab same vh protocol list: convert to dll_wss 2018-09-30 07:15:20 +08:00
Andy Green
a95a76399a threadpool: add return flag for outlive wsi 2018-09-30 07:08:59 +08:00
Andy Green
64ea98f11c issue_raw: translate transaction_completed decision about close into local semantics
via Chanson Shen

https://libwebsockets.org/pipermail/libwebsockets/2018-September/007672.html
2018-09-20 07:06:51 +08:00
Andy Green
000d2d2027 docs: adjust lost image links 2018-09-19 10:22:21 +08:00
Andy Green
93f4fe5532 lws_return_http_status: use /error.css if possible 2018-09-17 07:26:08 +08:00
Fredrik Fornstad
6104a25f1f Fix QTA erase after factory partition update 2018-09-17 07:26:08 +08:00
Andy Green
fd810f198a http proxy: client: unix socket support
This allows the client stuff to understand that addresses beginning with '+'
represent unix sockets.

If the first character after the '+' is '@', it understands that the '@'
should be read as '\0', in order to use Linux "abstract namespace"
sockets.

Further the lws_parse_uri() helper is extended to understand the convention
that an address starting with + is a unix socket, and treats the socket
path as delimited by ':', eg

http://+/var/run/mysocket:/my/path

HTTP Proxy is updated to allow mounts to these unix socket paths.

Proxy connections go out on h1, but are dynamically translated to h1 or h2
on the incoming side.

Proxy usage of libhubbub is separated out... LWS_WITH_HTTP_PROXY is on by
default, and LWS_WITH_HUBBUB is off by default.
2018-09-12 13:58:13 +08:00
Andy Green
dc38eea060 docs: CSP 2018-09-12 13:58:13 +08:00
Andy Green
ee250c0d83 esp32: follow idf meddlings 2018-09-12 09:38:30 +08:00
Chengsheng Shen
d8cf6e72ee roles: update ./lib/roles/README.md context.x path 2018-09-11 18:27:59 +08:00
Andy Green
78e6d45f78 openssl: error handling align 2018-09-11 18:27:59 +08:00
Andy Green
6a59af4282 test-app: remove -r resource path 2018-09-11 18:27:59 +08:00
Andy Green
95f3eb2980 plat: ENOTCONN 2018-09-11 18:27:59 +08:00
Andy Green
11fdbd8402 lwsws: logging: use stderr not syslog directly
systemd is completely at home using stderr logging to the journal,
without needing syslog apis.
2018-09-11 18:27:59 +08:00
Andy Green
ebed5e74cb threadpool 2018-09-11 18:27:59 +08:00
Andy Green
edd7efd43d client: libuv: fix close handling during redirect
During client redirect we "reset" the wsi to the redirect address,
involving closing the current fd that was told to redirect (it will
usually be a completely different server or port).

With libuv and its two-stage close that's not trivial.  This solves
the problem we will "reset" (overwrite) where the handle lives in the
wsi with new a new connection / handle by having it copied out into
an allocated watcher struct, which is freed in the uv close callback.

To confirm it the minimal ws client example gets some new options, the
original problem was replicated with this

$ lws-minimal-ws-client-echo -s invalid.url.com -p 80

https://github.com/warmcat/libwebsockets/issues/1390
2018-09-11 18:27:59 +08:00
Andy Green
ca33d2f5bf logging: ellipsisize logs longer than our line buffer
Currently the line buffer for vsnprintf() is 256, lines longer than that
end abruptly without a CRLF.

Change it to end with "...\n\0" when it truncates the line.

CSP header additions, logged on vhost init, longer than this are going
to become normal...
2018-09-11 18:27:59 +08:00
Andy Green
1665df4642 log client IP of well-wishers
Although getting a million of these doesn't make any trouble for lws, the
source should be logged.
2018-09-11 18:27:59 +08:00
Andy Green
fff8daa898 ws role: wsi ws may not have been allocated by time of close 2018-09-11 18:27:59 +08:00
Andy Green
3be0c5dfee genhmac: expose as VISIBLE 2018-09-11 18:27:59 +08:00
Sebastián Katzer
2223bc5041 Fix Iphlpapi.h -> iphlpapi.h
If you cross compile for Windows you will get an error otherwise that the header cannot be found.
See here for code example from microsoft: https://docs.microsoft.com/en-us/windows/desktop/iphlp/creating-a-basic-ip-helper-application
2018-09-11 18:27:59 +08:00
Andy Green
35473ca446 csp: update lwsgs 2018-09-11 18:27:59 +08:00
Andy Green
b31f8b2aa6 ws role: use protocol bind and unbind and transition earlier
Now individual role callbacks are added in an earlier patch for protocol
bind and unbind, change the ws upgrade action to use the generic protocol
bind and unbind apis so the corresponding callbacks are issued for ws.
2018-09-11 18:27:59 +08:00
Martin Milata
43d0ab02e2 Ignore unknown headers in multipart file upload
https://github.com/warmcat/libwebsockets/pull/1385
2018-09-11 18:27:59 +08:00
Andy Green
f6a3aa01c9 http: enlarge headers buffers since they may meet large headers from vhost config 2018-09-11 18:27:59 +08:00
Andy Green
97f3e66f3c test-app: upgrade test.html to have separate css and js for CSP 2018-09-11 18:27:59 +08:00
Andy Green
c1a1e38de0 LWS_WITH_STATS: only report ssl accept delay we have a start time for 2018-09-11 18:27:59 +08:00
Andy Green
25e5a58a02 CSP: Firefox bans default SVG styles
Firefox has a bug for 2 years

https://bugzilla.mozilla.org/show_bug.cgi?id=1262842

where a strict content-security-policy that is correctly followed
wrongly also defeats inline style inside SVG.

Apply the workaround told by the GIMP guys on the bug to convert
SVG styles to XML at export.
2018-09-11 18:27:59 +08:00
Andy Green
9ad08ec9c1 LWS_WITH_STATS: clean refactor dust
https://github.com/warmcat/libwebsockets/issues/1383
2018-09-11 18:27:59 +08:00
Andy Green
844b779130 lejp-conf: allow header value part to exceed one string chunk 2018-09-11 18:27:59 +08:00
Andy Green
60362c727d lejp: always allow an extra byte at the end of the string buffer for NUL 2018-09-11 18:27:59 +08:00
Andy Green
e618ce1d4c h2: use vhost headers with tolower adaptation
h2 was not applying vhost headers, make it do so.

Also adapt any header names to lower-case as required by h2.
2018-09-11 18:27:59 +08:00
Andy Green
89902847a8 unix skt: default on 2018-09-11 18:27:59 +08:00
Andy Green
a27dfb2a3e clean: coverity 2018-09-11 18:27:59 +08:00
Andy Green
253942ca80 clean: solve type conversion warnings for appveyor 2018-09-11 18:27:59 +08:00
Andy Green
d1f9f0ae2d libwebsockets.h: split out into a dir of sub-includes included by libwebsockets.h
This has no effect on user code or backward compatibility.

It moves the in-tree public api header libwebsockets.h from ./lib
to ./include, and introduces a dir ./include/libwebsockets/

The single public api header is split out into 31 sub-headers
in ./include/libwebsockets.  ./include/libwebsockets.h contains
some core types and platform adaptation code, but the rest of it
is now 31 #include <libwebsockets/...>

At install time, /usr/[local/]include/libwebsockets.h is installed
as before, along now with the 31 sub-headers in ...include/libwebsockets/

There's no net effect on user code.

But the api header is now much easier to maintain and study, with 31
topic-based sub headers.
2018-09-11 18:27:59 +08:00
Andy Green
d58828692e http: compression methods
Add generic http compression layer eanbled at cmake with LWS_WITH_HTTP_STREAM_COMPRESSION.

This is wholly a feature of the HTTP role (used by h1 and h2 roles) and doesn't exist
outside that context.

Currently provides 'deflate' and 'br' compression methods for server side only.

'br' requires also -DLWS_WITH_HTTP_BROTLI=1 at cmake and the brotli libraries (available in
your distro already) and dev package.

Other compression methods can be added nicely using an ops struct.

The built-in file serving stuff will use this is the client says he can handle it, and the
mimetype of the file either starts with "text/" (html and css etc) or is the mimetype of
Javascript.

zlib allocates quite a bit while in use, it seems to be around 256KiB per stream.  So this
is only useful on relatively strong servers with lots of memory.  However for some usecases
where you are serving a lot of css and js assets, it's a nice help.

The patch performs special treatment for http/1.1 pipelining, since the compression is
performed on the fly the compressed content-length is not known until the end.  So for h1
only, chunked transfer-encoding is automatically added so pipelining can continue of the
connection.

For h2 the chunking is neither supported nor required, so it "just works".

User code can also request to add a compression transform before the reply headers were
sent using the new api

LWS_VISIBLE int
lws_http_compression_apply(struct lws *wsi, const char *name,
			   unsigned char **p, unsigned char *end, char decomp);

... this allows transparent compression of dynamically generated HTTP.  The requested
compression (eg, "deflate") is only applied if the client headers indicated it was
supported, otherwise it's a NOP.

Name may be NULL in which case the first compression method in the internal table at
stream.c that is mentioned as acceptable by the client will be used.

NOTE: the compression translation, same as h2 support, relies on the user code using
LWS_WRITE_HTTP and then LWS_WRITE_HTTP_FINAL on the last part written.  The internal
lws fileserving code already does this.
2018-09-02 14:43:05 +08:00
Andy Green
90e6e65bff partial: replace ad-hoc code with a wsi buflist_out
Various kinds of input stashing were replaced with a single buflist before
v3.0... this patch replaces the partial send arrangements with its own buflist
in the same way.

Buflists as the name says are growable lists of allocations in a linked-list
that take care of book-keeping what's added and removed (even if what is
removed is less than the current buffer on the list).

The immediate result is that we no longer have to freak out if we had a partial
buffered and new output is coming... we can just pile it on the end of the
buflist and keep draining the front of it.

Likewise we no longer need to be rabid about reporting multiple attempts to
send stuff without going back to the event loop, although not doing that
will introduce inefficiencies we don't have to term it "illegal" any more.

Since buflists have proven reliable on the input side and the logic for dealing
with truncated "non-network events" was already there this internal-only change
should be relatively self-contained.
2018-08-20 12:02:26 +08:00