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

473 commits

Author SHA1 Message Date
Andy Green
8a087043c6 smd: account for new interested peers joining while queue exists 2021-02-20 13:54:35 +00:00
Andy Green
dc051fb2ae OpenBSD: various api ports 2021-02-17 11:39:15 +00:00
Andy Green
8e5f8491db opensslv3: handle deprecation of EC apis
openssl v3-alpha11 has marked EC_KEY pieces as deprecated... we use it in
LWS_WITH_GENCRYPTO but the related RSA etc pieces were already deprecated
for that.  We use EC_KEY pieces in vhost init...

The apis are not removed but deprecated, we should have a way to keep
trucking, but as it is the deprecation warning is promoted to an error.

Let's add LWS_SUPPRESS_DEPRECATED_API_WARNINGS option off by default.  If
enabled at cmake, external deprecated api warnings are suppressed.  This
gives a general workaround for now for opensslv3.

In addition, even if you don't do that, let's notice we are on openssl v3
and don't build the EC curve selection stuff, I don't think anyone is
actually using it anyway.
2021-02-17 11:39:15 +00:00
Andy Green
599691d233 dhcp: clean 2021-02-17 11:39:15 +00:00
Gang Chen
54110778ab http: x-amn-dss-signature header 2021-02-17 11:39:15 +00:00
Andy Green
f42c97baa9 route: on change also check source address still extant 2021-02-17 11:39:12 +00:00
Andy Green
eb782bd41e ip tos support 2021-02-04 10:28:02 +00:00
Andy Green
15bb455249 sspc: dsh: add rx flow control to policy
Add .proxy_buflen_rxflow_on_above / .proxy_buflen_rxflow_off_below policy streamtype options
and manage the rx flow control for the onward ss wsi according to how the dsh for the
remote client is doing.

client_buflen_rxflow_... are there but not wired up.
2021-02-02 09:11:29 +00:00
Andy Green
0e6df74409 plugins: add option LWS_WITH_PLUGINS_BUILTIN
Add the ability to just build plugins into the main library.
They are already designed to have a pinhole export for when
they are used as dynamic lib plugins so their namespace
does not conflict.
2021-01-31 20:24:29 +00:00
Andy Green
39cc5aec7c vh: lws_vhd_find_by_pvo 2021-01-30 21:09:44 +00:00
Andy Green
dffe96446a ss: policy: treat policy as filepath if no opening brace 2021-01-29 21:22:35 +00:00
Andy Green
6497220e87 plugins: add LWS_BUILD_HASH to header and require match
Also prioritize LD_LIBRARY_PATH check for plugins first

Iterate through paths in LD_LIBRARY_PATH in order

Warn on failed plugins init but continue protocol init
2021-01-28 05:52:41 +00:00
Andy Green
f1e5e573e6 destroy: shuffle for internal 2021-01-22 12:24:58 +00:00
Andy Green
4dbf5454c9 tokenize: asterisk-nonterm 2021-01-17 09:38:08 +00:00
Andy Green
e2f18957c1 lws_strcmp_wildcard
Add helper to do a strcmp() but against the first argument that may
contain zero or more * wildcards
2021-01-16 20:52:48 +00:00
Christian Fuchs
b961e5f351 eventlib: add sd-event support 2021-01-11 08:12:46 +00:00
Andy Green
c86e1c5b56 cpd: lws_system_cpd_start_defer 2021-01-11 08:12:46 +00:00
Andy Green
aa45de9e2a ss: enforce only valid state transitions
The various stream transitions for direct ss, SSPC, smd, and
different protocols are all handled in different code, let's
stop hoping for the best and add a state transition validation
function that is used everywhere we pass a state change to a
user callback, and knows what is valid for the user state()
callback to see next, given the last state it was shown.

Let's assert if lws manages to violate that so we can find
where the problem is and provide a stricter guarantee about
what user state handler will see, no matter if ss or sspc
or other cases.

To facilitate that, move the states to start from 1, where
0 indicates the state unset.
2021-01-11 08:12:43 +00:00
Andy Green
629ccd4db8 sspc: ssv1: return policy about client dsh allocation
Let's allow the proxy to pass back what the policy says about
the size of dsh buffer the client side of this streamtype
should have.

Defer clientsize dsh generation until we got the info back
from the proxy in the response to the initial packet.  If
it's zero / unset in the policy, just go with 32KB.
2021-01-05 10:56:38 +00:00
Andy Green
1033e1d4c8 sspc: ssv1: pass client PID into proxy for tagging
Let's have the client processes pass in their pid, and tag the related proxy SS
with that pid, so we can see on whose behalf the proxy is acting.
2021-01-05 10:56:38 +00:00
Andy Green
4fc4c671fa sspc: ssv1: add serialization protocol versioning
Let's add a byte on the first message that sspc clients send,
indicating the version of the serialization protocol that the
client was built with.

Start the version at 1, we will add some more changes in other
patches and call v1 (now it has the versioning baked in)
the first real supported serialization version, this patch must
be applied with the next patches to actually represent v1
protocol changes.

This doesn't require user setting, the client is told what version
it supports in LWS_SSS_CLIENT_PROTOCOL_VERSION.  The proxy knows
what version(s) it can support and loudly hangs up on the client
if it doesn't understand its protocol version.
2021-01-05 10:56:38 +00:00
Jed Lu
c82910d30c ss: auth: sigv4
Add SS pieces for Sigv4 auth support
2021-01-05 10:56:38 +00:00
Andy Green
8ff35b819a smd-add-ss-rx-forwarder-helper
Add a helper to simplify passing smd ss rx traffic into the local
smd participants, excluding the rx that received it externally to
avoid looping.

Make the smd readme clearer with three diagrams and more explanation
of how the ss proxying works.
2021-01-05 10:56:38 +00:00
Andy Green
962993fd24 smd: add ss tx helper 2021-01-05 10:56:38 +00:00
Andy Green
619ef5eb17 smd: add use class base index
In addition to the well-known classes, add a user class base bit offset
so distributed user applications can cleanly send messages using SMD
2021-01-05 10:56:38 +00:00
Andy Green
940abe557a ss: policy: add auth mapping section 2021-01-05 10:56:38 +00:00
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
Andy Green
2d6b9a06a7 windows: migrate to WSAPoll
Switch out the guts of the default window platform
wait to use WSAPoll(), switch the lws_cancel_service()
mechanism to use a UDP socket pair.
2021-01-05 10:56:38 +00:00
Andy Green
1422b23899 dll2: explicitly confim detached dll2 has no linkage 2021-01-04 05:40:12 +00:00
Andy Green
ef6bebda3c lws_wsi_close: fix wsi name 2021-01-04 05:40:12 +00:00
Andy Green
905e5373c6 ss: proxy_buflen in policy sets proxy max dsh alloc per streamtype 2021-01-04 05:39:06 +00:00
Andy Green
0ceba15d9c lws_lifecycle
This adds some new objects and helpers for keeping and logging
info on grouped allocations, a group is, eg, SS handles or client
wsis.

Allocated objects get a context-unique "tag" string intended to replace
%p / wsi pointers etc.  Pointers quickly become confusing when
allocations are freed and reused, the tag string won't repeat
until you produce 2^64 objects in a context.

In addition the tag string documents the object group, with prefixes
like "wsi-" or "vh-" and contain object-specific additional
information like the vhost name, address / port  or the role of the wsi.
At creation time the lws code can use a format string and args
to add whatever group-specific info makes sense, eg, a wsi bound
to a secure stream can also append the guid of the secure stream,
it's copied into the new object tag and so is still available
cleanly after the stream is destroyed if the wsi outlives it.
2021-01-04 05:26:50 +00:00
Andy Green
d98c9310e1 ss: UNREACHABLE: set ordinal in state cb b0 if due to DNS server reachability issue
For LWSSSCS_UNREACHABLE state, the additional ord arg has b0 set if the
reason for the unreachability is because the DNS server itself was not
reachable (implying either DNS server is wrongly set, or is not reachable
due to not having connectivity through to it)
2020-12-27 08:42:02 +00:00
Andy Green
097bbbd1eb ss: client_connect and request_tx also return dispositions
Since client_connect and request_tx can be called from code that expects
the ss handle to be in scope, these calls can't deal with destroying the
ss handle and must pass the lws_ss_state_return_t disposition back to
the caller to handle.
2020-12-24 16:14:36 +00:00
Andy Green
5947e54a66 ss: mark client wsi bound to ss using flag 2020-12-24 16:14:36 +00:00
Andy Green
454adf55ef lws_ptr_diff_size_t
lws_ptr_diff() is a very handy helper reducing the pointer delta to an int
count of bytes... however many times we actually want a size_t count of bytes
since that's the type of the argument we're trying to feed.

