From 30f3606b0eb9883e2f82271ada518d3147ee258c Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 23 Jun 2020 13:19:30 +0100 Subject: [PATCH] context: option to disable system state management --- CMakeLists.txt | 1 + cmake/lws_config.h.in | 1 + include/libwebsockets/lws-context-vhost.h | 8 ++++++- include/libwebsockets/lws-state.h | 6 +++++ include/libwebsockets/lws-system.h | 7 +++++- lib/core-net/CMakeLists.txt | 7 +++++- lib/core-net/network.c | 2 ++ lib/core-net/state.c | 2 +- lib/core/context.c | 15 ++++++++++++- lib/core/private-lib-core.h | 2 ++ lib/secure-streams/CMakeLists.txt | 3 ++- lib/secure-streams/secure-streams-process.c | 18 ++++++++------- .../system/fetch-policy/fetch-policy.c | 2 ++ lib/system/system.c | 2 ++ .../api-test-secure-streams/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-http-client/CMakeLists.txt | 1 + .../minimal-mqtt-client-multi/CMakeLists.txt | 1 + .../minimal-mqtt-client/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-secure-streams-avs/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-secure-streams/CMakeLists.txt | 1 + .../minimal-secure-streams.c | 22 +++++++++++++++++++ 26 files changed, 95 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c0405591..311e9f9e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,7 @@ option(LWS_WITH_SYS_NTPCLIENT "Build in tiny ntpclient good for tls date validat option(LWS_WITH_SYS_DHCP_CLIENT "Build in tiny DHCP client" OFF) option(LWS_WITH_HTTP_BASIC_AUTH "Support Basic Auth" ON) option(LWS_WITH_HTTP_UNCOMMON_HEADERS "Include less common http header support" ON) +option(LWS_WITH_SYS_STATE "lws_system state support" ON) # # Secure Streams diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in index a33f55dc0..c24af00ff 100644 --- a/cmake/lws_config.h.in +++ b/cmake/lws_config.h.in @@ -179,6 +179,7 @@ #cmakedefine LWS_WITH_SQLITE3 #cmakedefine LWS_WITH_SYS_NTPCLIENT #cmakedefine LWS_WITH_SYS_DHCP_CLIENT +#cmakedefine LWS_WITH_SYS_STATE #cmakedefine LWS_WITH_THREADPOOL #cmakedefine LWS_WITH_TLS #cmakedefine LWS_WITH_UDP diff --git a/include/libwebsockets/lws-context-vhost.h b/include/libwebsockets/lws-context-vhost.h index ef03c4104..14ca4c98a 100644 --- a/include/libwebsockets/lws-context-vhost.h +++ b/include/libwebsockets/lws-context-vhost.h @@ -221,11 +221,15 @@ #define LWS_SERVER_OPTION_GLIB (1ll << 33) /**< (CTX) Use glib event loop */ -#define LWS_SERVER_OPTION_H2_PRIOR_KNOWLEDGE (1ll << 34) +#define LWS_SERVER_OPTION_H2_PRIOR_KNOWLEDGE (1ll << 34) /**< (VH) Tell the vhost to treat plain text http connections as * H2 with prior knowledge (no upgrade request involved) */ +#define LWS_SERVER_OPTION_NO_LWS_SYSTEM_STATES (1ll << 35) + /**< (CTX) Disable lws_system state, eg, because we are a secure streams + * proxy client that is not trying to track system state by itself. */ + /****** add new things just above ---^ ******/ @@ -725,10 +729,12 @@ struct lws_context_creation_info { /**< VHOST: optional retry and idle policy to apply to this vhost. * Currently only the idle parts are applied to the connections. */ +#if defined(LWS_WITH_SYS_STATE) lws_state_notify_link_t * const *register_notifier_list; /**< CONTEXT: NULL, or pointer to an array of notifiers that should * be registered during context creation, so they can see state change * events from very early on. The array should end with a NULL. */ +#endif #if defined(LWS_WITH_SECURE_STREAMS) #if defined(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY) const struct lws_ss_policy *pss_policies; /**< CONTEXT: point to first diff --git a/include/libwebsockets/lws-state.h b/include/libwebsockets/lws-state.h index e5adabc4e..dfa688f1f 100644 --- a/include/libwebsockets/lws-state.h +++ b/include/libwebsockets/lws-state.h @@ -25,6 +25,8 @@ struct lws_state_notify_link; struct lws_state_manager; +#if defined(LWS_WITH_SYS_STATE) + typedef int (*lws_state_notify_t)(struct lws_state_manager *mgr, struct lws_state_notify_link *link, int current, int target); @@ -107,3 +109,7 @@ lws_state_transition_steps(lws_state_manager_t *mgr, int target); */ LWS_EXTERN LWS_VISIBLE int lws_state_transition(lws_state_manager_t *mgr, int target); + +#else + +#endif diff --git a/include/libwebsockets/lws-system.h b/include/libwebsockets/lws-system.h index bf946e474..6167a953d 100644 --- a/include/libwebsockets/lws-system.h +++ b/include/libwebsockets/lws-system.h @@ -175,6 +175,8 @@ typedef struct lws_system_ops { */ } lws_system_ops_t; +#if defined(LWS_WITH_SYS_STATE) + /** * lws_system_get_state_manager() - return the state mgr object for system state * @@ -186,7 +188,7 @@ typedef struct lws_system_ops { LWS_EXTERN LWS_VISIBLE lws_state_manager_t * lws_system_get_state_manager(struct lws_context *context); - +#endif /* wrappers handle NULL members or no ops struct set at all cleanly */ @@ -203,6 +205,8 @@ lws_system_get_state_manager(struct lws_context *context); LWS_EXTERN LWS_VISIBLE const lws_system_ops_t * lws_system_get_ops(struct lws_context *context); +#if defined(LWS_WITH_SYS_STATE) + /** * lws_system_context_from_system_mgr() - return context from system state mgr * @@ -214,6 +218,7 @@ lws_system_get_ops(struct lws_context *context); LWS_EXTERN LWS_VISIBLE struct lws_context * lws_system_context_from_system_mgr(lws_state_manager_t *mgr); +#endif /** * __lws_system_attach() - get and set items on context attach list diff --git a/lib/core-net/CMakeLists.txt b/lib/core-net/CMakeLists.txt index 671b99fe1..5bbc24ae9 100644 --- a/lib/core-net/CMakeLists.txt +++ b/lib/core-net/CMakeLists.txt @@ -33,13 +33,18 @@ list(APPEND SOURCES core-net/pollfd.c core-net/service.c core-net/sorted-usec-list.c - core-net/state.c core-net/wsi.c core-net/wsi-timeout.c core-net/adopt.c roles/pipe/ops-pipe.c ) +if (LWS_WITH_SYS_STATE) + list(APPEND SOURCES + core-net/state.c + ) +endif() + if (LWS_WITH_DETAILED_LATENCY) list(APPEND SOURCES core-net/detailed-latency.c) diff --git a/lib/core-net/network.c b/lib/core-net/network.c index 49999173c..af44a3979 100644 --- a/lib/core-net/network.c +++ b/lib/core-net/network.c @@ -851,8 +851,10 @@ lws_sa46_compare_ads(const lws_sockaddr46 *sa46a, const lws_sockaddr46 *sa46b) return sa46a->sa4.sin_addr.s_addr != sa46b->sa4.sin_addr.s_addr; } +#if defined(LWS_WITH_SYS_STATE) lws_state_manager_t * lws_system_get_state_manager(struct lws_context *context) { return &context->mgr_system; } +#endif diff --git a/lib/core-net/state.c b/lib/core-net/state.c index 8fe830bf6..660cf917d 100644 --- a/lib/core-net/state.c +++ b/lib/core-net/state.c @@ -1,7 +1,7 @@ /* * libwebsockets - small server side websockets and web server implementation * - * Copyright (C) 2010 - 2019 Andy Green + * Copyright (C) 2010 - 2020 Andy Green * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to diff --git a/lib/core/context.c b/lib/core/context.c index 196ea67ec..adf43e0f3 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -82,6 +82,8 @@ lws_sul_peer_limits_cb(lws_sorted_usec_list_t *sul) #if defined(LWS_WITH_NETWORK) +#if defined(LWS_WITH_SYS_STATE) + #if defined(_DEBUG) static const char * system_state_names[] = { "undef", @@ -101,6 +103,7 @@ static const char * system_state_names[] = { }; #endif + /* * Handle provoking protocol init when we pass through the right system state */ @@ -213,6 +216,7 @@ lws_context_creation_completion_cb(lws_sorted_usec_list_t *sul) lws_state_transition_steps(&context->mgr_system, LWS_SYSTATE_OPERATIONAL); } +#endif /* WITH_SYS_STATE */ #endif struct lws_context * @@ -824,6 +828,7 @@ lws_create_context(const struct lws_context_creation_info *info) } #endif +#if defined(LWS_WITH_SYS_STATE) /* * init the lws_state mgr for the system state */ @@ -847,6 +852,7 @@ lws_create_context(const struct lws_context_creation_info *info) lws_state_reg_notifier_list(&context->mgr_system, info->register_notifier_list); +#endif /* * if he's not saying he'll make his own vhosts later then act @@ -914,6 +920,7 @@ lws_create_context(const struct lws_context_creation_info *info) if (lws_plat_drop_app_privileges(context, 1)) goto bail; +#if defined(LWS_WITH_SYS_STATE) /* * We want to move on the syste, state as far as it can go towards * OPERATIONAL now. But we have to return from here first so the user @@ -925,6 +932,7 @@ lws_create_context(const struct lws_context_creation_info *info) lws_sul_schedule(context, 0, &context->sul_system_state, lws_context_creation_completion_cb, 1); +#endif /* expedite post-context init (eg, protocols) */ lws_cancel_service(context); @@ -1002,11 +1010,12 @@ lws_system_cpd_set(struct lws_context *cx, lws_cpd_result_t result) lwsl_notice("%s: setting CPD result %s\n", __func__, cname[result]); cx->captive_portal_detect = (uint8_t)result; - +#if defined(LWS_WITH_SYS_STATE) /* if nothing is there to intercept anything, go all the way */ if (cx->mgr_system.state != LWS_SYSTATE_POLICY_INVALID) lws_state_transition_steps(&cx->mgr_system, LWS_SYSTATE_OPERATIONAL); +#endif } lws_cpd_result_t @@ -1345,7 +1354,9 @@ lws_context_destroy(struct lws_context *context) context->being_destroyed = 1; #if defined(LWS_WITH_NETWORK) +#if defined(LWS_WITH_SYS_STATE) lws_state_transition(&context->mgr_system, LWS_SYSTATE_POLICY_INVALID); +#endif m = context->count_threads; while (m--) { @@ -1434,6 +1445,7 @@ out: #endif } +#if defined(LWS_WITH_SYS_STATE) struct lws_context * lws_system_context_from_system_mgr(lws_state_manager_t *mgr) { @@ -1443,3 +1455,4 @@ lws_system_context_from_system_mgr(lws_state_manager_t *mgr) return NULL; #endif } +#endif diff --git a/lib/core/private-lib-core.h b/lib/core/private-lib-core.h index 6aac81329..9fcddb0d2 100644 --- a/lib/core/private-lib-core.h +++ b/lib/core/private-lib-core.h @@ -375,8 +375,10 @@ struct lws_context { lws_sorted_usec_list_t sul_api_amazon_com_kick; #endif +#if defined(LWS_WITH_SYS_STATE) lws_state_manager_t mgr_system; lws_state_notify_link_t protocols_notify; +#endif #if defined (LWS_WITH_SYS_DHCP_CLIENT) lws_dll2_owner_t dhcpc_owner; /**< list of ifaces with dhcpc */ diff --git a/lib/secure-streams/CMakeLists.txt b/lib/secure-streams/CMakeLists.txt index 1d46849d2..ead679d0a 100644 --- a/lib/secure-streams/CMakeLists.txt +++ b/lib/secure-streams/CMakeLists.txt @@ -73,7 +73,8 @@ if (LWS_WITH_CLIENT) ) endif() - if (LWS_WITH_SECURE_STREAMS_SYS_AUTH_API_AMAZON_COM) + if (LWS_WITH_SECURE_STREAMS_SYS_AUTH_API_AMAZON_COM AND + LWS_WITH_SYS_STATE) list(APPEND SOURCES secure-streams/system/auth-api.amazon.com/auth.c ) diff --git a/lib/secure-streams/secure-streams-process.c b/lib/secure-streams/secure-streams-process.c index 8ee0d11b4..65362cb64 100644 --- a/lib/secure-streams/secure-streams-process.c +++ b/lib/secure-streams/secure-streams-process.c @@ -385,15 +385,17 @@ callback_ss_proxy(struct lws *wsi, enum lws_callback_reasons reason, * first 4 bytes or the create result, comma-separated */ - rsp = conn->ss->policy; + if (conn->ss) { + rsp = conn->ss->policy; - while (rsp) { - if (n != 4 && n < (int)sizeof(s) - 2) - s[n++] = ','; - n += lws_snprintf(&s[n], sizeof(s) - n, - "%s", rsp->streamtype); - rsp = lws_ss_policy_lookup(wsi->context, - rsp->rideshare_streamtype); + while (rsp) { + if (n != 4 && n < (int)sizeof(s) - 2) + s[n++] = ','; + n += lws_snprintf(&s[n], sizeof(s) - n, + "%s", rsp->streamtype); + rsp = lws_ss_policy_lookup(wsi->context, + rsp->rideshare_streamtype); + } } s[2] = n - 3; conn->state = LPCS_OPERATIONAL; diff --git a/lib/secure-streams/system/fetch-policy/fetch-policy.c b/lib/secure-streams/system/fetch-policy/fetch-policy.c index 65444f8b5..cbf54f0b9 100644 --- a/lib/secure-streams/system/fetch-policy/fetch-policy.c +++ b/lib/secure-streams/system/fetch-policy/fetch-policy.c @@ -83,8 +83,10 @@ policy_set(lws_sorted_usec_list_t *sul) lwsl_err("%s: policy set failed\n", __func__); else { context->policy_updated = 1; +#if defined(LWS_WITH_SYS_STATE) lws_state_transition_steps(&context->mgr_system, LWS_SYSTATE_OPERATIONAL); +#endif } } diff --git a/lib/system/system.c b/lib/system/system.c index e5c8723d9..af7c3341b 100644 --- a/lib/system/system.c +++ b/lib/system/system.c @@ -179,6 +179,7 @@ __lws_system_attach(struct lws_context *context, int tsi, lws_attach_cb_t cb, } *get = NULL; +#if defined(LWS_WITH_SYS_STATE) if (!pt->attach_owner.count) return 0; @@ -202,6 +203,7 @@ __lws_system_attach(struct lws_context *context, int tsi, lws_attach_cb_t cb, return 0; } } lws_end_foreach_dll(d); +#endif /* nobody ready to go... leave *get as NULL and return cleanly */ diff --git a/minimal-examples/api-tests/api-test-secure-streams/CMakeLists.txt b/minimal-examples/api-tests/api-test-secure-streams/CMakeLists.txt index 6396f98d7..0640e811a 100644 --- a/minimal-examples/api-tests/api-test-secure-streams/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-secure-streams/CMakeLists.txt @@ -6,6 +6,7 @@ include(LwsCheckRequirements) set(requirements 1) require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) require_lws_config(LWS_WITH_TLS 1 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) diff --git a/minimal-examples/http-client/minimal-http-client-captive-portal/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-captive-portal/CMakeLists.txt index dcfc9832e..09c81330d 100644 --- a/minimal-examples/http-client/minimal-http-client-captive-portal/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-captive-portal/CMakeLists.txt @@ -13,6 +13,7 @@ set(requirements 1) require_lws_config(LWS_ROLE_H1 1 requirements) require_lws_config(LWS_WITH_TLS 1 requirements) require_lws_config(LWS_WITH_CLIENT 1 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (NOT WIN32 AND requirements) add_executable(${SAMP} ${SRCS}) diff --git a/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt index f3ae1a79c..f755f0057 100644 --- a/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt @@ -11,6 +11,7 @@ set(SRCS minimal-http-client.c) set(requirements 1) require_lws_config(LWS_ROLE_H2 1 requirements) require_lws_config(LWS_WITH_CLIENT 1 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} ${SRCS}) diff --git a/minimal-examples/http-client/minimal-http-client/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client/CMakeLists.txt index 7405e74f2..f4c2e991c 100644 --- a/minimal-examples/http-client/minimal-http-client/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client/CMakeLists.txt @@ -11,6 +11,7 @@ set(SRCS minimal-http-client.c) set(requirements 1) require_lws_config(LWS_ROLE_H1 1 requirements) require_lws_config(LWS_WITH_CLIENT 1 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} ${SRCS}) diff --git a/minimal-examples/mqtt-client/minimal-mqtt-client-multi/CMakeLists.txt b/minimal-examples/mqtt-client/minimal-mqtt-client-multi/CMakeLists.txt index 7e878efea..aced38443 100644 --- a/minimal-examples/mqtt-client/minimal-mqtt-client-multi/CMakeLists.txt +++ b/minimal-examples/mqtt-client/minimal-mqtt-client-multi/CMakeLists.txt @@ -11,6 +11,7 @@ set(SRCS minimal-mqtt-client-multi.c) set(requirements 1) require_lws_config(LWS_ROLE_MQTT 1 requirements) require_lws_config(LWS_WITH_CLIENT 1 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} ${SRCS}) diff --git a/minimal-examples/mqtt-client/minimal-mqtt-client/CMakeLists.txt b/minimal-examples/mqtt-client/minimal-mqtt-client/CMakeLists.txt index a0d05db4c..ce1a67f1d 100644 --- a/minimal-examples/mqtt-client/minimal-mqtt-client/CMakeLists.txt +++ b/minimal-examples/mqtt-client/minimal-mqtt-client/CMakeLists.txt @@ -9,6 +9,7 @@ set(SRCS minimal-mqtt-client.c) set(requirements 1) require_lws_config(LWS_ROLE_MQTT 1 requirements) require_lws_config(LWS_WITH_CLIENT 1 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} ${SRCS}) diff --git a/minimal-examples/secure-streams/minimal-secure-streams-alexa/CMakeLists.txt b/minimal-examples/secure-streams/minimal-secure-streams-alexa/CMakeLists.txt index 077440a1b..bad2498f6 100644 --- a/minimal-examples/secure-streams/minimal-secure-streams-alexa/CMakeLists.txt +++ b/minimal-examples/secure-streams/minimal-secure-streams-alexa/CMakeLists.txt @@ -14,6 +14,7 @@ require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 requirements) require_lws_config(LWS_WITH_ALSA 1 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} ${SRCS}) diff --git a/minimal-examples/secure-streams/minimal-secure-streams-avs/CMakeLists.txt b/minimal-examples/secure-streams/minimal-secure-streams-avs/CMakeLists.txt index edb410dea..1d4d4ba4f 100644 --- a/minimal-examples/secure-streams/minimal-secure-streams-avs/CMakeLists.txt +++ b/minimal-examples/secure-streams/minimal-secure-streams-avs/CMakeLists.txt @@ -12,6 +12,7 @@ require_lws_config(LWS_ROLE_H1 1 requirements) require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} main.c avs.c) diff --git a/minimal-examples/secure-streams/minimal-secure-streams-metadata/CMakeLists.txt b/minimal-examples/secure-streams/minimal-secure-streams-metadata/CMakeLists.txt index 267568d45..63cfea8a8 100644 --- a/minimal-examples/secure-streams/minimal-secure-streams-metadata/CMakeLists.txt +++ b/minimal-examples/secure-streams/minimal-secure-streams-metadata/CMakeLists.txt @@ -12,6 +12,7 @@ require_lws_config(LWS_ROLE_H1 1 requirements) require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} minimal-secure-streams.c) diff --git a/minimal-examples/secure-streams/minimal-secure-streams-proxy/CMakeLists.txt b/minimal-examples/secure-streams/minimal-secure-streams-proxy/CMakeLists.txt index 485205fc9..3068dca15 100644 --- a/minimal-examples/secure-streams/minimal-secure-streams-proxy/CMakeLists.txt +++ b/minimal-examples/secure-streams/minimal-secure-streams-proxy/CMakeLists.txt @@ -14,6 +14,7 @@ require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS_PROXY_API 1 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} ${SRCS}) diff --git a/minimal-examples/secure-streams/minimal-secure-streams/CMakeLists.txt b/minimal-examples/secure-streams/minimal-secure-streams/CMakeLists.txt index 8428f9db1..1f97b9cd2 100644 --- a/minimal-examples/secure-streams/minimal-secure-streams/CMakeLists.txt +++ b/minimal-examples/secure-streams/minimal-secure-streams/CMakeLists.txt @@ -12,6 +12,7 @@ require_lws_config(LWS_ROLE_H1 1 requirements) require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 requirements) +require_lws_config(LWS_WITH_SYS_STATE 1 requirements) if (requirements) add_executable(${SAMP} minimal-secure-streams.c) diff --git a/minimal-examples/secure-streams/minimal-secure-streams/minimal-secure-streams.c b/minimal-examples/secure-streams/minimal-secure-streams/minimal-secure-streams.c index bdd429741..6ee063097 100644 --- a/minimal-examples/secure-streams/minimal-secure-streams/minimal-secure-streams.c +++ b/minimal-examples/secure-streams/minimal-secure-streams/minimal-secure-streams.c @@ -206,6 +206,8 @@ typedef struct myss { lws_sorted_usec_list_t sul; } myss_t; +#if !defined(LWS_SS_USE_SSPC) + static const char *canned_root_token_payload = "grant_type=refresh_token" "&refresh_token=Atzr|IwEBIJedGXjDqsU_vMxykqOMg" @@ -220,6 +222,8 @@ static const char *canned_root_token_payload = "&client_id=" "amzn1.application-oa2-client.4823334c434b4190a2b5a42c07938a2d"; +#endif + /* secure streams payload interface */ static int @@ -285,9 +289,12 @@ app_system_state_nf(lws_state_manager_t *mgr, lws_state_notify_link_t *link, int current, int target) { struct lws_context *context = lws_system_context_from_system_mgr(mgr); +#if !defined(LWS_SS_USE_SSPC) + lws_system_blob_t *ab = lws_system_get_blob(context, LWS_SYSBLOB_TYPE_AUTH, 1 /* AUTH_IDX_ROOT */); size_t size; +#endif /* * For the things we care about, let's notice if we are trying to get @@ -296,6 +303,13 @@ app_system_state_nf(lws_state_manager_t *mgr, lws_state_notify_link_t *link, */ switch (target) { +#if !defined(LWS_SS_USE_SSPC) + + /* + * The proxy takes responsibility for this stuff if we get things + * done through that + */ + case LWS_SYSTATE_INITIALIZED: /* overlay on the hardcoded policy */ case LWS_SYSTATE_POLICY_VALID: /* overlay on the loaded policy */ @@ -338,6 +352,8 @@ app_system_state_nf(lws_state_manager_t *mgr, lws_state_notify_link_t *link, strlen(canned_root_token_payload)); break; +#endif + case LWS_SYSTATE_OPERATIONAL: if (current == LWS_SYSTATE_OPERATIONAL) { lws_ss_info_t ssi; @@ -444,6 +460,11 @@ int main(int argc, const char **argv) return 1; } +#if !defined(LWS_SS_USE_SSPC) + /* + * If we're being a proxied client, the proxy does all this + */ + /* * Set the related lws_system blobs * @@ -472,6 +493,7 @@ int main(int argc, const char **argv) lws_system_blob_heap_append(lws_system_get_blob(context, LWS_SYSBLOB_TYPE_DEVICE_TYPE, 0), (const uint8_t *)"spacerocket", 11); +#endif /* the event loop */