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

3779 commits

Author SHA1 Message Date
Andy Green
6762c7367f remove: old esp32 helper pieces
The old esp32 -factory stuff along with the lws support doesn't have a
future in its old form.  It has users but the ratio of effort to
contribution is really especially bad.  I haven't updated it for more
than a year since esp-idf changes broke the original stuff.

Freertos plat is alive and well and getting a lot of new use, ESP-32 is
supported both there and by modern lws_drivers pieces, including in CI
on real hardware, any further effort will be invested in that direction
instead of more vendor api-specific code (outside of wrapper
implementation).

lws_drivers wraps any SDK apis in generic lws apis such that your code
just uses those, enabling it to become SDK / SoC / vendor independent.
Its first implementation is on esp-idf, the low and mid-level features
that were in the old -factory are already available using that and
new technologies like lws_struct and Secure Streams.
2020-07-15 16:18:00 +01:00
Andy Green
634a97ad79 lws_jwt_token_sanity 2020-07-15 16:18:00 +01:00
Andy Green
08b9a31e20 lws_json_simple: allow running into end
If the arg is unquoted, it's normal to run into the
end finding its extent.
2020-07-15 16:18:00 +01:00
Andy Green
77530f8ccb jwt: sign and create jws helper 2020-07-15 16:17:59 +01:00
Andy Green
5b3ea74b77 jwt: validate jws helper
Introduce a signed JWT validation helper
2020-07-15 16:17:59 +01:00
Andy Green
0bcfe88381 lws_http_cookie_get 2020-07-15 16:17:59 +01:00
Andy Green
cf41c3e793 jws: compact representation helper must use dots 2020-07-15 16:17:59 +01:00
Andy Green
4a5f1d83c2 ss: proxy: make sure state is always available in ssi 2020-07-15 16:17:59 +01:00
Andy Green
1ae6ce37d3 lws_dll2: add helper for typed object name from owner list
There's a good pattern that's encouraged by using lws_struct pieces, that
we have an lws_dll2 owner with an array of objects listed in it that exist
in an lwsac.  And because it came from JSON, there is tending to be a
logical name for the objects.

This adds a typed helper and wrapper to scan the owner list looking for
a specific name (of a specified length, not NUL terminated) in a specific
member of the listed objects, which must be a NUL-terminated const char *.
Again this is a good pattern that's encouraged by use of lws_tokenize
to recover the name we're looking for.

So it leads to the helper that can cleanly search for a listed object of the
right name from an owner, and return the typed object pointer or NULL, from a
length-specified string.
2020-07-09 15:30:34 +01:00
Andy Green
6b3221ffc1 mbedtls: only free crt_parse when something came back
Mbedtls mbedtls_x509_crt_parse() returns 0 for success which is good.
But it has a complicated idea about what to return on fail... if it
couldn't make even one cert from the data, then it returns a negative
return indicating the parsing problem and there is nothing to free.

If it managed to parse at least one cert, instead it retuns a positive
number indicating the number of certs it didn't parse successfully,
and there is something to free.

