Commit graph

114 commits

Author SHA1 Message Date
Cory McWilliams
fff2bb5b21 Subject: Mismatched lws_zalloc / free 2017-08-17 07:33:54 +08:00
Andy Green
31b1029234 LWS_WITH_NO_LOGS: take care about unused array for log generation 2017-06-09 21:48:03 +08:00
Andy Green
3a09c3b7d6 esp32: align fops member name defines 2017-03-08 11:11:41 +08:00
Andy Green
b9dd61bb6f server-name: default to no server name unless set in context 2017-03-08 07:35:27 +08:00
Andy Green
205ccedf6e raw: enable server and client raw sockets 2017-03-07 16:06:05 +08:00
Andy Green
19cc7acb24 fops-zip 2017-03-05 15:32:55 +08:00
Andy Green
1ada132932 fops: allow setting from context creation and introduce lws_select_fops_by_vfs_path
1) There's now a .fops pointer that can be set in the context creation info.  If set, the array of
fops it points to (terminated by an entry with .open = NULL) is walked to find out the best vfs filesystem
path match (comparing the vfs path to fops.path_prefix) for which fops to use.

If none given (.fops is NULL in info) then behaviour is as before, fops are the platform-provided one only.

2) The built in fileserving now walks any array of fops looking for the best fops match automatically.

3) lws_plat_file_... apis are renamed to lws_vfs_file_...
2017-03-01 14:59:48 +08:00
Namowen
7832b236a4 vhost: also free per-vhost protocols list even when no PLUGINS 2017-02-20 06:20:56 +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
ce37ee9624 gcc- format strings: debug and extra plugins 2017-02-05 22:30:27 +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
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
fdddf5af51 clean: usused accidental global wsi
https://github.com/warmcat/libwebsockets/issues/708
2016-12-20 14:37:07 +08:00
Andy Green
69c88d9f0c context: external_baggage_free_on_destroy
This adds a context creation-time member that points to something
that should be freed when the context is destroyed.

It's in preparation for context deprecation, when a context might
be destroyed asynchronously... a related external with the
lifetime of thee context should also be freed at that time.

Adapt lwsws to use it with the context "strings" (also used for
aligned structs created by the config) allocation.
2016-12-20 14:37:07 +08:00
Bablooos
6e436dca39 vhost: allow adding vhosts after server init
This should allow adding vhosts "late", ie, after the server is up and
running with its initial vhost(s).  The necessary housekeeping is folded
into lws_create_vhost() itself so it should be transparent.

Notice though that at the point the server starts to do service after it
starts initially, if it was requested that the UID / GID change, that
is performed at that point and is not reversible.

So vhosts added "late" find themselves running under the unprivileged
UID / GID from the very start, whereas vhosts added "early" initially
run under the UID / GID the process started with.  If protocols the
vhost uses want to, eg, open privileged files at init and then use
them unprivileged, that will fail if the vhost is added late because
the initial privs are already gone.

AG: also deal with lws_protocol_init() on late vhost init (does the
callbacks for per vh protocol creation), add comments
2016-12-16 22:08:13 +08:00
Andy Green
3b93e344f6 Add reject service keywords list 2016-10-13 06:32:57 +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
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
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
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
014481e912 documentation convert to doxygen
Signed-off-by: Andy Green <andy@warmcat.com>
2016-07-14 08:57:27 +08:00
Andy Green
7a2fc442b6 protocol generic sessions
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-18 06:44:31 +08:00
Denis Osvald
33403a474e vhost creation print ipv6
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-06-04 08:37:31 +08:00
Andy Green
4889566d5d 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>
2016-06-02 13:03: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
7a9970f90d win fix warnings from appveyor
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-15 08:31:01 +08:00
Andy Green
b9c095db47 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>
2016-05-13 10:31:52 +08:00
Sterling Jensen
ecaed5ec94 Fix leak caused by undestroyed pthread mutex 2016-05-13 09:42:37 +08:00
Andy Green
fb8be0507e 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>
2016-05-12 21:14:13 +08:00
Andy Green
03e628b9a6 windows no chown on log file generation
https://github.com/warmcat/libwebsockets/issues/524

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-11 18:59:27 +08:00
Andy Green
0a4da2c71f 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>
2016-05-10 11:28:30 +08:00
Andy Green
b24aaeb822 add protocol plugin for post demo
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-09 10:05:43 +08:00
Andy Green
11d8efef88 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>
2016-05-08 17:00:38 +08:00
Andy Green
f6585285cb protocol plugins set default
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-06 14:24:59 +08:00
Andy Green
4eab21976c clean build warning on windows
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-04 11:11:15 +08:00
Andy Green
d5dc5dff13 provide default empty protocol zero handler if NULL protocols in info
Move the dummy stub protocol into the library as the default
if NULL protocols given, since that is likely to become popular.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-02 07:49:29 +08:00
Andy Green
952fcdede1 per vhost options struct explicitly const
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-02 06:01:59 +08:00
Andy Green
4664f71ed3 create_vhost move mounts list to info
There's no reason to not have the mounts linked list init also in the info
struct, rather than provide as a paramater to lws_create_vhost().  Now
is a good time to normalize that since this api only exists in master.

This also allows oldstyle "do everything at context creation time in one
vhost" guys to leverage mounts.

Also there's no reason the mounts linked-list pointer and all uses in lws
are non-const, so make them all explicitly const *.

Update the info struct docs to clarify which members are used when creating
a vhost and which for context creation.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-02 04:59:54 +08:00
Andy Green
5dd57a9430 coverity 160165 dead code
Yes... extension selection is not wired up yet

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-23 08:16:17 +08:00
Andy Green
42e8b189dc http cache policy
This allows mounts to define the caching policy of the files inside them.

Support is added in lwsws for controlling it from the config files.

The api for serializing a mount struct opaquely is removed and lws_http_mount struct
made public... it was getting out of control trying to hide the options.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-22 08:53:49 +08:00
Andy Green
980614035f plugin lws server status
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-18 20:05:43 +08:00
Andy Green
4714cf02f4 vh doubly linked list for wsi on same protocol
This trades off a couple of wsi pointers for vastly increased speed
for the callback when writeable "all protocol" variants when there
are many kinds of wsi active.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-16 08:40:35 +08:00
Andy Green
b21c20b5ff context settable server string
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-15 13:58:24 +08:00
Andy Green
2f0bc93d46 lws access log option and lwsws conf
This adds the ability to store apache-compatible logs to a file given at
vhost-creation time.

lwsws conf can set it per-vhost using "access-log": "<filepath>"

The feature defaults to disabled at cmake, it can be set independently but
LWS_WITH_LWSWS set it on.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-15 13:58:24 +08:00
Andy Green
868b9f2ecb strict transport security vhost option flag and lwsws conf support
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-14 21:27:38 +08:00
Andy Green
cc3c6fb047 vhost should have his own options
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-14 21:27:38 +08:00
Yeonjun Lim
3c6a8c1a24 Add unix domain socket 2016-04-14 20:59:16 +08:00
Andy Green
b46e4a866d vhost keepalive timeout
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-14 20:59:16 +08:00