1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/http-server/minimal-http-server-deaddrop
Andy Green b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
..
mount-origin lws logo: update minimal examples 2020-03-06 04:46:39 +00:00
uploads/user1 minimal example deaddrop 2018-12-01 11:05:59 +08:00
ba-passwords minimal example deaddrop 2018-12-01 11:05:59 +08:00
CMakeLists.txt cmakelist: Augean Stables refactor 2020-05-27 08:40:12 +01:00
localhost-100y.cert minimal example deaddrop 2018-12-01 11:05:59 +08:00
localhost-100y.key minimal example deaddrop 2018-12-01 11:05:59 +08:00
minimal-http-server-deaddrop.c sul: all timed objects use a single pt sul list 2019-08-09 10:12:09 +01:00
README.md minimal example deaddrop 2018-12-01 11:05:59 +08:00

lws minimal http server deaddrop

This demonstrates how you can leverage the lws deaddrop plugin to make a secure, modern html5 file upload and sharing application.

The demo is protected by basic auth credentials defined in the file at ./ba-passwords - by default the credentials are user: user1, password: password; and user: user2, password: password again.

You can upload files and have them appear on a shared, downloadable list that is dynamically updated to all clients open on the page. Only the authenticated uploader is able to delete the files he uploaded.

Multiple simultaneous ongoing file uploads are supported.

build

To build this standalone, you must tell cmake where the lws source tree ./plugins directory can be found, since it relies on including the source of the raw-proxy plugin.

 $ cmake . -DLWS_PLUGINS_DIR=~/libwebsockets/plugins && make

usage

 $ ./lws-minimal-http-server-deaddrop
[2018/12/01 10:31:09:7108] USER: LWS minimal http server deaddrop | visit https://localhost:7681
[2018/12/01 10:31:09:8511] NOTICE: Creating Vhost 'default' port 7681, 1 protocols, IPv6 off
[2018/12/01 10:31:09:8522] NOTICE:  Using SSL mode
[2018/12/01 10:31:10:0755] NOTICE:  SSL ECDH curve 'prime256v1'
[2018/12/01 10:31:10:2562] NOTICE: lws_tls_client_create_vhost_context: doing cert filepath localhost-100y.cert
[2018/12/01 10:31:10:2581] NOTICE: Loaded client cert localhost-100y.cert
[2018/12/01 10:31:10:2583] NOTICE: lws_tls_client_create_vhost_context: doing private key filepath
[2018/12/01 10:31:10:2593] NOTICE: Loaded client cert private key localhost-100y.key
[2018/12/01 10:31:10:2596] NOTICE: created client ssl context for default
[2018/12/01 10:31:10:5290] NOTICE:   deaddrop: vh default, upload dir ./uploads, max size 10000000
[2018/12/01 10:31:10:5376] NOTICE:    vhost default: cert expiry: 730203d
...

Visit https://localhost:7681, and follow the link there to the secret area.

Give your browser "user1" and "password" as the credentials. For testing to confirm what a different user sees, you can also log in as "user2" and "password".