Adapt the code to understand this quirk.
2020-07-09 15:30:34 +01:00
Andy Green
73424ae66a ss: proxy: smd: use correct zombie vs message check 2020-07-08 19:47:55 +01:00
Andy Green
650a8781e9 ss: client: clear timeout when connection acknowledged 2020-07-08 19:20:03 +01:00
Andy Green
6b639e6a81 coverity: force amount to 0 before read call 2020-07-08 18:27:47 +01:00
Andy Green
4939b87e66 lws_netdev: use lws_settings
Perform the AP selection using lws_settings and a generic scan state machine
2020-07-07 15:23:19 +01:00
Jed Lu
ed528b59f7 ss: client: add sspc_to_user_obj
Helper api exists in direct lws_ss_ apis but not in lws_sspc_, align it.
2020-07-07 15:23:19 +01:00
Andy Green
e09430c48d ss: smd: no need to log msg alloc rejection 2020-07-07 15:23:19 +01:00
Andy Green
c410956a31 ss: event_helper handles destroy requests itself
Callbacks can ask the caller to, eg, destroy the ss handle now.  But some
callback returns are handled and produced inside other helper apis, eg
lws_ss_backoff() may have to had fulfilled the callback request to destroy
the ss... therefore it has to signal to its caller, and its callers have
to check and exit their flow accordingly.
2020-07-07 11:28:36 +01:00
Andy Green
1a756ca178 ss-h1: close bound wsi when state handler requests ss destroy 2020-07-07 11:28:28 +01:00
Andy Green
2e1969187d sul: lws_sul_nonmonotonic_adjust
FreeRTOS only supports nonmonotonic time, when we correct it by, eg,
ntpclient, we offset all the existing sul timeouts.  This adds an
internal helper function to correct existing sul timeouts by the
step amount, and call it in lws ntpclient implementation when
adjusting the gettimeofday() time.
2020-07-07 11:28:28 +01:00
Andy Green
f902873634 ss: add timeout 2020-07-07 11:28:28 +01:00
Andy Green
0f3b45bc20 ss: h1: completed transaction needs to leave ss wsi intact for close 2020-07-07 11:28:28 +01:00
Andy Green
dfed547529 glib: stop leaking idle and hrtimer source
This gives a valgrind result for lws-minimal-http-server-event-lib-foreign
that's clean for lws pieces, although glib is always dirty wrt thread local
storage and hashtable.
2020-07-07 11:28:28 +01:00
Andy Green
b72ab32c17 lws_netdev 2020-07-02 10:36:31 +01:00
Andy Green
65545d2d21 lws-settings 2020-07-02 10:20:17 +01:00
Andy Green
63c1e8ba00 esp32-wrover-kit
Add lws_display and minimal example support for esp32-wrover to match wsp32-heltec-wb32

Since no usable buttons that don't affect something else on wrover kit, assumes
a button to 0V on GPIO14.
2020-06-30 19:35:41 +01:00
Andy Green
4bcc446bf6 docs: ss: document ss state flow 2020-06-30 19:35:41 +01:00
Andy Green
64aee81ba7 ss: reset retry count for explicit connection request
This differentiates between client connections for retry / writeable requests
and explicit lws_ss_client_connect() api calls.  The former effectively uses
retry / backoff, and the latter resets the retry / backoff.

If you receive ALL_RETRIES_FAILED due to the retry policy, you can do whatever
you need to do there and call lws_ss_client_connect() to try to connect again
with a fresh, reset retry / backoff state.
2020-06-30 19:35:41 +01:00
Yichen Gu
2ba3b7b72b ss: rideshare fix for when h2 not available 2020-06-30 19:35:41 +01:00
Andy Green
0fb8504b20 client: suppress CONNECTION_ERROR if still in client_connect_via_info
If the client connection attempt fails early, we report it will a NULL
return from the client connection api.  If it fails later, perhaps after
more times around the event loop, we report it as a CONNECTION_ERROR.

This patch makes sure we don't do CONNECTION_ERROR flow if in fact we
are still in the client_connect_via_info() and in a position to report
the failure by returning NULL from there, without it under some
conditions we will do both a CONNECTION_ERROR and return NULL.
2020-06-30 19:35:41 +01:00
Andy Green
04c20d7460 ah: workaround for broken routers with no http header delimiter
There's a type of router in the wild issuing malformed http when
in captive portal mode... there's no \x0a\x0d but just \x0a
2020-06-30 17:52:10 +01:00
Jed Lu
84f8137fa6 ah-un_pos-cleanup-fix-other-path 2020-06-30 17:49:14 +01:00
Andy Green
a75a476026 ah: use unk_pos to clean up unknown header starts even without CUSTOM_HEADERS 2020-06-27 07:57:22 +01:00
Andy Green
8eca7e17f2 lws_smd: system message distribution
- Add low level system message distibution framework
 - Add support for local Secure Streams to participate using _lws_smd streamtype
 - Add apit test and minimal example
 - Add SS proxy support for _lws_smd

See minimal-secure-streams-smd README.md
2020-06-27 07:57:22 +01:00
Andy Green
30f3606b0e context: option to disable system state management 2020-06-27 07:57:22 +01:00
Andy Green
ceb4e53174 lws_button: classification
Now there's an abstract button class regardless of the underlying
connection, we can add more sophicsticated analysis on top of it
for processing its usually noisy events and classifying them into
smd-ready click, long-click or double-click events.

