From df7649d56f02960880a7149c37fc7c3d5b6f2c7e Mon Sep 17 00:00:00 2001 From: Russ Dill Date: Fri, 4 Feb 2022 13:12:52 -0800 Subject: [PATCH] Expose supplied client key in state The client key and id is currently supplied in a cookie. This provides a way for a client to determine it's id in order to match it within the state response. However if cookies are disabled or the source domain differs from the ustreamer domain the cookie will not be set. This provides an alternate way for a client to find the state response associated with it's connection by including the client provided key in the state response. If the client does not supply a key, the value 0 is supplied. Signed-off-by: Russ Dill --- src/ustreamer/http/server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ustreamer/http/server.c b/src/ustreamer/http/server.c index 7908640..5d2ebf3 100644 --- a/src/ustreamer/http/server.c +++ b/src/ustreamer/http/server.c @@ -421,13 +421,14 @@ static void _http_callback_state(struct evhttp_request *request, void *v_server) LIST_ITERATE(RUN(stream_clients), client, { assert(evbuffer_add_printf(buf, "\"%" PRIx64 "\": {\"fps\": %u, \"extra_headers\": %s, \"advance_headers\": %s," - " \"dual_final_frames\": %s, \"zero_data\": %s}%s", + " \"dual_final_frames\": %s, \"zero_data\": %s, \"key\": %s}%s", client->id, client->fps, bool_to_string(client->extra_headers), bool_to_string(client->advance_headers), bool_to_string(client->dual_final_frames), bool_to_string(client->zero_data), + client->key != NULL ? client->key : "0", (client->next ? ", " : "") )); });