1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/raw/minimal-raw-fallback-http-server
Andy Green c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
..
mount-origin lws logo: update minimal examples 2020-03-06 04:46:39 +00:00
CMakeLists.txt cmake: latest cmake shows dep warnings for scripts < 2.8.12 2020-12-06 19:44:54 +00:00
localhost-100y.cert adopt: allow associated accepted vhost connections to specific role 2018-12-01 11:05:59 +08:00
localhost-100y.key adopt: allow associated accepted vhost connections to specific role 2018-12-01 11:05:59 +08:00
minimal-raw-fallback-http-server.c type comparisons: fixes 2021-01-05 10:56:38 +00:00
README.md role: raw-proxy 2018-12-01 11:05:59 +08:00

lws minimal raw fallback http server

This is the same as the minimal http server, with one difference... if you connect to localhost:7681 with something that doesn't send recognizable http, then the connection will be switched to a raw-skt role and bind to a protocol that echoes anything sent back to the sender.

build

 $ cmake . && make

usage

Commandline option Meaning
-d Debug verbosity in decimal, eg, -d15
-s Configure the server for tls / https and LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT
-h (needs -s) Configure the vhost also for LWS_SERVER_OPTION_ALLOW_HTTP_ON_HTTPS_LISTENER, allowing http service on tls port (caution... it's insecure then)
-u (needs -s) Configure the vhost also for LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS, so the server issues a redirect to https to clients that attempt to connect to a server configured for tls with http.
 $ ./lws-minimal-raw-fallback-http-server
[2018/11/29 14:27:34:3014] USER: LWS minimal raw fallback http server | visit http://localhost:7681
[2018/11/29 14:27:34:3243] NOTICE: Creating Vhost 'default' port 7681, 1 protocols, IPv6 off

Visit http://127.0.0.1:7681

This allows testing of various combinations of special features for unexpected content on an http(s) listening socket.

cmdline args http://127.0.0.1:7681 https://127.0.0.1:7681 ssh -p7681 127.0.0.1 flags
none served no tls echos hello LWS_SERVER_OPTION_FALLBACK_TO_APPLY_LISTEN_ACCEPT_CONFIG
-s echos http GET served echos hello LWS_SERVER_OPTION_FALLBACK_TO_APPLY_LISTEN_ACCEPT_CONFIG, LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT
-s -h served served echos hello LWS_SERVER_OPTION_FALLBACK_TO_APPLY_LISTEN_ACCEPT_CONFIG, LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT, LWS_SERVER_OPTION_ALLOW_HTTP_ON_HTTPS_LISTENER
-s -u redirected to https served echos hello LWS_SERVER_OPTION_FALLBACK_TO_APPLY_LISTEN_ACCEPT_CONFIG, LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT, LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS