1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/lib/secure-streams/protocols
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
..
README.md client: secure streams 2020-03-04 12:17:49 +00:00
ss-h1.c lws_lifecycle 2021-01-04 05:26:50 +00:00
ss-h2.c lws_lifecycle 2021-01-04 05:26:50 +00:00
ss-mqtt.c lws_lifecycle 2021-01-04 05:26:50 +00:00
ss-raw.c lws_lifecycle 2021-01-04 05:26:50 +00:00
ss-ws.c lws_lifecycle 2021-01-04 05:26:50 +00:00

Lws Protocol bindings for Secure Streams

This directory contains the code wiring up normal lws protocols to Secure Streams.

The lws_protocols callback

This is the normal lws struct lws_protocols callback that handles events and traffic on the lws protocol being supported.

The various events and traffic are converted into calls using the Secure Streams api, and Secure Streams events.

The connect_munge helper

Different protocols have different semantics in the arguments to the client connect function, this protocol-specific helper is called to munge the connect_info struct to match the details of the protocol selected.

The ss->policy->aux string is used to hold protocol-specific information passed in the from the policy, eg, the URL path or websockets subprotocol name.

The (library-private) ss_pcols export

Each protocol binding exports two things to other parts of lws (they are not exported to user code)

  • a struct lws_protocols, including a pointer to the callback

  • a struct ss_pcols describing how secure_streams should use, including a pointer to the related connect_munge helper.

In ./lib/core-net/vhost.c, enabled protocols are added to vhost protcols lists so they may be used. And in ./lib/secure-streams/secure-streams.c, enabled struct ss_pcols are listed and checked for matches when the user creates a new Secure Stream.