Let's establish a variant that naturally issues size_t.
2020-12-24 16:14:24 +00:00
Andy Green
962e9ee345 wip: ss c++ classes
C++ APIs wrapping SS client


These are intended to provide an experimental protocol-independent c++
api even more abstracted than secure streams, along the lines of
"wget -Omyfile https://example.com/thing"

WIP
2020-12-02 10:15:50 +00:00
Andy Green
1cf25e3052 doc: lws_add_http_header_by_name make it clear the trailing : is expected 2020-12-01 15:38:20 +00:00
Andy Green
b4af4bf025 docs: lwsac doxygen 2020-11-28 10:58:38 +00:00
Andy Green
2bcae2b3b6 context: refactor destroy flow 2020-11-28 10:58:38 +00:00
Andy Green
9eb4c4fac2 client: rfc6724 dns results sorting
RFC6724 defines an ipv6-centric DNS result sorting algorithm, that
takes route and source address route information for the results
given by the DNS resolution, and sorts them in order of preferability,
which defines the order they should be tried in.

If LWS_WITH_NETLINK, then lws takes care about collecting and monitoring
the interface, route and source address information, and uses it to
perform the RFC6724 sorting to re-sort the DNS before trying to make
the connections.
2020-11-28 10:58:07 +00:00
Andy Green
1b7c0a08fc udp: convert to sa46
Let's stop using sockaddr and migrate to lws_sockaddr46 so the udp path
works more the same as the tcp / uds client connect path.
2020-11-26 09:23:30 +00:00
Andy Green
495a966302 mqtt: lws_system blobs for password username 2020-11-26 09:23:30 +00:00
Andy Green
3216d4d087 ss: server: add foreach client cb api
Server SS maintains a list of accepted client ss, add an api allowing
iterating through the clients via a user callback.
2020-11-11 06:58:20 +00:00
Andy Green
0d31b7a154 buflist: additional helpers 2020-11-09 07:40:40 +00:00
Andy Green
22e6d5212b spawn: in discrete env setting case do it readonly
OSX changed to blow a segfault on write to .rodata, exposing that
we're dropping a NUL in what can be .rodata to set the environment
manually.  We don't do this on Linux typically because we take the
code path where execvpe() is available to do the env for us.

Adapt the code to treat it as const, and underscore it by changing
its type to be const char ** in the info struct.
2020-10-19 16:35:03 +01:00
Andy Green
643a001ed8 roles: netlink
This creates a role for RFC3549 Netlink monitoring.

If the OS supports it (currently, linux) then each pt creates a wsi
with the netlink role and dumps the current routing table at pt init.
It then maintains a cache of the routing table in each pt.

Upon routing table changes an SMD message is issued as an event, and
Captive Portal Detection is triggered.

All of the pt's current connections are reassessed for routability under
the changed routing table, those that no longer have a valid route or
gateway are closed.
2020-10-19 16:35:03 +01:00
Andy Green
915f888f3e sa46: network check
This adds a helper to test if an sa46 is on an sa46-based subnet.

The compare helper is adapted to say that non INET/INET6 addresses with
the same AF match.
2020-10-19 16:35:03 +01:00
Andy Green
67d24d7c00 cleaning 2020-10-19 16:35:03 +01:00
Andy Green
4e973c3cc5 ss: metadata: rename value to add reminder about heap 2020-10-19 16:34:54 +01:00