A "regime" defines the timing limits for different press recognition
and can be specified per-button, if not given a default regime is
applied.
2020-06-27 07:57:22 +01:00
Andy Green
33f1003305 lws_pwm 2020-06-27 07:57:22 +01:00
dev31337
81bff78c86 lejp: enable negative integers
https://github.com/warmcat/libwebsockets/issues/1957
2020-06-22 08:14:56 +01:00
Andy Green
43ba4e4ef5 libevent: enforce no event state duplication
https://github.com/warmcat/libwebsockets/issues/1956
2020-06-22 08:14:56 +01:00
Jed Lu
c2609f6d7b ss: http: if not retrying move to idle state 2020-06-22 08:14:56 +01:00
Andy Green
5a937fa830 lws_json_simple_find and lws_nstrstr
String helpers for scanning non-NUL-delimited strings safely,
and very cheap simple string match based JSON parse for cases
that make sense for it... for more complex cases, do a full
JSON parse.
2020-06-20 04:56:30 +01:00
Andy Green
d4a7c7134a lws_button and lws_led
Generic drivers for buttons and leds
2020-06-18 16:57:44 +01:00
Andy Green
6747ab830e content_info: make members conditional 2020-06-18 08:29:43 +01:00
Andy Green
fdf8a5f931 lws_mutex
Add a simple platform wrapper around OS mutexes.
*nix and windows == pthreads
freertos = SemaphoreHandle
2020-06-16 19:45:35 +01:00
Andy Green
c9f31bdceb ss-mqtt: additional strexp in MQTT policy elements
Allow usage of ${metadata} string substitution in more policy elements
for MQTT:

 - associated subscription topic in policy
 - associated publish topic in policy
 - associated will topic in policy
 - associated will message in policy

Tested against lws-minimal-mqtt-client-multi / mosquitto
2020-06-16 19:45:35 +01:00
Andy Green
ac6edaf199 lws_strexp: add ability to find output length without write
Sometimes we need to find out the substituted length before we can
allocate and actually store it.  Teach strexp that if we set the
output buffer to NULL (and the output length to something big) we
are asking for the substituted length and to not produce output.
2020-06-16 19:45:35 +01:00
Andy Green
30e6c22e14 openssl3: migrate genhmac to EVP
The low level apis for HMAC (including those only introduced at 1.1.0...)
are all deprecated in OpenSSL v3.

Let's bite the bullet and migrate to EVP, it's already existing in modern
OpenSSL and we already use it for genhash.

EVP needs a PKEY, sort that out and keep it around until the hmac is
destroyed.
2020-06-16 19:45:35 +01:00
Andy Green
4948291b8b multipart: quote boundary
https://github.com/warmcat/libwebsockets/issues/1948
2020-06-16 19:45:35 +01:00
Andy Green
15ce46d971 drivers: initial generic gpio and i2c plus bitbang
Make a start on generic peripheral and bus drivers to provide
meta-functionality regardless of platform.

On the one hand this simply provides...

 - bitbang i2c on top of esp-idf gpio apis
 - ssd1306 oled chip driver as found on Heltec WB32
 - modifications to the minimal example test for esp32 to use that

... on the other hand, those capabilities are provided by creating:

 - an abstract i2c class object
 - an abstract gpio class object
 - i2c class implementation using the abstract gpio for bitbang
 - an abstract display class object
 - an abstract display state (brightness, animated change,
    on/off/init tracking, autodim after inactive, auto-off /
    blanking after inactive)

... with the intention, eg, you only have to add a platform
implementation for the gpio to be able to use the i2c-based
display drivers and state handling, and i2c bitbang, without
any other modifications.
2020-06-10 19:17:08 +01:00
Andy Green
ad5a4f7040 clean 2020-06-10 19:07:38 +01:00
Andy Green
280584ff8f ipv6: support interface name for scope lookup
Currently for ipv6, we look up the scope assuming we were given an interface ip for
binding.  But with ipv4, we also support giving an interface name.

Check it against an interface name first and return that if valid.

https://github.com/warmcat/libwebsockets/issues/1944
2020-06-08 05:27:11 +01:00