From 3869006dd6b926c28e4781fcbae775bc6926fda2 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 14 Nov 2024 16:49:55 +0200 Subject: [PATCH 01/36] feat(message-type): add custom message type support Add custom message type support for the following APIs: publish, signal, share file, subscribe and history. --- core/pbcc_fetch_history.c | 4 +- core/pbcc_fetch_history.h | 1 + core/pbcc_subscribe_v2.c | 7 +++- core/pbcc_subscribe_v2.h | 2 +- core/pubnub_ccore_pubsub.c | 12 +++++- core/pubnub_ccore_pubsub.h | 6 ++- core/pubnub_coreapi_ex.c | 48 +++++++++++++++++++--- core/pubnub_coreapi_ex.h | 41 +++++++++++++++++- core/pubnub_fetch_history.c | 2 + core/pubnub_fetch_history.h | 4 ++ core/pubnub_pubsubapi.c | 4 +- core/pubnub_subscribe_v2_message.h | 2 + core/samples/pubnub_fetch_history_sample.c | 14 ++++++- 13 files changed, 129 insertions(+), 18 deletions(-) diff --git a/core/pbcc_fetch_history.c b/core/pbcc_fetch_history.c index 24b45a65..20d417d6 100644 --- a/core/pbcc_fetch_history.c +++ b/core/pbcc_fetch_history.c @@ -21,6 +21,7 @@ enum pubnub_res pbcc_fetch_history_prep(struct pbcc_context* pb, const char* channel, unsigned int max_per_channel, enum pubnub_tribool include_meta, + enum pubnub_tribool include_custom_message_type, enum pubnub_tribool include_message_type, enum pubnub_tribool include_user_id, enum pubnub_tribool include_message_actions, @@ -59,7 +60,8 @@ enum pubnub_res pbcc_fetch_history_prep(struct pbcc_context* pb, if (max_per_channel) { ADD_URL_PARAM(qparam, max, max_per_ch_cnt_buf); } if (include_meta != pbccNotSet) { ADD_URL_PARAM(qparam, include_meta, include_meta == pbccTrue ? "true" : "false"); } - if (include_message_type != pbccNotSet) { ADD_URL_PARAM(qparam, include_message_type, include_meta == pbccTrue ? "true" : "false"); } + if (include_custom_message_type != pbccNotSet) { ADD_URL_PARAM(qparam, include_custom_message_type, include_custom_message_type == pbccTrue ? "true" : "false"); } + if (include_message_type != pbccNotSet) { ADD_URL_PARAM(qparam, include_message_type, include_message_type == pbccTrue ? "true" : "false"); } if (include_user_id != pbccNotSet) { ADD_URL_PARAM(qparam, include_uuid, include_user_id == pbccTrue ? "true" : "false"); } #if PUBNUB_CRYPTO_API if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); } diff --git a/core/pbcc_fetch_history.h b/core/pbcc_fetch_history.h index c16739e4..d2072e77 100644 --- a/core/pbcc_fetch_history.h +++ b/core/pbcc_fetch_history.h @@ -10,6 +10,7 @@ enum pubnub_res pbcc_fetch_history_prep(struct pbcc_context* pb, const char* channel, unsigned int max_per_channel, enum pubnub_tribool include_meta, + enum pubnub_tribool include_custom_message_type, enum pubnub_tribool include_message_type, enum pubnub_tribool include_user_id, enum pubnub_tribool include_message_actions, diff --git a/core/pbcc_subscribe_v2.c b/core/pbcc_subscribe_v2.c index e1c50650..119bb749 100644 --- a/core/pbcc_subscribe_v2.c +++ b/core/pbcc_subscribe_v2.c @@ -27,7 +27,7 @@ enum pubnub_res pbcc_subscribe_v2_prep(struct pbcc_context* p, char const* channel, char const* channel_group, - unsigned* heartbeat, + const unsigned* heartbeat, char const* filter_expr) { char region_str[20]; @@ -303,6 +303,11 @@ struct pubnub_v2_message pbcc_get_msg_v2(struct pbcc_context* p) rslt.message_type = pbsbPublished; } + if (jonmpOK == pbjson_get_object_value(&el, "cmt", &found)) { + rslt.custom_message_type.ptr = (char*)found.start + 1; + rslt.custom_message_type.size = found.end - found.start - 2; + } + jpresult = pbjson_get_object_value(&el, "p", &found); if (jonmpOK == jpresult) { struct pbjson_elem titel; diff --git a/core/pbcc_subscribe_v2.h b/core/pbcc_subscribe_v2.h index 642f969a..cce9c340 100644 --- a/core/pbcc_subscribe_v2.h +++ b/core/pbcc_subscribe_v2.h @@ -15,7 +15,7 @@ struct pbcc_context; enum pubnub_res pbcc_subscribe_v2_prep(struct pbcc_context* p, char const* channel, char const* channel_group, - unsigned* heartbeat, + const unsigned* heartbeat, char const* filter_expr); diff --git a/core/pubnub_ccore_pubsub.c b/core/pubnub_ccore_pubsub.c index 6822467e..62d6026b 100644 --- a/core/pubnub_ccore_pubsub.c +++ b/core/pubnub_ccore_pubsub.c @@ -525,6 +525,7 @@ enum pubnub_res pbcc_append_url_param_encoded(struct pbcc_context* pb, enum pubnub_res pbcc_publish_prep(struct pbcc_context* pb, const char* channel, const char* message, + const char* custom_message_type, bool store_in_history, bool norep, char const* meta, @@ -606,6 +607,9 @@ enum pubnub_res pbcc_publish_prep(struct pbcc_context* pb, if (!store_in_history) { ADD_URL_PARAM(qparam, store, "0"); } if (norep) { ADD_URL_PARAM(qparam, norep, "true"); } if (meta) { ADD_URL_PARAM(qparam, meta, meta); } + if (custom_message_type) { + ADD_URL_PARAM(qparam, custom_message_type, custom_message_type); + } #if PUBNUB_CRYPTO_API SORT_URL_PARAMETERS(qparam); @@ -667,7 +671,8 @@ enum pubnub_res pbcc_sign_url(struct pbcc_context* pc, const char* msg, enum pub enum pubnub_res pbcc_signal_prep(struct pbcc_context* pb, const char* channel, - const char* message) + const char* message, + const char* custom_message_type) { enum pubnub_res rslt = PNR_OK; char const* const uname = pubnub_uname(); @@ -689,6 +694,9 @@ enum pubnub_res pbcc_signal_prep(struct pbcc_context* pb, URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS); if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); } if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); } + if (custom_message_type) { + ADD_URL_PARAM(qparam, custom_message_type, custom_message_type); + } #if PUBNUB_CRYPTO_API if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); } ADD_TS_TO_URL_PARAM(); @@ -716,7 +724,7 @@ enum pubnub_res pbcc_signal_prep(struct pbcc_context* pb, enum pubnub_res pbcc_subscribe_prep(struct pbcc_context* p, char const* channel, char const* channel_group, - unsigned* heartbeat) + const unsigned* heartbeat) { char const* user_id = pbcc_user_id_get(p); char const* const uname = pubnub_uname(); diff --git a/core/pubnub_ccore_pubsub.h b/core/pubnub_ccore_pubsub.h index 1e03e6a8..737cbfed 100644 --- a/core/pubnub_ccore_pubsub.h +++ b/core/pubnub_ccore_pubsub.h @@ -477,6 +477,7 @@ void pbcc_via_post_headers(struct pbcc_context* p, char* header, size_t max_leng enum pubnub_res pbcc_publish_prep(struct pbcc_context* pb, const char* channel, const char* message, + const char* custom_message_type, bool store_in_history, bool norep, char const* meta, @@ -488,7 +489,8 @@ enum pubnub_res pbcc_publish_prep(struct pbcc_context* pb, */ enum pubnub_res pbcc_signal_prep(struct pbcc_context* pb, const char* channel, - const char* message); + const char* message, + const char* custom_message_type); /** Prepares the Subscribe operation (transaction), mostly by formatting the URI of the HTTP request. @@ -496,7 +498,7 @@ enum pubnub_res pbcc_signal_prep(struct pbcc_context* pb, enum pubnub_res pbcc_subscribe_prep(struct pbcc_context* p, char const* channel, char const* channel_group, - unsigned* heartbeat); + const unsigned* heartbeat); /** Split @p buf string containing a JSON array (with arbitrary diff --git a/core/pubnub_coreapi_ex.c b/core/pubnub_coreapi_ex.c index 119a28c7..513f8284 100644 --- a/core/pubnub_coreapi_ex.c +++ b/core/pubnub_coreapi_ex.c @@ -27,12 +27,13 @@ struct pubnub_publish_options pubnub_publish_defopts(void) { struct pubnub_publish_options result; - result.store = true; - result.cipher_key = NULL; - result.replicate = true; - result.meta = NULL; - result.method = pubnubSendViaGET; - result.ttl = SIZE_MAX; + result.store = true; + result.cipher_key = NULL; + result.replicate = true; + result.meta = NULL; + result.method = pubnubSendViaGET; + result.ttl = SIZE_MAX; + result.custom_message_type = NULL; return result; } @@ -85,6 +86,7 @@ enum pubnub_res pubnub_publish_ex(pubnub_t* pb, rslt = pbcc_publish_prep(&pb->core, channel, message, + opts.custom_message_type, opts.store, !opts.replicate, opts.meta, @@ -102,6 +104,40 @@ enum pubnub_res pubnub_publish_ex(pubnub_t* pb, return rslt; } +struct pubnub_signal_options pubnub_signal_defopts(void) +{ + struct pubnub_signal_options result; + result.custom_message_type = NULL; + return result; +} + +enum pubnub_res pubnub_signal_ex( + pubnub_t* pb, + const char* channel, + const char* message, + struct pubnub_signal_options opts) +{ + enum pubnub_res rslt; + + PUBNUB_ASSERT(pb_valid_ctx_ptr(pb)); + + pubnub_mutex_lock(pb->monitor); + if (!pbnc_can_start_transaction(pb)) { + pubnub_mutex_unlock(pb->monitor); + return PNR_IN_PROGRESS; + } + + rslt = pbcc_signal_prep(&pb->core, channel, message, opts.custom_message_type); + if (PNR_STARTED == rslt) { + pb->trans = PBTT_SIGNAL; + pb->core.last_result = PNR_STARTED; + pbnc_fsm(pb); + rslt = pb->core.last_result; + } + pubnub_mutex_unlock(pb->monitor); + + return rslt; +} struct pubnub_subscribe_options pubnub_subscribe_defopts(void) { diff --git a/core/pubnub_coreapi_ex.h b/core/pubnub_coreapi_ex.h index 79a88b30..2b0a8b95 100644 --- a/core/pubnub_coreapi_ex.h +++ b/core/pubnub_coreapi_ex.h @@ -65,6 +65,11 @@ struct pubnub_publish_options { API. */ size_t ttl; + /** User-specified message type. + Important: String limited by **3**-**50** case-sensitive alphanumeric + characters with only `-` and `_` special characters allowed. + */ + char const* custom_message_type; }; /** This returns the default options for publish V1 transactions. @@ -85,7 +90,7 @@ PUBNUB_EXTERN struct pubnub_publish_options pubnub_publish_defopts(void); @param p The Pubnub context. Can't be NULL. @param channel The string with the channel name to publish to. Can't be NULL. - @param opt Publish V1 options + @param opts Publish V1 options @return #PNR_STARTED on success, an error otherwise */ PUBNUB_EXTERN enum pubnub_res pubnub_publish_ex(pubnub_t* p, @@ -94,6 +99,40 @@ PUBNUB_EXTERN enum pubnub_res pubnub_publish_ex(pubnub_t* p, struct pubnub_publish_options opts); +/** Options for "extended" signal V1. */ +struct pubnub_signal_options { + /** User-specified message type. + Important: String limited by **3**-**50** case-sensitive alphanumeric + characters with only `-` and `_` special characters allowed. + */ + char const* custom_message_type; +}; + +/** This returns the default options for signal V1 transactions. */ +PUBNUB_EXTERN struct pubnub_signal_options pubnub_signal_defopts(void); + +/** The extended signal V1. Basically the same as pubnub_signal(), + but with added optional parameters in @p opts. + + Basic usage: + + struct pubnub_signal_options opt = pubnub_signal_defopts(); + opt.custom_message_type = "test-message-type"; + pbresult = pubnub_signal_ex(pn, "my_channel", "status:active", opt); + + @param pb The pubnub context. Can't be NULL + @param channel The string with the channel to signal to. + @param message The signal message to send, expected to be in JSON format + @param opts Signal V1 options + @return #PNR_STARTED on success, an error otherwise +*/ +PUBNUB_EXTERN enum pubnub_res pubnub_signal_ex( + pubnub_t* pb, + const char* channel, + const char* message, + struct pubnub_signal_options opts); + + /** Options for "extended" subscribe. */ struct pubnub_subscribe_options { /** Channel group (a comma-delimited list of channel group names). diff --git a/core/pubnub_fetch_history.c b/core/pubnub_fetch_history.c index c4626190..85e729fa 100644 --- a/core/pubnub_fetch_history.c +++ b/core/pubnub_fetch_history.c @@ -23,6 +23,7 @@ struct pubnub_fetch_history_options pubnub_fetch_history_defopts(void) rslt.include_message_type = false; rslt.include_user_id = false; rslt.include_message_actions = false; + rslt.include_custom_message_type = false; return rslt; } @@ -45,6 +46,7 @@ enum pubnub_res pubnub_fetch_history(pubnub_t* pb, channel, opt.max_per_channel, opt.include_meta ? pbccTrue : pbccFalse, + opt.include_custom_message_type ? pbccTrue : pbccFalse, opt.include_message_type ? pbccTrue : pbccFalse, opt.include_user_id ? pbccTrue : pbccFalse, opt.include_message_actions ? pbccTrue : pbccFalse, diff --git a/core/pubnub_fetch_history.h b/core/pubnub_fetch_history.h index 45e92c42..2379a3d2 100644 --- a/core/pubnub_fetch_history.h +++ b/core/pubnub_fetch_history.h @@ -55,6 +55,10 @@ struct pubnub_fetch_history_options { * false. */ bool include_message_actions; + /** Include messages' custom type flag. + Message / signal and file messages may contain user-provided type. + */ + bool include_custom_message_type; }; /** This returns the default options for fetch history transactions. diff --git a/core/pubnub_pubsubapi.c b/core/pubnub_pubsubapi.c index ac9b027d..624dc0ef 100644 --- a/core/pubnub_pubsubapi.c +++ b/core/pubnub_pubsubapi.c @@ -110,7 +110,7 @@ enum pubnub_res pubnub_publish(pubnub_t* pb, const char* channel, const char* me } rslt = pbcc_publish_prep( - &pb->core, channel, message, true, false, NULL, SIZE_MAX, pubnubSendViaGET); + &pb->core, channel, message, NULL, true, false, NULL, SIZE_MAX, pubnubSendViaGET); if (PNR_STARTED == rslt) { pb->trans = PBTT_PUBLISH; pb->core.last_result = PNR_STARTED; @@ -137,7 +137,7 @@ enum pubnub_res pubnub_signal(pubnub_t* pb, return PNR_IN_PROGRESS; } - rslt = pbcc_signal_prep(&pb->core, channel, message); + rslt = pbcc_signal_prep(&pb->core, channel, message, NULL); if (PNR_STARTED == rslt) { pb->trans = PBTT_SIGNAL; pb->core.last_result = PNR_STARTED; diff --git a/core/pubnub_subscribe_v2_message.h b/core/pubnub_subscribe_v2_message.h index bd02cbfb..4c712418 100644 --- a/core/pubnub_subscribe_v2_message.h +++ b/core/pubnub_subscribe_v2_message.h @@ -54,6 +54,8 @@ struct pubnub_v2_message { enum pubnub_message_type message_type; /** The message information about publisher */ struct pubnub_char_mem_block publisher; + /** User-provided message type. */ + struct pubnub_char_mem_block custom_message_type; }; diff --git a/core/samples/pubnub_fetch_history_sample.c b/core/samples/pubnub_fetch_history_sample.c index 03e19fd3..8cfb62b4 100644 --- a/core/samples/pubnub_fetch_history_sample.c +++ b/core/samples/pubnub_fetch_history_sample.c @@ -4,6 +4,7 @@ #if PUBNUB_USE_FETCH_HISTORY #include "core/pubnub_fetch_history.c" #endif +#include "core/pubnub_coreapi_ex.h" #include "core/pubnub_helper.h" #include "core/pubnub_timers.h" @@ -58,9 +59,13 @@ static void publish_on_channels(pubnub_t* pbp) enum pubnub_res res; char msg[100]; sprintf(msg,"\"Hello world from fetch history sample %d !\"", i); - res = pubnub_publish(pbp, + struct pubnub_publish_options opts = pubnub_publish_defopts(); + opts.custom_message_type = "test-message-type"; + + res = pubnub_publish_ex(pbp, m_channel1, - msg); + msg, + opts); if (res == PNR_STARTED) { puts("Await publish"); res = pubnub_await(pbp); @@ -139,6 +144,7 @@ int main(int argc, char* argv[]) m_channel2); struct pubnub_fetch_history_options opt = pubnub_fetch_history_defopts(); + opt.include_custom_message_type = true; opt.include_message_type = true; opt.include_meta = true; res = pubnub_fetch_history(pbp, string_channels, opt); @@ -162,6 +168,10 @@ int main(int argc, char* argv[]) printf("\"meta\" is missing in response."); return 1; } + if (NULL == strstr(response.ptr, "\"custom_message_type\"")) { + printf("\"custom_message_type\" is missing in response."); + return 1; + } } else{ printf("pubnub_fetch_history() failed with code: %d('%s')\n", From e58459c1156515c76c46a108d7363ceb00b71ef8 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 01:00:55 +0200 Subject: [PATCH 02/36] feat(ipv6): add the ability to enforce IPv6 usage Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` functions to make it possible to enforce specific protocol usage. test(message-type): add subscription test for custom message type Modify subscription integration with additional information about custom message type to check parsing. --- .../run-unit-tests.sh | 1 + .../composite/unit-test-framework/action.yaml | 4 ++-- .github/workflows/run-tests.yml | 4 ++-- core/pubnub_ccore_pubsub.c | 2 +- core/pubnub_coreapi_ex.c | 2 +- core/pubnub_coreapi_ex.h | 6 ++++-- core/pubnub_dns_servers.c | 15 ++++++++++++++- core/pubnub_dns_servers.h | 8 ++++++++ core/pubnub_pubsubapi.c | 6 ++---- core/pubnub_subscribe_v2_unit_test.c | 7 ++++--- 10 files changed, 39 insertions(+), 16 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 0da15bf5..80927afe 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" diff --git a/.github/workflows/composite/unit-test-framework/action.yaml b/.github/workflows/composite/unit-test-framework/action.yaml index e0114ddc..70b3fd18 100644 --- a/.github/workflows/composite/unit-test-framework/action.yaml +++ b/.github/workflows/composite/unit-test-framework/action.yaml @@ -18,7 +18,7 @@ runs: steps: - name: Build and Cache Unit Test framework ('${{ inputs.os }}' ${{ inputs.compilers }}) id: unit-test-framework - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | cgreen @@ -27,7 +27,7 @@ runs: ${{ inputs.os }}-cgreen-${{ inputs.version }}- - name: Checkout Unit Test framework if: steps.unit-test-framework.outputs.cache-hit != 'true' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: cgreen-devs/cgreen ref: ${{ matrix.cgreen }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 66fe81d8..0c70fab6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -25,11 +25,11 @@ jobs: # group: organization/macos-gh steps: - name: Checkout project - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.GH_TOKEN }} - name: Checkout actions - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: pubnub/client-engineering-deployment-tools ref: v1 diff --git a/core/pubnub_ccore_pubsub.c b/core/pubnub_ccore_pubsub.c index 62d6026b..405695c7 100644 --- a/core/pubnub_ccore_pubsub.c +++ b/core/pubnub_ccore_pubsub.c @@ -597,7 +597,7 @@ enum pubnub_res pbcc_publish_prep(struct pbcc_context* pb, URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS); if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); } ADD_URL_PARAM(qparam, uuid, user_id); - if (ttl != SIZE_MAX) { ADD_URL_PARAM_SIZET(qparam, ttl, ttl); } + if (ttl != 0) { ADD_URL_PARAM_SIZET(qparam, ttl, ttl); } #if PUBNUB_CRYPTO_API if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); } ADD_TS_TO_URL_PARAM(); diff --git a/core/pubnub_coreapi_ex.c b/core/pubnub_coreapi_ex.c index 513f8284..30fdfa66 100644 --- a/core/pubnub_coreapi_ex.c +++ b/core/pubnub_coreapi_ex.c @@ -32,7 +32,7 @@ struct pubnub_publish_options pubnub_publish_defopts(void) result.replicate = true; result.meta = NULL; result.method = pubnubSendViaGET; - result.ttl = SIZE_MAX; + result.ttl = 0; result.custom_message_type = NULL; return result; } diff --git a/core/pubnub_coreapi_ex.h b/core/pubnub_coreapi_ex.h index 2b0a8b95..f48eec6a 100644 --- a/core/pubnub_coreapi_ex.h +++ b/core/pubnub_coreapi_ex.h @@ -74,7 +74,8 @@ struct pubnub_publish_options { /** This returns the default options for publish V1 transactions. Will set `store = true`, `cipher_key = NULL`, `replicate = true`, - `meta = NULL` and `method = pubnubPublishViaGet` + `meta = NULL`, `method = pubnubPublishViaGet`, `ttl=0`, and + `custom_message_type=NULL`. */ PUBNUB_EXTERN struct pubnub_publish_options pubnub_publish_defopts(void); @@ -108,7 +109,8 @@ struct pubnub_signal_options { char const* custom_message_type; }; -/** This returns the default options for signal V1 transactions. */ +/** This returns the default options for signal V1 transactions. + Will set `custom_message_type=NULL`. */ PUBNUB_EXTERN struct pubnub_signal_options pubnub_signal_defopts(void); /** The extended signal V1. Basically the same as pubnub_signal(), diff --git a/core/pubnub_dns_servers.c b/core/pubnub_dns_servers.c index 5a8eb32c..b02d07da 100644 --- a/core/pubnub_dns_servers.c +++ b/core/pubnub_dns_servers.c @@ -33,7 +33,6 @@ void pubnub_dns_servers_deinit(void) pubnub_mutex_destroy(m_lock); } - int pubnub_dns_set_primary_server_ipv4(struct pubnub_ipv4_address ipv4_address) { uint8_t* ipv4 = ipv4_address.ipv4; @@ -166,6 +165,20 @@ int pubnub_get_dns_secondary_server_ipv4(struct pubnub_ipv4_address* o_ipv4) } #if PUBNUB_USE_IPV6 +void pubnub_set_ipv4_connectivity(pubnub_t *p) +{ + pubnub_mutex_lock(p->monitor); + p->options.ipv6_connectivity = false; + pubnub_mutex_unlock(p->monitor); +} + +void pubnub_set_ipv6_connectivity(pubnub_t *p) +{ + pubnub_mutex_lock(p->monitor); + p->options.ipv6_connectivity = true; + pubnub_mutex_unlock(p->monitor); +} + int pubnub_dns_set_primary_server_ipv6(struct pubnub_ipv6_address ipv6_address) { uint8_t* ipv6 = ipv6_address.ipv6; diff --git a/core/pubnub_dns_servers.h b/core/pubnub_dns_servers.h index 4a742990..e4b170a3 100644 --- a/core/pubnub_dns_servers.h +++ b/core/pubnub_dns_servers.h @@ -19,6 +19,14 @@ struct pubnub_ipv6_address { uint8_t ipv6[16]; }; +/** IPv4 connectivity type for @p. + Use IPv4 addresses to establish connection with remote origin. */ +void pubnub_set_ipv4_connectivity(pubnub_t *p); + +/** IPv6 connectivity type for @p. + Use IPv6 addresses to establish connection with remote origin. */ +void pubnub_set_ipv6_connectivity(pubnub_t *p); + /* primary, secondary(ipv4, ipv6) and default dns server */ #define PUBNUB_MAX_DNS_SERVERS_MASK 0x10 #else diff --git a/core/pubnub_pubsubapi.c b/core/pubnub_pubsubapi.c index 624dc0ef..a8ffdd25 100644 --- a/core/pubnub_pubsubapi.c +++ b/core/pubnub_pubsubapi.c @@ -53,10 +53,8 @@ pubnub_t* pubnub_init(pubnub_t* p, const char* publish_key, const char* subscrib p->trans = PBTT_NONE; p->options.use_http_keep_alive = true; #if PUBNUB_USE_IPV6 && defined(PUBNUB_CALLBACK_API) - /* Connectivity type(true-Ipv6/false-Ipv4) chosen on given contex. - Ipv4 by default. - */ - p->options.ipv6_connectivity = false; + /* IPv4 connectivity type by default. */ + pubnub_set_ipv4_connectivity(p); #endif p->flags.started_while_kept_alive = false; p->method = pubnubSendViaGET; diff --git a/core/pubnub_subscribe_v2_unit_test.c b/core/pubnub_subscribe_v2_unit_test.c index eb89c06e..fad553bb 100644 --- a/core/pubnub_subscribe_v2_unit_test.c +++ b/core/pubnub_subscribe_v2_unit_test.c @@ -53,7 +53,7 @@ Ensure(subscribe_v2, should_parse_response_correctly) { assert_that(pubnub_auth_get(pbp), is_equal_to_string(NULL)); expect_have_dns_for_pubnub_origin_on_ctx(pbp); expect_outgoing_with_url_on_ctx(pbp, - "/v2/subscribe/sub_key/my-channel/0?pnsdk=unit-test-0.1&tt=0&tr=0&uuid=test_id&heartbeat=270"); + "/v2/subscribe/sub_key/my-channel/0?pnsdk=unit-test-0.1&tt=0&uuid=test_id&heartbeat=300"); incoming("HTTP/1.1 200\r\nContent-Length: " "44\r\n\r\n{\"t\":{\"t\":\"15628652479932717\",\"r\":4},\"m\":[]}", NULL); @@ -71,9 +71,9 @@ Ensure(subscribe_v2, should_parse_response_correctly) { expect(pbntf_got_socket, when(pb, is_equal_to(pbp)), will_return(0)); expect_outgoing_with_url_on_ctx(pbp, - "/v2/subscribe/sub_key/my-channel/0?pnsdk=unit-test-0.1&tt=15628652479932717&tr=4&uuid=test_id&heartbeat=270"); + "/v2/subscribe/sub_key/my-channel/0?pnsdk=unit-test-0.1&tt=15628652479932717&tr=4&uuid=test_id&heartbeat=300"); incoming("HTTP/1.1 220\r\nContent-Length: " - "183\r\n\r\n{\"t\":{\"t\":\"15628652479932717\",\"r\":4},\"m\":[{\"a\":\"1\",\"f\":514,\"i\":\"publisher_id\",\"s\":1,\"p\":{\"t\":\"15628652479933927\",\"r\":4},\"k\":\"demo\",\"c\":\"my-channel\",\"d\":\"mymessage\",\"b\":\"my-channel\"}]}", + "209\r\n\r\n{\"t\":{\"t\":\"15628652479932717\",\"r\":4},\"m\":[{\"a\":\"1\",\"f\":514,\"cmt\":\"test-message-type\",\"i\":\"publisher_id\",\"s\":1,\"p\":{\"t\":\"15628652479933927\",\"r\":4},\"k\":\"demo\",\"c\":\"my-channel\",\"d\":\"mymessage\",\"b\":\"my-channel\"}]}", NULL); expect(pbntf_lost_socket, when(pb, is_equal_to(pbp))); @@ -88,6 +88,7 @@ Ensure(subscribe_v2, should_parse_response_correctly) { assert_char_mem_block(msg.channel, "my-channel"); assert_char_mem_block(msg.payload, "\"mymessage\""); assert_char_mem_block(msg.publisher, "publisher_id"); + assert_char_mem_block(msg.custom_message_type, "test-message-type"); assert_that(msg.region, is_equal_to(4)); assert_that(msg.flags, is_equal_to(514)); From 386b05f6f50dfaa48ae88dd73c784444995c1a50 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 10:20:55 +0200 Subject: [PATCH 03/36] test(ssl): fix paths to the ssl in Makefile --- core/Makefile | 17 ++++++++++++++++- core/pubnub_ccore_pubsub.c | 2 +- core/pubnub_dns_servers.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/Makefile b/core/Makefile index 79de3513..6736fe6b 100644 --- a/core/Makefile +++ b/core/Makefile @@ -66,7 +66,7 @@ pubnub_timer_list_unittest: pubnub_timer_list.c pubnub_timer_list_unit_test.c #$(GCOVR) -r . --html --html-details -o coverage.html -PROXY_PROJECT_SOURCEFILES = pubnub_proxy_core.c pubnub_proxy.c pbhttp_digest.c pbntlm_core.c pbntlm_packer_std.c pubnub_generate_uuid_v4_random_std.c ../lib/pubnub_parse_ipv4_addr.c ../lib/pubnub_parse_ipv6_addr.c ../lib/md5/md5.c +PROXY_PROJECT_SOURCEFILES = pubnub_proxy_core.c pubnub_proxy.c pbhttp_digest.c pbntlm_core.c pbntlm_packer_std.c pubnub_generate_uuid_v4_random_std.c pubnub_dns_servers.c ../lib/pubnub_parse_ipv4_addr.c ../lib/pubnub_parse_ipv6_addr.c ../lib/md5/md5.c pubnub_proxy_unittest: $(PROJECT_SOURCEFILES) $(PROXY_PROJECT_SOURCEFILES) pubnub_proxy_unit_test.c gcc -o pubnub_proxy_unit_test.so -shared $(CFLAGS) $(LDFLAGS) -D PUBNUB_CALLBACK_API -D PUBNUB_PROXY_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(PROXY_PROJECT_SOURCEFILES) pubnub_proxy_unit_test.c -lcgreen -lm @@ -87,6 +87,21 @@ CRYPTO_INCLUDES += -I ../openssl/. CRYPTO_LIBS += -lssl -lcrypto CRYPTO_SOURCEFILES += pubnub_crypto.c pbcc_crypto.c pbcc_crypto_aes_cbc.c pbcc_crypto_legacy.c ../openssl/pbaes256.c +ifeq ($(shell uname),Darwin) + CRYPTO_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) + CRYPTO_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + + ifeq ($(CRYPTO_CFLAGS),) + CRYPTO_CFLAGS := -I/usr/local/opt/openssl/include + endif + ifeq ($(CRYPTO_LIBS),) + CRYPTO_LIBS := -L/usr/local/opt/openssl/lib -lssl -lcrypto + endif + + CRYPTO_INCLUDES += $(CRYPTO_CFLAGS) + CRYPTO_LIBS += $(CRYPTO_LIBS) +endif + pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c gcc -o pbcc_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm diff --git a/core/pubnub_ccore_pubsub.c b/core/pubnub_ccore_pubsub.c index 405695c7..db886ce9 100644 --- a/core/pubnub_ccore_pubsub.c +++ b/core/pubnub_ccore_pubsub.c @@ -597,7 +597,7 @@ enum pubnub_res pbcc_publish_prep(struct pbcc_context* pb, URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS); if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); } ADD_URL_PARAM(qparam, uuid, user_id); - if (ttl != 0) { ADD_URL_PARAM_SIZET(qparam, ttl, ttl); } + if (ttl != 0 && ttl != SIZE_MAX) { ADD_URL_PARAM_SIZET(qparam, ttl, ttl); } #if PUBNUB_CRYPTO_API if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); } ADD_TS_TO_URL_PARAM(); diff --git a/core/pubnub_dns_servers.h b/core/pubnub_dns_servers.h index e4b170a3..73c3b986 100644 --- a/core/pubnub_dns_servers.h +++ b/core/pubnub_dns_servers.h @@ -2,6 +2,7 @@ #if !defined INC_PUBNUB_DNS_SERVERS #define INC_PUBNUB_DNS_SERVERS +#include "core/pubnub_api_types.h" #include /** IPv4 Address, in binary format. From b7c2b3ab8de1a1e3f4718f032229b34e2315eb01 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 11:24:09 +0200 Subject: [PATCH 04/36] tes(openssl): update paths in other makefiles --- .../run-integration-tests.sh | 1 + core/Makefile | 25 +++++++++---------- cpp/posix_openssl.mk | 17 +++++++++++-- openssl/posix.mk | 17 +++++++++++-- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-integration-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-integration-tests.sh index a89779a3..b0f8fac8 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-integration-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-integration-tests.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e INFO_BG="\033[0m\033[48;2;5;49;70m" INFO_FG="\033[38;2;19;181;255m" diff --git a/core/Makefile b/core/Makefile index 6736fe6b..dd0e4858 100644 --- a/core/Makefile +++ b/core/Makefile @@ -87,21 +87,20 @@ CRYPTO_INCLUDES += -I ../openssl/. CRYPTO_LIBS += -lssl -lcrypto CRYPTO_SOURCEFILES += pubnub_crypto.c pbcc_crypto.c pbcc_crypto_aes_cbc.c pbcc_crypto_legacy.c ../openssl/pbaes256.c -ifeq ($(shell uname),Darwin) - CRYPTO_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) - CRYPTO_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) - - ifeq ($(CRYPTO_CFLAGS),) - CRYPTO_CFLAGS := -I/usr/local/opt/openssl/include - endif - ifeq ($(CRYPTO_LIBS),) - CRYPTO_LIBS := -L/usr/local/opt/openssl/lib -lssl -lcrypto - endif - - CRYPTO_INCLUDES += $(CRYPTO_CFLAGS) - CRYPTO_LIBS += $(CRYPTO_LIBS) +# Searching for proper OpenSSL paths. +CRYPTO_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) +CRYPTO_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + +ifeq ($(CRYPTO_CFLAGS),) + CRYPTO_CFLAGS := -I/usr/local/opt/openssl/include +endif +ifeq ($(CRYPTO_LIBS),) + CRYPTO_LIBS := -L/usr/local/opt/openssl/lib endif +CRYPTO_INCLUDES += $(CRYPTO_CFLAGS) +CRYPTO_LIBS += $(CRYPTO_LIBS) + pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c gcc -o pbcc_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm diff --git a/cpp/posix_openssl.mk b/cpp/posix_openssl.mk index 12bb230e..0e6e0827 100644 --- a/cpp/posix_openssl.mk +++ b/cpp/posix_openssl.mk @@ -120,14 +120,27 @@ OS := $(shell uname) ifeq ($(OS),Darwin) SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c OBJFILES += monotonic_clock_get_time_darwin.o -LDLIBS=-lpthread -lssl -lcrypto -L/usr/local/opt/openssl/lib -CFLAGS += -I/usr/local/opt/openssl/include +LDLIBS=-lpthread -lssl -lcrypto else SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c OBJFILES += monotonic_clock_get_time_posix.o LDLIBS=-lrt -lpthread -lssl -lcrypto endif +# Searching for proper OpenSSL paths. +OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) +OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + +ifeq ($(OPENSSL_CFLAGS),) + OPENSSL_CFLAGS := -I/usr/local/opt/openssl/include +endif +ifeq ($(OPENSSL_LIBS),) + OPENSSL_LIBS := -L/usr/local/opt/openssl/lib +endif + +CFLAGS += $(OPENSSL_CFLAGS) +LDLIBS += $(OPENSSL_LIBS) + all: openssl/pubnub_sync_sample openssl/pubnub_callback_sample openssl/pubnub_sync_grant_sample openssl/pubnub_callback_cpp11_sample openssl/cancel_subscribe_sync_sample openssl/subscribe_publish_callback_sample openssl/futres_nesting_sync openssl/fntest_runner openssl/futres_nesting_callback openssl/futres_nesting_callback_cpp11 diff --git a/openssl/posix.mk b/openssl/posix.mk index 445d083b..d20b7322 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -127,14 +127,27 @@ OS := $(shell uname) ifeq ($(OS),Darwin) SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c OBJFILES += monotonic_clock_get_time_darwin.o -LDLIBS = -lpthread -lssl -lcrypto -L/usr/local/opt/openssl/lib -CFLAGS += -I/usr/local/opt/openssl/include +LDLIBS = -lpthread -lssl -lcrypto else SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c OBJFILES += monotonic_clock_get_time_posix.o LDLIBS=-lrt -lpthread -lssl -lcrypto endif +# Searching for proper OpenSSL paths. +OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) +OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + +ifeq ($(OPENSSL_CFLAGS),) + OPENSSL_CFLAGS := -I/usr/local/opt/openssl/include +endif +ifeq ($(OPENSSL_LIBS),) + OPENSSL_LIBS := -L/usr/local/opt/openssl/lib +endif + +CFLAGS += $(OPENSSL_CFLAGS) +LDLIBS += $(OPENSSL_LIBS) + INCLUDES=-I .. -I . -I ../lib/base64/ From 71e9383bac013cf65c2b2832b9fbd1a5d98b434b Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 12:24:49 +0200 Subject: [PATCH 05/36] test(debug): runner SSL path --- core/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/Makefile b/core/Makefile index dd0e4858..652f1694 100644 --- a/core/Makefile +++ b/core/Makefile @@ -90,6 +90,8 @@ CRYPTO_SOURCEFILES += pubnub_crypto.c pbcc_crypto.c pbcc_crypto_aes_cbc.c pbcc_c # Searching for proper OpenSSL paths. CRYPTO_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) CRYPTO_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) +OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl) +OPENSSL_LIBS := $(shell pkg-config --libs openssl) ifeq ($(CRYPTO_CFLAGS),) CRYPTO_CFLAGS := -I/usr/local/opt/openssl/include @@ -102,6 +104,8 @@ CRYPTO_INCLUDES += $(CRYPTO_CFLAGS) CRYPTO_LIBS += $(CRYPTO_LIBS) pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c + @echo "Includes: '$(OPENSSL_CFLAGS)'" + @echo "Libraries: '$(OPENSSL_LIBS)'" gcc -o pbcc_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm $(CGREEN_RUNNER) ./pbcc_crypto_unit_test.so From b0d58f7ad9458779c12e1e20fb9ef4a37e79a5f2 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 12:29:29 +0200 Subject: [PATCH 06/36] test(debug): runner SSL path --- core/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/Makefile b/core/Makefile index 652f1694..a2efa5e8 100644 --- a/core/Makefile +++ b/core/Makefile @@ -114,6 +114,8 @@ pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_u SUBSCRIBE_V2_SOURCEFILES += pubnub_subscribe_v2.c pbcc_subscribe_v2.c pubnub_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) pubnub_crypto_unit_tests.c + @echo "Includes: '$(OPENSSL_CFLAGS)'" + @echo "Libraries: '$(OPENSSL_LIBS)'" gcc -o pubnub_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pubnub_crypto_unit_tests.c -lcgreen -lm $(CGREEN_RUNNER) ./pubnub_crypto_unit_test.so From c610714478cfcea3ffed7fc1b60ecef9b70599a9 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 12:46:20 +0200 Subject: [PATCH 07/36] test(debug): list runner env variables --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 80927afe..9e2681ce 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +printenv + echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" make clean generate_report From 30b866b0535939cc44f2cb881b3d4edb356b858b Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 16:22:21 +0200 Subject: [PATCH 08/36] test(debug): check whether openssl really installed --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 9e2681ce..84dfa7cb 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,7 +1,8 @@ #!/bin/bash set -e -printenv +ls /usr/include/openssl +ls /usr/lib/x86_64-linux-gnu/libssl.so echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" From e17a9eac3b4391d990163c8fd5a225ecdf7973dd Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 16:43:40 +0200 Subject: [PATCH 09/36] test(debug): package config debug --- .../run-unit-tests.sh | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 84dfa7cb..aa156990 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,8 +1,54 @@ #!/bin/bash set -e +# +#ls /usr/include/openssl +#ls /usr/lib/x86_64-linux-gnu/libssl.so + +ls /usr/lib/x86_64-linux-gnu/pkgconfig +echo "----" +openssl version +echo "----" +if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then + echo "'openssl' package config not found!" +else + echo "'openssl' package configuration exists" +fi +echo "----" +if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc ]; then + echo "'libssl' package config not found!" +else + echo "'libssl' package configuration exists" + + if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then + echo "'openssl' package config not found!" + sudo ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc + else + echo "'openssl' package configuration exists" + fi +fi + + +if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then + OPENSSL_VERSION=$(openssl version | awk '{print $2}') + echo "prefix=/usr +exec_prefix=\${prefix} +libdir=\${exec_prefix}/lib/x86_64-linux-gnu +includedir=\${prefix}/include + +Name: OpenSSL +Description: Secure Sockets Layer and cryptography libraries and tools +Version: $OPENSSL_VERSION +Requires: +Libs: -L\${libdir} -lssl -lcrypto +Cflags: -I\${includedir}" | sudo tee /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc > /dev/null +fi + + +export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH +echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" +echo "CFLAGS: '$(shell pkg-config --cflags openssl)'" +echo "LIBS: '$(shell pkg-config --libs openssl)'" -ls /usr/include/openssl -ls /usr/lib/x86_64-linux-gnu/libssl.so echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" From 17d4da1fcc255fc1d2c863966a130ee313094e44 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 21:36:30 +0200 Subject: [PATCH 10/36] test(debug): package config debug --- .../unit-integration-test-runner/run-unit-tests.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index aa156990..cf4c19eb 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -12,12 +12,16 @@ if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then echo "'openssl' package config not found!" else echo "'openssl' package configuration exists" + cat /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc + echo "----" fi echo "----" if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc ]; then echo "'libssl' package config not found!" else echo "'libssl' package configuration exists" + cat /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc + echo "----" if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then echo "'openssl' package config not found!" @@ -46,8 +50,8 @@ fi export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" -echo "CFLAGS: '$(shell pkg-config --cflags openssl)'" -echo "LIBS: '$(shell pkg-config --libs openssl)'" +echo "CFLAGS: '$(pkg-config --cflags openssl)'" +echo "LIBS: '$(pkg-config --libs openssl)'" echo "::group::Run unit tests ('$1' $CC / $CXX)" From 406dca6e7cb02d0b793082148ebe50e99328c0b4 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 21:53:33 +0200 Subject: [PATCH 11/36] test(debug): package config debug --- .../run-unit-tests.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index cf4c19eb..bee87527 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -4,10 +4,6 @@ set -e #ls /usr/include/openssl #ls /usr/lib/x86_64-linux-gnu/libssl.so -ls /usr/lib/x86_64-linux-gnu/pkgconfig -echo "----" -openssl version -echo "----" if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then echo "'openssl' package config not found!" else @@ -45,11 +41,23 @@ Version: $OPENSSL_VERSION Requires: Libs: -L\${libdir} -lssl -lcrypto Cflags: -I\${includedir}" | sudo tee /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc > /dev/null +else + OPENSSL_PC_FILE=/usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc; +# Fix Libs if required. +if ! grep -q "Libs:" "$OPENSSL_PC_FILE"; then + echo "Adding missing Libs field..." + echo "Libs: -L/usr/lib/x86_64-linux-gnu -lssl -lcrypto" | sudo tee -a "$OPENSSL_PC_FILE" +fi + +# Fix C flags if required. +if ! grep -q "Cflags:" "$OPENSSL_PC_FILE"; then + echo "Adding missing Cflags field..." + echo "Cflags: -I/usr/include" | sudo tee -a "$OPENSSL_PC_FILE" +fi fi export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH -echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" echo "CFLAGS: '$(pkg-config --cflags openssl)'" echo "LIBS: '$(pkg-config --libs openssl)'" From 1c4edfa469f8070b7d8023784c16dc55322a3b34 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 22:04:35 +0200 Subject: [PATCH 12/36] test(debug): package config debug --- .../run-unit-tests.sh | 100 ++++++++++-------- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index bee87527..efa8aaa6 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -4,63 +4,69 @@ set -e #ls /usr/include/openssl #ls /usr/lib/x86_64-linux-gnu/libssl.so -if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then - echo "'openssl' package config not found!" -else - echo "'openssl' package configuration exists" - cat /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc - echo "----" -fi -echo "----" -if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc ]; then - echo "'libssl' package config not found!" -else - echo "'libssl' package configuration exists" - cat /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc - echo "----" +echo "~~~> $1" +if [[ "$1" == "ubuntu" ]]; then if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then - echo "'openssl' package config not found!" - sudo ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc + echo "~~~> 'openssl' package config not found!" else - echo "'openssl' package configuration exists" + echo "~~~> 'openssl' package configuration exists" + cat /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc + echo "----" fi -fi - + echo "----" + if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc ]; then + echo "~~~> 'libssl' package config not found!" + else + echo "~~~> 'libssl' package configuration exists" + cat /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc + echo "----" -if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then - OPENSSL_VERSION=$(openssl version | awk '{print $2}') - echo "prefix=/usr -exec_prefix=\${prefix} -libdir=\${exec_prefix}/lib/x86_64-linux-gnu -includedir=\${prefix}/include + if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then + echo "~~~> 'openssl' package config not found!" + sudo ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc + else + echo "~~~> 'openssl' package configuration exists" + fi + fi -Name: OpenSSL -Description: Secure Sockets Layer and cryptography libraries and tools -Version: $OPENSSL_VERSION -Requires: -Libs: -L\${libdir} -lssl -lcrypto -Cflags: -I\${includedir}" | sudo tee /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc > /dev/null -else - OPENSSL_PC_FILE=/usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc; -# Fix Libs if required. -if ! grep -q "Libs:" "$OPENSSL_PC_FILE"; then - echo "Adding missing Libs field..." - echo "Libs: -L/usr/lib/x86_64-linux-gnu -lssl -lcrypto" | sudo tee -a "$OPENSSL_PC_FILE" -fi -# Fix C flags if required. -if ! grep -q "Cflags:" "$OPENSSL_PC_FILE"; then - echo "Adding missing Cflags field..." - echo "Cflags: -I/usr/include" | sudo tee -a "$OPENSSL_PC_FILE" -fi -fi + if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then + OPENSSL_VERSION=$(openssl version | awk '{print $2}') + echo "prefix=/usr + exec_prefix=\${prefix} + libdir=\${exec_prefix}/lib/x86_64-linux-gnu + includedir=\${prefix}/include + Name: OpenSSL + Description: Secure Sockets Layer and cryptography libraries and tools + Version: $OPENSSL_VERSION + Requires: + Libs: -L\${libdir} -lssl -lcrypto + Cflags: -I\${includedir}" | sudo tee /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc > /dev/null + else + OPENSSL_PC_FILE=/usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc + # Fix Libs if required. + if ! grep -q "Libs:" "$OPENSSL_PC_FILE"; then + echo "~~~> Adding missing Libs field..." + echo "Libs: -L/usr/lib/x86_64-linux-gnu -lssl -lcrypto" | sudo tee -a "$OPENSSL_PC_FILE" + fi -export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH -echo "CFLAGS: '$(pkg-config --cflags openssl)'" -echo "LIBS: '$(pkg-config --libs openssl)'" + # Fix C flags if required. + if ! grep -q "Cflags:" "$OPENSSL_PC_FILE"; then + echo "~~~> Adding missing Cflags field..." + echo "Cflags: -I/usr/include" | sudo tee -a "$OPENSSL_PC_FILE" + fi + echo "----" + echo "$OPENSSL_PC_FILE" + cat "$OPENSSL_PC_FILE" + echo "----" + fi + export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH + echo "CFLAGS: '$(pkg-config --cflags openssl)'" + echo "LIBS: '$(pkg-config --libs openssl)'" +fi echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" From 4c97cb9554e3c93997dff88a18cc1331c708d620 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 22:11:12 +0200 Subject: [PATCH 13/36] test(debug): package config debug --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index efa8aaa6..5f0ace01 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -64,8 +64,8 @@ if [[ "$1" == "ubuntu" ]]; then fi export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH - echo "CFLAGS: '$(pkg-config --cflags openssl)'" - echo "LIBS: '$(pkg-config --libs openssl)'" + echo "CFLAGS: '$(pkg-config --debug --cflags openssl)'" + echo "LIBS: '$(pkg-config --debug --libs openssl)'" fi echo "::group::Run unit tests ('$1' $CC / $CXX)" From cd04ac4d6c27575a1af9f5688cde92711715f662 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 22:24:10 +0200 Subject: [PATCH 14/36] test(debug): package config debug --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 5f0ace01..9cd3181e 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -64,8 +64,8 @@ if [[ "$1" == "ubuntu" ]]; then fi export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH - echo "CFLAGS: '$(pkg-config --debug --cflags openssl)'" - echo "LIBS: '$(pkg-config --debug --libs openssl)'" + echo "CFLAGS: '$(pkg-config --debug --static --cflags openssl)'" + echo "LIBS: '$(pkg-config --debug --static --libs openssl)'" fi echo "::group::Run unit tests ('$1' $CC / $CXX)" From 91cba6fcb9c721c6b88d0302677f8f6fda120903 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 22:44:24 +0200 Subject: [PATCH 15/36] test(debug): package config debug --- .../unit-integration-test-runner/run-unit-tests.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 9cd3181e..be374bd3 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -64,8 +64,16 @@ if [[ "$1" == "ubuntu" ]]; then fi export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH - echo "CFLAGS: '$(pkg-config --debug --static --cflags openssl)'" - echo "LIBS: '$(pkg-config --debug --static --libs openssl)'" + echo "----" + pkg-config list-package-names + echo "----" + pkg-config --exists openssl + echo "----" + echo "CFLAGS 1: '$(pkg-config --print-errors --no-cache --debug --path --cflags openssl)'" + echo "LIBS 1: '$(pkg-config --print-errors --no-cache --debug --path --libs openssl)'" + echo "----" + echo "CFLAGS 2: '$(pkg-config --print-errors --no-cache --debug --path --internal-cflags --cflags openssl)'" + echo "LIBS 2: '$(pkg-config --print-errors --no-cache --debug --path --libs openssl)'" fi echo "::group::Run unit tests ('$1' $CC / $CXX)" From 72c3aa1f96aea0308ed12912a73de141111f248f Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 22:47:00 +0200 Subject: [PATCH 16/36] test(debug): package config debug --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index be374bd3..0e7f23ce 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -65,9 +65,7 @@ if [[ "$1" == "ubuntu" ]]; then export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH echo "----" - pkg-config list-package-names - echo "----" - pkg-config --exists openssl + pkg-config --list-package-names echo "----" echo "CFLAGS 1: '$(pkg-config --print-errors --no-cache --debug --path --cflags openssl)'" echo "LIBS 1: '$(pkg-config --print-errors --no-cache --debug --path --libs openssl)'" From b93f63809dc5a49901f2812ae557b6678392ef49 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Wed, 20 Nov 2024 22:56:17 +0200 Subject: [PATCH 17/36] test(debug): package config debug --- .../unit-integration-test-runner/run-unit-tests.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 0e7f23ce..febeed0d 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -4,7 +4,8 @@ set -e #ls /usr/include/openssl #ls /usr/lib/x86_64-linux-gnu/libssl.so -echo "~~~> $1" +find /usr/lib -name 'openssl.pc' -exec ls -l {} \; +echo "----" if [[ "$1" == "ubuntu" ]]; then if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then @@ -65,13 +66,11 @@ if [[ "$1" == "ubuntu" ]]; then export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH echo "----" - pkg-config --list-package-names + echo "CFLAGS 1: '$(pkg-config --print-errors --no-cache --debug --cflags openssl)'" + echo "LIBS 1: '$(pkg-config --print-errors --no-cache --debug --libs openssl)'" echo "----" - echo "CFLAGS 1: '$(pkg-config --print-errors --no-cache --debug --path --cflags openssl)'" - echo "LIBS 1: '$(pkg-config --print-errors --no-cache --debug --path --libs openssl)'" - echo "----" - echo "CFLAGS 2: '$(pkg-config --print-errors --no-cache --debug --path --internal-cflags --cflags openssl)'" - echo "LIBS 2: '$(pkg-config --print-errors --no-cache --debug --path --libs openssl)'" + echo "CFLAGS 2: '$(pkg-config --print-errors --no-cache --debug --internal-cflags --cflags openssl)'" + echo "LIBS 2: '$(pkg-config --print-errors --no-cache --debug --libs openssl)'" fi echo "::group::Run unit tests ('$1' $CC / $CXX)" From 716fcc1e5371b9aae5d735a12113ca0112bd6259 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 00:09:15 +0200 Subject: [PATCH 18/36] test(openssl): detect on Darwin and hardcode paths in other case --- .../run-unit-tests.sh | 72 ------------------- core/Makefile | 42 ++++++----- cpp/posix_openssl.mk | 49 +++++++------ openssl/posix.mk | 50 +++++++------ 4 files changed, 83 insertions(+), 130 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index febeed0d..80927afe 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,77 +1,5 @@ #!/bin/bash set -e -# -#ls /usr/include/openssl -#ls /usr/lib/x86_64-linux-gnu/libssl.so - -find /usr/lib -name 'openssl.pc' -exec ls -l {} \; -echo "----" - -if [[ "$1" == "ubuntu" ]]; then - if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then - echo "~~~> 'openssl' package config not found!" - else - echo "~~~> 'openssl' package configuration exists" - cat /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc - echo "----" - fi - echo "----" - if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc ]; then - echo "~~~> 'libssl' package config not found!" - else - echo "~~~> 'libssl' package configuration exists" - cat /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc - echo "----" - - if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then - echo "~~~> 'openssl' package config not found!" - sudo ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc - else - echo "~~~> 'openssl' package configuration exists" - fi - fi - - - if [ ! -f /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc ]; then - OPENSSL_VERSION=$(openssl version | awk '{print $2}') - echo "prefix=/usr - exec_prefix=\${prefix} - libdir=\${exec_prefix}/lib/x86_64-linux-gnu - includedir=\${prefix}/include - - Name: OpenSSL - Description: Secure Sockets Layer and cryptography libraries and tools - Version: $OPENSSL_VERSION - Requires: - Libs: -L\${libdir} -lssl -lcrypto - Cflags: -I\${includedir}" | sudo tee /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc > /dev/null - else - OPENSSL_PC_FILE=/usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc - # Fix Libs if required. - if ! grep -q "Libs:" "$OPENSSL_PC_FILE"; then - echo "~~~> Adding missing Libs field..." - echo "Libs: -L/usr/lib/x86_64-linux-gnu -lssl -lcrypto" | sudo tee -a "$OPENSSL_PC_FILE" - fi - - # Fix C flags if required. - if ! grep -q "Cflags:" "$OPENSSL_PC_FILE"; then - echo "~~~> Adding missing Cflags field..." - echo "Cflags: -I/usr/include" | sudo tee -a "$OPENSSL_PC_FILE" - fi - echo "----" - echo "$OPENSSL_PC_FILE" - cat "$OPENSSL_PC_FILE" - echo "----" - fi - - export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH - echo "----" - echo "CFLAGS 1: '$(pkg-config --print-errors --no-cache --debug --cflags openssl)'" - echo "LIBS 1: '$(pkg-config --print-errors --no-cache --debug --libs openssl)'" - echo "----" - echo "CFLAGS 2: '$(pkg-config --print-errors --no-cache --debug --internal-cflags --cflags openssl)'" - echo "LIBS 2: '$(pkg-config --print-errors --no-cache --debug --libs openssl)'" -fi echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" diff --git a/core/Makefile b/core/Makefile index a2efa5e8..155921a6 100644 --- a/core/Makefile +++ b/core/Makefile @@ -87,25 +87,35 @@ CRYPTO_INCLUDES += -I ../openssl/. CRYPTO_LIBS += -lssl -lcrypto CRYPTO_SOURCEFILES += pubnub_crypto.c pbcc_crypto.c pbcc_crypto_aes_cbc.c pbcc_crypto_legacy.c ../openssl/pbaes256.c -# Searching for proper OpenSSL paths. -CRYPTO_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) -CRYPTO_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) -OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl) -OPENSSL_LIBS := $(shell pkg-config --libs openssl) - -ifeq ($(CRYPTO_CFLAGS),) - CRYPTO_CFLAGS := -I/usr/local/opt/openssl/include -endif -ifeq ($(CRYPTO_LIBS),) - CRYPTO_LIBS := -L/usr/local/opt/openssl/lib + +OS := $(shell uname) +ifeq ($(OS),Darwin) + # Ensure OpenSSL paths are set. + OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) + OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + ifneq ($(OPENSSL_CFLAGS),) + CRYPTO_INCLUDES += $(OPENSSL_CFLAGS) + endif + ifneq ($(OPENSSL_LIBS),) + CRYPTO_LIBS += $(OPENSSL_LIBS) + endif +else + ifeq ($(shell test -d "/usr/local/opt/openssl" && echo yes || echo no),yes) + CRYPTO_INCLUDES += -I/usr/local/opt/openssl/include + else + # Path on GitHub Action Runner (ubuntu-latest image) + ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) + CRYPTO_INCLUDES += -I/usr/include/openssl + endif + endif + # Path on GitHub Action Runner (ubuntu-latest image) + ifeq ($(shell test -d "/usr/lib/x86_64-linux-gnu" && echo yes || echo no),yes) + CRYPTO_LIBS += -L/usr/lib/x86_64-linux-gnu + endif endif -CRYPTO_INCLUDES += $(CRYPTO_CFLAGS) -CRYPTO_LIBS += $(CRYPTO_LIBS) pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c - @echo "Includes: '$(OPENSSL_CFLAGS)'" - @echo "Libraries: '$(OPENSSL_LIBS)'" gcc -o pbcc_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm $(CGREEN_RUNNER) ./pbcc_crypto_unit_test.so @@ -114,8 +124,6 @@ pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_u SUBSCRIBE_V2_SOURCEFILES += pubnub_subscribe_v2.c pbcc_subscribe_v2.c pubnub_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) pubnub_crypto_unit_tests.c - @echo "Includes: '$(OPENSSL_CFLAGS)'" - @echo "Libraries: '$(OPENSSL_LIBS)'" gcc -o pubnub_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pubnub_crypto_unit_tests.c -lcgreen -lm $(CGREEN_RUNNER) ./pubnub_crypto_unit_test.so diff --git a/cpp/posix_openssl.mk b/cpp/posix_openssl.mk index 0e6e0827..a1885afd 100644 --- a/cpp/posix_openssl.mk +++ b/cpp/posix_openssl.mk @@ -118,29 +118,38 @@ CFLAGS =-g -I .. -I . -I ../openssl -I ../lib/base64 -Wall -D PUBNUB_THREADSAFE OS := $(shell uname) ifeq ($(OS),Darwin) -SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c -OBJFILES += monotonic_clock_get_time_darwin.o -LDLIBS=-lpthread -lssl -lcrypto + SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c + OBJFILES += monotonic_clock_get_time_darwin.o + LDLIBS=-lpthread -lssl -lcrypto + + # Ensure OpenSSL paths are set. + OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) + OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + ifneq ($(OPENSSL_CFLAGS),) + CFLAGS += $(OPENSSL_CFLAGS) + endif + ifneq ($(OPENSSL_LIBS),) + LDLIBS += $(OPENSSL_LIBS) + endif else -SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c -OBJFILES += monotonic_clock_get_time_posix.o -LDLIBS=-lrt -lpthread -lssl -lcrypto + SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c + OBJFILES += monotonic_clock_get_time_posix.o + LDLIBS=-lrt -lpthread -lssl -lcrypto + + ifeq ($(shell test -d "/usr/local/opt/openssl" && echo yes || echo no),yes) + CFLAGS += -I/usr/local/opt/openssl/include + else + # Path on GitHub Action Runner (ubuntu-latest image) + ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) + CFLAGS += -I/usr/include/openssl + endif + endif + # Path on GitHub Action Runner (ubuntu-latest image) + ifeq ($(shell test -d "/usr/lib/x86_64-linux-gnu" && echo yes || echo no),yes) + LDLIBS += -L/usr/lib/x86_64-linux-gnu + endif endif -# Searching for proper OpenSSL paths. -OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) -OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) - -ifeq ($(OPENSSL_CFLAGS),) - OPENSSL_CFLAGS := -I/usr/local/opt/openssl/include -endif -ifeq ($(OPENSSL_LIBS),) - OPENSSL_LIBS := -L/usr/local/opt/openssl/lib -endif - -CFLAGS += $(OPENSSL_CFLAGS) -LDLIBS += $(OPENSSL_LIBS) - all: openssl/pubnub_sync_sample openssl/pubnub_callback_sample openssl/pubnub_sync_grant_sample openssl/pubnub_callback_cpp11_sample openssl/cancel_subscribe_sync_sample openssl/subscribe_publish_callback_sample openssl/futres_nesting_sync openssl/fntest_runner openssl/futres_nesting_callback openssl/futres_nesting_callback_cpp11 diff --git a/openssl/posix.mk b/openssl/posix.mk index d20b7322..85a4586b 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -125,30 +125,38 @@ CFLAGS = -g -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -W OS := $(shell uname) ifeq ($(OS),Darwin) -SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c -OBJFILES += monotonic_clock_get_time_darwin.o -LDLIBS = -lpthread -lssl -lcrypto + SOURCEFILES += ../posix/monotonic_clock_get_time_darwin.c + OBJFILES += monotonic_clock_get_time_darwin.o + LDLIBS = -lpthread -lssl -lcrypto + + # Ensure OpenSSL paths are set. + OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) + OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) + ifneq ($(OPENSSL_CFLAGS),) + CFLAGS += $(OPENSSL_CFLAGS) + endif + ifneq ($(OPENSSL_LIBS),) + LDLIBS += $(OPENSSL_LIBS) + endif else -SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c -OBJFILES += monotonic_clock_get_time_posix.o -LDLIBS=-lrt -lpthread -lssl -lcrypto + SOURCEFILES += ../posix/monotonic_clock_get_time_posix.c + OBJFILES += monotonic_clock_get_time_posix.o + LDLIBS=-lrt -lpthread -lssl -lcrypto + + ifeq ($(shell test -d "/usr/local/opt/openssl" && echo yes || echo no),yes) + CFLAGS += -I/usr/local/opt/openssl/include + else + # Path on GitHub Action Runner (ubuntu-latest image) + ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) + CFLAGS += -I/usr/include/openssl + endif + endif + # Path on GitHub Action Runner (ubuntu-latest image) + ifeq ($(shell test -d "/usr/lib/x86_64-linux-gnu" && echo yes || echo no),yes) + LDLIBS += -L/usr/lib/x86_64-linux-gnu + endif endif -# Searching for proper OpenSSL paths. -OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null) -OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null) - -ifeq ($(OPENSSL_CFLAGS),) - OPENSSL_CFLAGS := -I/usr/local/opt/openssl/include -endif -ifeq ($(OPENSSL_LIBS),) - OPENSSL_LIBS := -L/usr/local/opt/openssl/lib -endif - -CFLAGS += $(OPENSSL_CFLAGS) -LDLIBS += $(OPENSSL_LIBS) - - INCLUDES=-I .. -I . -I ../lib/base64/ From 47ff35d57f07d3beac40d4362504d3e297a4c71d Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 00:19:25 +0200 Subject: [PATCH 19/36] test(debug): libcrypto includes --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 80927afe..acdb04e9 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +ls -la /usr/include + echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" make clean generate_report From 46f8b6d4b25889679ab3cee20e750970f92e90de Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 00:23:36 +0200 Subject: [PATCH 20/36] test(debug): libcrypto includes --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index acdb04e9..d0311b3a 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -ls -la /usr/include +ls /usr/lib/x86_64-linux-gnu/libcrypto.* echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" From 70eb196adf8bd47bfd28c39b5efebcb102802510 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 00:27:08 +0200 Subject: [PATCH 21/36] test(debug): libcrypto includes --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index d0311b3a..1dbb8df5 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -2,6 +2,9 @@ set -e ls /usr/lib/x86_64-linux-gnu/libcrypto.* +echo "----" +ls /usr/include/openssl +echo "----" echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" From ee328028a3f96e149a8435e5982c30cad1c9024d Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 00:40:03 +0200 Subject: [PATCH 22/36] test(libcrypto): fix paths --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 5 ----- core/Makefile | 2 +- cpp/posix_openssl.mk | 2 +- openssl/posix.mk | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 1dbb8df5..80927afe 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,11 +1,6 @@ #!/bin/bash set -e -ls /usr/lib/x86_64-linux-gnu/libcrypto.* -echo "----" -ls /usr/include/openssl -echo "----" - echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" make clean generate_report diff --git a/core/Makefile b/core/Makefile index 155921a6..20aa9c61 100644 --- a/core/Makefile +++ b/core/Makefile @@ -105,7 +105,7 @@ else else # Path on GitHub Action Runner (ubuntu-latest image) ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) - CRYPTO_INCLUDES += -I/usr/include/openssl + CRYPTO_INCLUDES += -I/usr/include endif endif # Path on GitHub Action Runner (ubuntu-latest image) diff --git a/cpp/posix_openssl.mk b/cpp/posix_openssl.mk index a1885afd..5fa51c7e 100644 --- a/cpp/posix_openssl.mk +++ b/cpp/posix_openssl.mk @@ -141,7 +141,7 @@ else else # Path on GitHub Action Runner (ubuntu-latest image) ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) - CFLAGS += -I/usr/include/openssl + CFLAGS += -I/usr/include endif endif # Path on GitHub Action Runner (ubuntu-latest image) diff --git a/openssl/posix.mk b/openssl/posix.mk index 85a4586b..7b5a8c7a 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -148,7 +148,7 @@ else else # Path on GitHub Action Runner (ubuntu-latest image) ifeq ($(shell test -d "/usr/include/openssl" && echo yes || echo no),yes) - CFLAGS += -I/usr/include/openssl + CFLAGS += -I/usr/include endif endif # Path on GitHub Action Runner (ubuntu-latest image) From 1663da6a7a26e569781a7c7e3856a9bf9fe9be62 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 00:44:13 +0200 Subject: [PATCH 23/36] test(debug): printout evp to check types --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 80927afe..6f76aca5 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +cat /usr/include/openssl/evp.h + echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" make clean generate_report From 550ea8140181d5f6141617d55f54fe274ea2138c Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 01:14:48 +0200 Subject: [PATCH 24/36] test(debug): debug libcrypto load issue --- .../unit-integration-test-runner/run-unit-tests.sh | 11 ++++++++++- core/Makefile | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 6f76aca5..69b03a4d 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -1,7 +1,16 @@ #!/bin/bash set -e -cat /usr/include/openssl/evp.h +if [ -d "/usr/lib/x86_64-linux-gnu/" ]; then +ls /usr/lib/x86_64-linux-gnu/libcrypto.* +echo "----" +nm -D /usr/lib/x86_64-linux-gnu/libcrypto.so +echo "----" +nm -D /usr/lib/x86_64-linux-gnu/libcrypto.so | grep EVP_DecryptFinal_ex +echo "----" +export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH +fi + echo "::group::Run unit tests ('$1' $CC / $CXX)" cd "$GITHUB_WORKSPACE/core" diff --git a/core/Makefile b/core/Makefile index 20aa9c61..ccd91315 100644 --- a/core/Makefile +++ b/core/Makefile @@ -118,6 +118,7 @@ endif pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c gcc -o pbcc_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm + ldd pbcc_crypto_unit_test.so $(CGREEN_RUNNER) ./pbcc_crypto_unit_test.so #$(GCOVR) -r . --html --html-details -o coverage.html @@ -126,6 +127,7 @@ SUBSCRIBE_V2_SOURCEFILES += pubnub_subscribe_v2.c pbcc_subscribe_v2.c pubnub_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) pubnub_crypto_unit_tests.c gcc -o pubnub_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pubnub_crypto_unit_tests.c -lcgreen -lm + ldd pubnub_crypto_unit_test.so $(CGREEN_RUNNER) ./pubnub_crypto_unit_test.so From e05a062c0bcf2a0e5a9705801a633b789df30066 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 01:31:58 +0200 Subject: [PATCH 25/36] test(debug): debug libcrypto load issue --- .../unit-integration-test-runner/run-unit-tests.sh | 6 ------ core/Makefile | 8 +++++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 69b03a4d..88027bb1 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -2,12 +2,6 @@ set -e if [ -d "/usr/lib/x86_64-linux-gnu/" ]; then -ls /usr/lib/x86_64-linux-gnu/libcrypto.* -echo "----" -nm -D /usr/lib/x86_64-linux-gnu/libcrypto.so -echo "----" -nm -D /usr/lib/x86_64-linux-gnu/libcrypto.so | grep EVP_DecryptFinal_ex -echo "----" export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH fi diff --git a/core/Makefile b/core/Makefile index ccd91315..c5e0a6b2 100644 --- a/core/Makefile +++ b/core/Makefile @@ -110,24 +110,26 @@ else endif # Path on GitHub Action Runner (ubuntu-latest image) ifeq ($(shell test -d "/usr/lib/x86_64-linux-gnu" && echo yes || echo no),yes) - CRYPTO_LIBS += -L/usr/lib/x86_64-linux-gnu + CRYPTO_LIBS += -L/usr/lib/x86_64-linux-gnu -Wl,-Bdynamic endif endif pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c - gcc -o pbcc_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm + gcc -o pbcc_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm ldd pbcc_crypto_unit_test.so + readelf -s pbcc_crypto_unit_test.so | grep EVP_DecryptFinal_ex $(CGREEN_RUNNER) ./pbcc_crypto_unit_test.so #$(GCOVR) -r . --html --html-details -o coverage.html SUBSCRIBE_V2_SOURCEFILES += pubnub_subscribe_v2.c pbcc_subscribe_v2.c pubnub_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) pubnub_crypto_unit_tests.c - gcc -o pubnub_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c -lcgreen -lm + gcc -o pubnub_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pubnub_crypto_unit_tests.c -lcgreen -lm ldd pubnub_crypto_unit_test.so + readelf -s pubnub_crypto_unit_test.so | grep EVP_DecryptFinal_ex $(CGREEN_RUNNER) ./pubnub_crypto_unit_test.so From 4ce96766852bb3fec65c698be1114f728cc6fb9c Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 01:45:10 +0200 Subject: [PATCH 26/36] test(debug): debug libcrypto load issue --- .../composite/unit-integration-test-runner/run-unit-tests.sh | 5 +++++ core/Makefile | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 88027bb1..4c065093 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -2,6 +2,11 @@ set -e if [ -d "/usr/lib/x86_64-linux-gnu/" ]; then +echo "-----" +ls -l /usr/lib/x86_64-linux-gnu/libcrypto.* +echo "-----" +ls -l /usr/lib/x86_64-linux-gnu/libcrypto.so +echo "-----" export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH fi diff --git a/core/Makefile b/core/Makefile index c5e0a6b2..17bd607a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -116,7 +116,7 @@ endif pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c - gcc -o pbcc_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c -lcgreen -lm + gcc -o pbcc_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c $(CRYPTO_LIBS) -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm ldd pbcc_crypto_unit_test.so readelf -s pbcc_crypto_unit_test.so | grep EVP_DecryptFinal_ex @@ -126,7 +126,7 @@ pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_u SUBSCRIBE_V2_SOURCEFILES += pubnub_subscribe_v2.c pbcc_subscribe_v2.c pubnub_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) pubnub_crypto_unit_tests.c - gcc -o pubnub_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) $(CRYPTO_LIBS) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c -lcgreen -lm + gcc -o pubnub_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c $(CRYPTO_LIBS) -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pubnub_crypto_unit_tests.c -lcgreen -lm ldd pubnub_crypto_unit_test.so readelf -s pubnub_crypto_unit_test.so | grep EVP_DecryptFinal_ex From b5a93455561e100181a843b29bc3993cf1d4e15e Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 21 Nov 2024 01:52:56 +0200 Subject: [PATCH 27/36] test(debug): debug libcrypto load issue --- .../unit-integration-test-runner/run-unit-tests.sh | 5 ----- core/Makefile | 10 ++++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh index 4c065093..88027bb1 100755 --- a/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh +++ b/.github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh @@ -2,11 +2,6 @@ set -e if [ -d "/usr/lib/x86_64-linux-gnu/" ]; then -echo "-----" -ls -l /usr/lib/x86_64-linux-gnu/libcrypto.* -echo "-----" -ls -l /usr/lib/x86_64-linux-gnu/libcrypto.so -echo "-----" export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH fi diff --git a/core/Makefile b/core/Makefile index 17bd607a..3727ea07 100644 --- a/core/Makefile +++ b/core/Makefile @@ -116,20 +116,18 @@ endif pbcc_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) pbcc_crypto_unit_tests.c - gcc -o pbcc_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c $(CRYPTO_LIBS) -lcgreen -lm + gcc -o pbcc_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) -D PUBNUB_CRYPTO_API=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) test/pubnub_test_mocks.c pbcc_crypto_unit_tests.c $(CRYPTO_LIBS) -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pbcc_crypto_unit_tests.c -lcgreen -lm - ldd pbcc_crypto_unit_test.so - readelf -s pbcc_crypto_unit_test.so | grep EVP_DecryptFinal_ex + #ldd pbcc_crypto_unit_test.so $(CGREEN_RUNNER) ./pbcc_crypto_unit_test.so #$(GCOVR) -r . --html --html-details -o coverage.html SUBSCRIBE_V2_SOURCEFILES += pubnub_subscribe_v2.c pbcc_subscribe_v2.c pubnub_crypto_unittest: $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) pubnub_crypto_unit_tests.c - gcc -o pubnub_crypto_unit_test.so -shared -v $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c $(CRYPTO_LIBS) -lcgreen -lm + gcc -o pubnub_crypto_unit_test.so -shared $(CFLAGS) $(LDFLAGS) $(CRYPTO_INCLUDES) -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SUBSCRIBE_V2=1 -Wall $(COVERAGE_FLAGS) -fPIC $(PROJECT_SOURCEFILES) $(CRYPTO_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES) test/pubnub_test_mocks.c pubnub_crypto_unit_tests.c $(CRYPTO_LIBS) -lcgreen -lm # gcc -o pubnub_core_unit_testo $(CFLAGS) -Wall $(COVERAGE_FLAGS) $(PROJECT_SOURCEFILES) pubnub_crypto_unit_tests.c -lcgreen -lm - ldd pubnub_crypto_unit_test.so - readelf -s pubnub_crypto_unit_test.so | grep EVP_DecryptFinal_ex + #ldd pubnub_crypto_unit_test.so $(CGREEN_RUNNER) ./pubnub_crypto_unit_test.so From 83eb8eea5f4628a0de33d23a1b980e141e8ee284 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 01:37:31 +0200 Subject: [PATCH 28/36] feat(ipv6): add connectivity setter Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` to `pubnub_coreapi` to switch preferred connectivity protocol. fix(proxy): add proxy context reset on connection close Make sure that in case of connection close (including because of error) proxy context object will be reset. --- core/pubnub_coreapi.c | 17 +++++ core/pubnub_coreapi.h | 10 +++ core/pubnub_dns_servers.c | 14 ---- core/pubnub_dns_servers.h | 8 --- core/pubnub_internal_common.h | 2 +- core/pubnub_netcore.c | 6 +- core/pubnub_proxy_core.c | 10 +++ core/pubnub_proxy_core.h | 3 + core/pubnub_pubsubapi.c | 4 +- .../pbpal_resolv_and_connect_sockets.c | 70 +++++++++++++------ .../pbpal_resolv_and_connect_harmony_tcp.c | 20 ++++-- 11 files changed, 112 insertions(+), 52 deletions(-) diff --git a/core/pubnub_coreapi.c b/core/pubnub_coreapi.c index 5eec3c42..da82efdb 100644 --- a/core/pubnub_coreapi.c +++ b/core/pubnub_coreapi.c @@ -471,3 +471,20 @@ int pubnub_last_http_response_body(pubnub_t* pb, pubnub_chamebl_t* o_msg) pubnub_mutex_unlock(pb->monitor); return 0; } + +#if PUBNUB_USE_IPV6 +void pubnub_set_ipv4_connectivity(pubnub_t *p) +{ + pubnub_mutex_lock(p->monitor); + p->options.ipv6_connectivity = false; + pubnub_mutex_unlock(p->monitor); +} + +void pubnub_set_ipv6_connectivity(pubnub_t *p) +{ + pubnub_mutex_lock(p->monitor); + p->options.ipv6_connectivity = true; + pubnub_mutex_unlock(p->monitor); +} +#endif /* PUBNUB_USE_IPV6 */ + diff --git a/core/pubnub_coreapi.h b/core/pubnub_coreapi.h index e803c828..99656480 100644 --- a/core/pubnub_coreapi.h +++ b/core/pubnub_coreapi.h @@ -439,4 +439,14 @@ PUBNUB_EXTERN int pubnub_get_error_message(pubnub_t* pb, pubnub_chamebl_t* o_msg */ PUBNUB_EXTERN int pubnub_last_http_response_body(pubnub_t* pb, pubnub_chamebl_t* o_msg); +#if PUBNUB_USE_IPV6 +/** IPv4 connectivity type for @p. + Use IPv4 addresses to establish connection with remote origin. */ +PUBNUB_EXTERN void pubnub_set_ipv4_connectivity(pubnub_t *p); + +/** IPv6 connectivity type for @p. + Use IPv6 addresses to establish connection with remote origin. */ +PUBNUB_EXTERN void pubnub_set_ipv6_connectivity(pubnub_t *p); +#endif + #endif /* defined INC_PUBNUB_COREAPI */ diff --git a/core/pubnub_dns_servers.c b/core/pubnub_dns_servers.c index b02d07da..57a63d33 100644 --- a/core/pubnub_dns_servers.c +++ b/core/pubnub_dns_servers.c @@ -165,20 +165,6 @@ int pubnub_get_dns_secondary_server_ipv4(struct pubnub_ipv4_address* o_ipv4) } #if PUBNUB_USE_IPV6 -void pubnub_set_ipv4_connectivity(pubnub_t *p) -{ - pubnub_mutex_lock(p->monitor); - p->options.ipv6_connectivity = false; - pubnub_mutex_unlock(p->monitor); -} - -void pubnub_set_ipv6_connectivity(pubnub_t *p) -{ - pubnub_mutex_lock(p->monitor); - p->options.ipv6_connectivity = true; - pubnub_mutex_unlock(p->monitor); -} - int pubnub_dns_set_primary_server_ipv6(struct pubnub_ipv6_address ipv6_address) { uint8_t* ipv6 = ipv6_address.ipv6; diff --git a/core/pubnub_dns_servers.h b/core/pubnub_dns_servers.h index 73c3b986..2a77f411 100644 --- a/core/pubnub_dns_servers.h +++ b/core/pubnub_dns_servers.h @@ -20,14 +20,6 @@ struct pubnub_ipv6_address { uint8_t ipv6[16]; }; -/** IPv4 connectivity type for @p. - Use IPv4 addresses to establish connection with remote origin. */ -void pubnub_set_ipv4_connectivity(pubnub_t *p); - -/** IPv6 connectivity type for @p. - Use IPv6 addresses to establish connection with remote origin. */ -void pubnub_set_ipv6_connectivity(pubnub_t *p); - /* primary, secondary(ipv4, ipv6) and default dns server */ #define PUBNUB_MAX_DNS_SERVERS_MASK 0x10 #else diff --git a/core/pubnub_internal_common.h b/core/pubnub_internal_common.h index ba6a733e..f30cdc82 100644 --- a/core/pubnub_internal_common.h +++ b/core/pubnub_internal_common.h @@ -206,7 +206,7 @@ struct pubnub_options { */ bool use_http_keep_alive : 1; -#if PUBNUB_USE_IPV6 && defined(PUBNUB_CALLBACK_API) +#if PUBNUB_USE_IPV6 /* Connectivity type(true-Ipv6/false-Ipv4) chosen on a given context */ bool ipv6_connectivity : 1; #endif diff --git a/core/pubnub_netcore.c b/core/pubnub_netcore.c index 62bad26b..227faabb 100644 --- a/core/pubnub_netcore.c +++ b/core/pubnub_netcore.c @@ -186,6 +186,10 @@ static bool should_keep_alive(struct pubnub_* pb, enum pubnub_res rslt) static void close_connection(struct pubnub_* pb) { +#if PUBNUB_PROXY_API + pbproxy_handle_connection_close(pb); +#endif /* PUBNUB_PROXY_API */ + if (pbpal_close(pb) <= 0) { #if PUBNUB_NEED_RETRY_AFTER_CLOSE PUBNUB_LOG_TRACE("close_connection(): pb->flags.retry_after_close=%d\n", @@ -588,7 +592,7 @@ int pbnc_fsm(struct pubnub_* pb) if (0 == i) { goto next_state; } - else if (i < 0) { + if (i < 0) { pb->core.last_result = PNR_CONNECT_FAILED; #if PUBNUB_ADNS_RETRY_AFTER_CLOSE if (pb->flags.retry_after_close) { diff --git a/core/pubnub_proxy_core.c b/core/pubnub_proxy_core.c index b40a4a7e..dcbe9221 100644 --- a/core/pubnub_proxy_core.c +++ b/core/pubnub_proxy_core.c @@ -122,6 +122,15 @@ static int process_digest_header_line(pubnub_t* p, char const* header) return 0; } +void pbproxy_handle_connection_close(pubnub_t *pb) +{ + /* Invalidate current NTLM proxy context state. */ + if (pbhtauNTLM == pb->proxy_auth_scheme && + (pb->ntlm_context.state != pbntlmSendNegotiate && + pb->ntlm_context.state != pbntlmDone)) { + pbntlm_core_deinit(pb); + } +} int pbproxy_handle_http_header(pubnub_t* p, char const* header) { @@ -211,6 +220,7 @@ int pbproxy_handle_http_header(pubnub_t* p, char const* header) } else if ((0 == strncmp(contents, scheme_NTLM, sizeof scheme_NTLM - 1)) && (auth_sheme_priority(p->proxy_auth_scheme) <= auth_sheme_priority(pbhtauNTLM))) { + PUBNUB_LOG_TRACE("pbproxy_handle_http_header() NTLM authentication\n"); if (pbhtauNTLM != p->proxy_auth_scheme) { pbntlm_core_init(p); p->proxy_auth_scheme = pbhtauNTLM; diff --git a/core/pubnub_proxy_core.h b/core/pubnub_proxy_core.h index e73c2772..6669192c 100644 --- a/core/pubnub_proxy_core.h +++ b/core/pubnub_proxy_core.h @@ -19,12 +19,15 @@ #if PUBNUB_PROXY_API +/** Handle PubNub context connection close. */ +void pbproxy_handle_connection_close(pubnub_t *pb); /** Processes a proxy related HTTP @p header on the Pubnub context @p p. @return 0 expected, -1 unexpected proxy authentication header */ int pbproxy_handle_http_header(pubnub_t *p, char const* header); #else +#define pbproxy_handle_connection_close(p, header) #define pbproxy_handle_http_header(p, header) 0 #endif diff --git a/core/pubnub_pubsubapi.c b/core/pubnub_pubsubapi.c index a8ffdd25..a8953a97 100644 --- a/core/pubnub_pubsubapi.c +++ b/core/pubnub_pubsubapi.c @@ -52,9 +52,9 @@ pubnub_t* pubnub_init(pubnub_t* p, const char* publish_key, const char* subscrib p->state = PBS_IDLE; p->trans = PBTT_NONE; p->options.use_http_keep_alive = true; -#if PUBNUB_USE_IPV6 && defined(PUBNUB_CALLBACK_API) +#if PUBNUB_USE_IPV6 /* IPv4 connectivity type by default. */ - pubnub_set_ipv4_connectivity(p); + p->options.ipv6_connectivity = false; #endif p->flags.started_while_kept_alive = false; p->method = pubnubSendViaGET; diff --git a/lib/sockets/pbpal_resolv_and_connect_sockets.c b/lib/sockets/pbpal_resolv_and_connect_sockets.c index f89e8580..ad4b0517 100644 --- a/lib/sockets/pbpal_resolv_and_connect_sockets.c +++ b/lib/sockets/pbpal_resolv_and_connect_sockets.c @@ -149,6 +149,7 @@ static void get_dns_ip(struct sockaddr* addr) get_default_dns_ip((struct pubnub_ipv4_address*)p); #endif /* PUBNUB_USE_IPV6 */ } +#if PUBNUB_USE_IPV6 if (AF_INET6 == addr->sa_family) { if ((pubnub_get_dns_primary_server_ipv6((struct pubnub_ipv6_address*)pv6) == -1) @@ -158,6 +159,7 @@ static void get_dns_ip(struct sockaddr* addr) get_default_dns_ip((struct pubnub_ipv4_address*)p); } } +#endif } #endif /* PUBNUB_CHANGE_DNS_SERVERS */ #else @@ -295,7 +297,11 @@ try_TCP_connect_spare_address(pb_socket_t* skt, enum pbpal_resolv_n_connect_result rslt = pbpal_resolv_resource_failure; time_t tt = time(NULL); - if (spare_addresses->ipv4_index < spare_addresses->n_ipv4) { + if (spare_addresses->ipv4_index < spare_addresses->n_ipv4 +#if PUBNUB_USE_IPV6 + && !options->ipv6_connectivity +#endif /* PUBNUB_USE_IPV6 */ + ) { PUBNUB_LOG_TRACE( "spare_addresses->ipv4_index = %d, spare_addresses->n_ipv4 = %d.\n", spare_addresses->ipv4_index, @@ -408,10 +414,18 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t* pb) #ifdef PUBNUB_CALLBACK_API sockaddr_inX_t dest = { 0 }; +#if PUBNUB_USE_IPV6 + const bool has_ipv6_proxy = 0 != pb->proxy_ipv6_address.ipv6[0] + || 0 != pb->proxy_ipv6_address.ipv6[1]; +#endif /* PUBNUB_USE_IPV6 */ prepare_port_and_hostname(pb, &port, &origin); #if PUBNUB_PROXY_API - if (0 != pb->proxy_ipv4_address.ipv4[0]) { + if (0 != pb->proxy_ipv4_address.ipv4[0] +#if PUBNUB_USE_IPV6 + && (!pb->options.ipv6_connectivity || !has_ipv6_proxy) +#endif /* PUBNUB_USE_IPV6 */ + ) { struct sockaddr_in dest = { 0 }; PUBNUB_LOG_TRACE("(0 != pb->proxy_ipv4_address.ipv4[0]) - "); memcpy(&(dest.sin_addr.s_addr), @@ -422,8 +436,7 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t* pb) &pb->pal.socket, &pb->options, (struct sockaddr*)&dest, port); } #if PUBNUB_USE_IPV6 - else if ((0 != pb->proxy_ipv6_address.ipv6[0]) - || (0 != pb->proxy_ipv6_address.ipv6[1])) { + if (has_ipv6_proxy) { struct sockaddr_in6 dest = { 0 }; PUBNUB_LOG_TRACE("(0 != pb->proxy_ipv6_address.ipv6[0]) ||" " (0 != pb->proxy_ipv6_address.ipv6[1]) - "); @@ -469,7 +482,7 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t* pb) #endif return pbpal_resolv_failed_send; } - else if (error > 0) { + if (error > 0) { return pbpal_resolv_send_wouldblock; } pb->flags.sent_queries++; @@ -495,28 +508,41 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t* pb) if (error != 0) { return pbpal_resolv_failed_processing; } +#if PUBNUB_USE_IPV6 + for (int pass = 0; pass < 2; ++pass) { + bool prioritize_ipv6 = pass == 0 && pb->options.ipv6_connectivity; +#endif /* PUBNUB_USE_IPV6 */ - for (it = result; it != NULL; it = it->ai_next) { - pb->pal.socket = socket(it->ai_family, it->ai_socktype, it->ai_protocol); - if (pb->pal.socket == SOCKET_INVALID) { - continue; - } - pbpal_set_blocking_io(pb); - if (connect(pb->pal.socket, it->ai_addr, it->ai_addrlen) == SOCKET_ERROR) { - if (socket_would_block()) { - error = 1; - break; - } - else { - PUBNUB_LOG_WARNING("socket connect() failed, will try another " - "IP address, if available\n"); - socket_close(pb->pal.socket); - pb->pal.socket = SOCKET_INVALID; + for (it = result; it != NULL; it = it->ai_next) { +#if PUBNUB_USE_IPV6 + if (prioritize_ipv6 && it->ai_family != AF_INET6) { continue; } + if (!prioritize_ipv6 && it->ai_family != AF_INET) { continue; } +#endif /* PUBNUB_USE_IPV6 */ + + pb->pal.socket = + socket(it->ai_family, it->ai_socktype, it->ai_protocol); + if (pb->pal.socket == SOCKET_INVALID) { continue; } + pbpal_set_blocking_io(pb); + if (connect(pb->pal.socket, it->ai_addr, it->ai_addrlen) == SOCKET_ERROR) { + if (socket_would_block()) { + error = 1; + break; + } + else { + PUBNUB_LOG_WARNING("socket connect() failed, will try " + "another IP address, if available\n"); + socket_close(pb->pal.socket); + pb->pal.socket = SOCKET_INVALID; + continue; + } + } + break; } - break; +#if PUBNUB_USE_IPV6 } +#endif /* PUBNUB_USE_IPV6 */ freeaddrinfo(result); if (NULL == it) { diff --git a/microchip_harmony/pbpal_resolv_and_connect_harmony_tcp.c b/microchip_harmony/pbpal_resolv_and_connect_harmony_tcp.c index b5f26af8..c754cb92 100644 --- a/microchip_harmony/pbpal_resolv_and_connect_harmony_tcp.c +++ b/microchip_harmony/pbpal_resolv_and_connect_harmony_tcp.c @@ -13,7 +13,13 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t *pb) { char const* origin = PUBNUB_ORIGIN_SETTABLE ? pb->origin : PUBNUB_ORIGIN; - TCPIP_DNS_RESULT dns_result = TCPIP_DNS_Resolve(origin, TCPIP_DNS_TYPE_A); +#if PUBNUB_USE_IPV6 + TCPIP_DNS_RESOLVE_TYPE query_type = + pb->options.ipv6_connectivity ? TCPIP_DNS_TYPE_AAAA : TCPIP_DNS_TYPE_A; +#else + TCPIP_DNS_RESOLVE_TYPE query_type = TCPIP_DNS_TYPE_A; +#endif + TCPIP_DNS_RESULT dns_result = TCPIP_DNS_Resolve(origin, query_type); PUBNUB_ASSERT(pb_valid_ctx_ptr(pb)); PUBNUB_ASSERT((pb->state == PBS_IDLE) || (pb->state == PBS_WAIT_DNS_SEND) || (pb->state == PBS_WAIT_DNS_RCV)); @@ -41,8 +47,14 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t *pb) enum pbpal_resolv_n_connect_result pbpal_check_resolv_and_connect(pubnub_t *pb) { char const* origin = PUBNUB_ORIGIN_SETTABLE ? pb->origin : PUBNUB_ORIGIN; +#if PUBNUB_USE_IPV6 + IP_ADDRESS_TYPE address_type = + pb->options.ipv6_connectivity ? IP_ADDRESS_TYPE_IPV6 : IP_ADDRESS_TYPE_IPV4; +#else + IP_ADDRESS_TYPE address_type = IP_ADDRESS_TYPE_IPV4; +#endif IP_MULTI_ADDRESS ip_addr; - TCPIP_DNS_RESULT dns_result = TCPIP_DNS_IsResolved(origin, &ip_addr, IP_ADDRESS_TYPE_IPV4); + TCPIP_DNS_RESULT dns_result = TCPIP_DNS_IsResolved(origin, &ip_addr, address_type); PUBNUB_ASSERT_OPT(pb != NULL); switch (dns_result) { case TCPIP_DNS_RES_OK: @@ -51,12 +63,12 @@ enum pbpal_resolv_n_connect_result pbpal_check_resolv_and_connect(pubnub_t *pb) pb->pal.socket = NET_PRES_SocketOpen( 0, pb->options.useSSL ? NET_PRES_SKT_ENCRYPTED_STREAM_CLIENT : NET_PRES_SKT_UNENCRYPTED_STREAM_CLIENT, - IP_ADDRESS_TYPE_IPV4, + address_type, HTTPS_PORT, (NET_PRES_ADDRESS*)&ip_addr, NULL ); #else - pb->pal.socket = TCPIP_TCP_ClientOpen(IP_ADDRESS_TYPE_IPV4, HTTP_PORT, &ip_addr); + pb->pal.socket = TCPIP_TCP_ClientOpen(address_type, HTTP_PORT, &ip_addr); #endif } if (SOCKET_INVALID == pb->pal.socket) { From 1cb5745b9e58688bec0ca9e49fbdd7abdc109e7f Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 12:18:36 +0200 Subject: [PATCH 29/36] fix(subscribe): fix subscribe v2 decrypt issue Fix issue because of which library with enabled but not configured crypto didn't return message from `pubnub_get_v2`. --- core/pbcc_subscribe_v2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/pbcc_subscribe_v2.c b/core/pbcc_subscribe_v2.c index 119bb749..4ed2e13c 100644 --- a/core/pbcc_subscribe_v2.c +++ b/core/pbcc_subscribe_v2.c @@ -254,6 +254,9 @@ struct pubnub_v2_message pbcc_get_msg_v2(struct pbcc_context* p) found.end - found.start, &rslt.payload.size ); + } else { + rslt.payload.ptr = (char*)found.start; + rslt.payload.size = found.end - found.start; } #else rslt.payload.ptr = (char*)found.start; From dc6826f638cff069167d72ac8588018c7a02df74 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 22:13:35 +0200 Subject: [PATCH 30/36] build(samples): update publish via post sample to support IPv6 connectivity --- core/samples/pubnub_publish_via_post_sample.c | 12 +++++++++ openssl/posix.mk | 25 +++++++++++------- posix/posix.mk | 26 ++++++++++++------- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/core/samples/pubnub_publish_via_post_sample.c b/core/samples/pubnub_publish_via_post_sample.c index 4c60bd3d..bca89677 100644 --- a/core/samples/pubnub_publish_via_post_sample.c +++ b/core/samples/pubnub_publish_via_post_sample.c @@ -2,6 +2,8 @@ #include "pubnub_sync.h" #include "core/pubnub_coreapi_ex.h" +#include "core/pubnub_coreapi.h" +#include "core/pubnub_dns_servers.h" #include "core/pubnub_helper.h" #include "core/pubnub_timers.h" @@ -89,14 +91,24 @@ int main() char* my_env_publish_key = getenv("PUBNUB_PUBLISH_KEY"); char* my_env_subscribe_key = getenv("PUBNUB_SUBSCRIBE_KEY"); char* my_env_secret_key = getenv("PUBNUB_SECRET_KEY"); + char* my_env_ipv6_connectivity = getenv("PUBNUB_USE_IPV6_CONNECTIVITY"); + char* my_env_origin = getenv("PUBNUB_ORIGIN"); if (NULL == my_env_publish_key) { my_env_publish_key = "demo"; } if (NULL == my_env_subscribe_key) { my_env_subscribe_key = "demo"; } if (NULL == my_env_secret_key) { my_env_secret_key = "demo"; } + if (NULL == my_env_origin) { my_env_origin = "ps.pndsn.com"; } printf("%s\n%s\n%s\n",my_env_publish_key,my_env_subscribe_key,my_env_secret_key); pubnub_init(pbp, my_env_publish_key, my_env_subscribe_key); pubnub_set_user_id(pbp, user_id); + pubnub_origin_set(pbp, my_env_origin); +#if PUBNUB_USE_IPV6 + // Enable IPv6 connectivity. + if (NULL != my_env_ipv6_connectivity) { + pubnub_set_ipv6_connectivity(pbp); + } +#endif pubnub_set_transaction_timeout(pbp, PUBNUB_DEFAULT_NON_SUBSCRIBE_TIMEOUT); diff --git a/openssl/posix.mk b/openssl/posix.mk index 7b5a8c7a..4b7bf53f 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -58,6 +58,14 @@ ifndef USE_CRYPTO_API USE_CRYPTO_API = 1 endif +ifndef USE_IPV6 +USE_IPV6 = 1 +endif + +ifndef USE_DNS_SERVERS +USE_DNS_SERVERS = 1 +endif + ifeq ($(USE_PROXY), 1) SOURCEFILES += ../core/pubnub_proxy.c ../core/pubnub_proxy_core.c ../core/pbhttp_digest.c ../core/pbntlm_core.c ../core/pbntlm_packer_std.c OBJFILES += pubnub_proxy.o pubnub_proxy_core.o pbhttp_digest.o pbntlm_core.o pbntlm_packer_std.o @@ -159,14 +167,18 @@ endif INCLUDES=-I .. -I . -I ../lib/base64/ - all: pubnub_sync_sample pubnub_sync_grant_token_sample pubnub_sync_revoke_token_sample pubnub_objects_secretkey_sample metadata cancel_subscribe_sync_sample pubnub_sync_subloop_sample pubnub_publish_via_post_sample pubnub_publish_via_post_secretkey_sample pubnub_advanced_history_sample pubnub_fetch_history_sample pubnub_callback_sample subscribe_publish_callback_sample pubnub_callback_subloop_sample pubnub_fntest pubnub_console_sync pubnub_console_callback pubnub_crypto_sync_sample subscribe_publish_from_callback publish_callback_subloop_sample publish_queue_callback_subloop pubnub_crypto_module_sample SYNC_INTF_SOURCEFILES=../core/pubnub_ntf_sync.c ../core/pubnub_sync_subscribe_loop.c ../core/srand_from_pubnub_time.c SYNC_INTF_OBJFILES=pubnub_ntf_sync.o pubnub_sync_subscribe_loop.o srand_from_pubnub_time.o +ifeq ($(USE_IPV6), 1) +SYNC_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c +SYNC_INTF_OBJFILES += pubnub_parse_ipv6_addr.o +endif + pubnub_sync.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - $(CC) -c $(CFLAGS) -D PUBNUB_RAND_INIT_VECTOR=0 $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) + $(CC) -c $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_RAND_INIT_VECTOR=0 $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) ar rcs pubnub_sync.a $(OBJFILES) $(SYNC_INTF_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(GRANT_TOKEN_OBJFILES) pubnub_sync_dynamiciv.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) @@ -176,13 +188,6 @@ pubnub_sync_dynamiciv.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_posix.c pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_ntf_callback_poller_poll.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c CALLBACK_INTF_OBJFILES=pubnub_ntf_callback_posix.o pubnub_get_native_socket.o pubnub_timer_list.o pbpal_ntf_callback_poller_poll.o pbpal_adns_sockets.o pubnub_dns_codec.o pbpal_ntf_callback_queue.o pbpal_ntf_callback_admin.o pbpal_ntf_callback_handle_timer_list.o pubnub_callback_subscribe_loop.o -ifndef USE_DNS_SERVERS -USE_DNS_SERVERS = 1 -endif - -ifndef USE_IPV6 -USE_IPV6 = 1 -endif ifeq ($(USE_DNS_SERVERS), 1) CALLBACK_INTF_SOURCEFILES += ../core/pubnub_dns_servers.c ../posix/pubnub_dns_system_servers.c ../lib/pubnub_parse_ipv4_addr.c @@ -237,7 +242,7 @@ pubnub_sync_subloop_sample: ../core/samples/pubnub_sync_subloop_sample.c pubnub_ $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_subloop_sample.c pubnub_sync.a $(LDLIBS) pubnub_publish_via_post_sample: ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a $(LDLIBS) + $(CC) -o $@ $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(INCLUDES) ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a $(LDLIBS) pubnub_publish_via_post_secretkey_sample: ../core/samples/pubnub_publish_via_post_secretkey_sample.c pubnub_sync.a $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_publish_via_post_secretkey_sample.c pubnub_sync.a $(LDLIBS) diff --git a/posix/posix.mk b/posix/posix.mk index 80cc008a..5da74da7 100644 --- a/posix/posix.mk +++ b/posix/posix.mk @@ -58,6 +58,14 @@ ifndef USE_FETCH_HISTORY USE_FETCH_HISTORY = 1 endif +ifndef USE_IPV6 +USE_IPV6 = 1 +endif + +ifndef USE_DNS_SERVERS +USE_DNS_SERVERS = 1 +endif + ifeq ($(USE_PROXY), 1) SOURCEFILES += ../core/pubnub_proxy.c ../core/pubnub_proxy_core.c ../core/pbhttp_digest.c ../core/pbntlm_core.c ../core/pbntlm_packer_std.c OBJFILES += pubnub_proxy.o pubnub_proxy_core.o pbhttp_digest.o pbntlm_core.o pbntlm_packer_std.o @@ -124,7 +132,7 @@ OBJFILES += monotonic_clock_get_time_posix.o LDLIBS=-lrt -lpthread endif -CFLAGS =-g -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=$(USE_SUBSCRIBE_EVENT_ENGINE) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) +CFLAGS =-g -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_DEBUG -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=$(USE_SUBSCRIBE_EVENT_ENGINE) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) # -g # enables debugging, remove to get a smaller executable # -fsanitize=address # Use AddressSanitizer # -fsanitize=thread # Use ThreadSanitizer: @@ -136,20 +144,18 @@ all: pubnub_sync_sample metadata cancel_subscribe_sync_sample pubnub_advanced_hi SYNC_INTF_SOURCEFILES=../core/pubnub_ntf_sync.c ../core/pubnub_sync_subscribe_loop.c ../core/srand_from_pubnub_time.c SYNC_INTF_OBJFILES=pubnub_ntf_sync.o pubnub_sync_subscribe_loop.o srand_from_pubnub_time.o +ifeq ($(USE_IPV6), 1) +SYNC_INTF_SOURCEFILES += ../lib/pubnub_parse_ipv6_addr.c +SYNC_INTF_OBJFILES += pubnub_parse_ipv6_addr.o +endif + pubnub_sync.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) - $(CC) -c $(CFLAGS) $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) + $(CC) -c $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) ar rcs pubnub_sync.a $(OBJFILES) $(SYNC_INTF_OBJFILES) CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_posix.c pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_ntf_callback_poller_poll.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c CALLBACK_INTF_OBJFILES=pubnub_ntf_callback_posix.o pubnub_get_native_socket.o pubnub_timer_list.o pbpal_ntf_callback_poller_poll.o pbpal_adns_sockets.o pubnub_dns_codec.o pbpal_ntf_callback_queue.o pbpal_ntf_callback_admin.o pbpal_ntf_callback_handle_timer_list.o pubnub_callback_subscribe_loop.o -ifndef USE_DNS_SERVERS -USE_DNS_SERVERS = 1 -endif - -ifndef USE_IPV6 -USE_IPV6 = 1 -endif ifeq ($(USE_DNS_SERVERS), 1) CALLBACK_INTF_SOURCEFILES += ../core/pubnub_dns_servers.c ../posix/pubnub_dns_system_servers.c ../lib/pubnub_parse_ipv4_addr.c @@ -183,7 +189,7 @@ pubnub_sync_publish_retry: ../core/samples/pubnub_sync_publish_retry.c pubnub_sy $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_sync_publish_retry.c pubnub_sync.a $(LDLIBS) pubnub_publish_via_post_sample: ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a - $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a $(LDLIBS) + $(CC) -o $@ $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(INCLUDES) ../core/samples/pubnub_publish_via_post_sample.c pubnub_sync.a $(LDLIBS) pubnub_advanced_history_sample: ../core/samples/pubnub_advanced_history_sample.c pubnub_sync.a $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/samples/pubnub_advanced_history_sample.c pubnub_sync.a $(LDLIBS) From 31fb49c9d394d2f58b833b4ef4d7e4cd3ca17d80 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 22:45:27 +0200 Subject: [PATCH 31/36] build(sample): fix missing compilation flags --- Dockerfile | 99 ++++++------------------------------------------ openssl/posix.mk | 2 +- posix/posix.mk | 2 +- 3 files changed, 14 insertions(+), 89 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3364296f..075863fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,95 +1,20 @@ FROM ubuntu:20.04 AS cucumber_cpp ARG DEBIAN_FRONTEND=noninteractive -WORKDIR /home -ENV GMOCK_VER=1.7.0 -ENV CMAKE_CXX_COMPILER=/usr/bin/g++ - -RUN apt-get update -RUN apt-get install -y cmake g++ ruby ruby-dev git ninja-build libboost-all-dev gcovr libssl-dev gdb curl -RUN gem install bundler - -ENV GMOCK_VER=1.7.0 -ENV CMAKE_CXX_COMPILER=/usr/bin/g++ - -RUN git clone https://github.com/cucumber/cucumber-cpp.git - -WORKDIR /home/cucumber-cpp +RUN apt update +RUN apt install -y build-essential libssl-dev pkg-config -RUN bundle install -RUN git submodule init -RUN git submodule update -RUN cmake -E make_directory build -RUN cmake -E chdir build cmake --DCUKE_ENABLE_EXAMPLES=on .. -RUN cmake --build build -RUN cmake --build build --target test - -FROM ubuntu:20.04 AS cgreen -ARG DEBIAN_FRONTEND=noninteractive -WORKDIR /home - -ENV GMOCK_VER=1.7.0 ENV CMAKE_CXX_COMPILER=/usr/bin/g++ +ENV PUBNUB_ORIGIN=h2.pubnubapi.com +ENV PUBNUB_USE_IPV6_CONNECTIVITY=1 -RUN apt-get update -RUN apt-get install -y cmake g++ ruby ruby-dev git ninja-build libboost-all-dev gcovr libssl-dev gdb curl - -RUN git clone https://github.com/cgreen-devs/cgreen.git -RUN cd cgreen && git checkout 1.4.1 && make - -FROM ubuntu:20.04 -ARG DEBIAN_FRONTEND=noninteractive -WORKDIR /home - -ENV GMOCK_VER=1.7.0 -ENV CMAKE_CXX_COMPILER=/usr/bin/g++ - -RUN apt-get update -RUN apt-get install -y cmake g++ ruby ruby-dev git ninja-build libboost-all-dev gcovr libssl-dev gdb curl - -RUN gem install cucumber -RUN apt-get install -y python3-pip -RUN pip install requests - -COPY --from=cucumber_cpp /home/cucumber-cpp /home/cucumber-cpp/ -COPY --from=cgreen /home/cgreen /home/cgreen/ - -COPY core /home/core/ -COPY lib /home/lib/ -RUN cd core && make generate_report -COPY posix /home/posix/ -COPY cpp /home/cpp/ -COPY openssl /home/openssl/ -RUN cd cpp && make -f posix_openssl.mk openssl/pubnub_sync - -ARG SUB_KEY -ARG PUB_KEY -ARG SEC_KEY -ARG MOCK_SERVER_DOCKER -ENV PAM_SUB_KEY=${SUB_KEY} -ENV PAM_PUB_KEY=${PUB_KEY} -ENV PAM_SEC_KEY=${SEC_KEY} - - -COPY sdk-specifications/features /home/features/ -COPY features/step_definitions /home/features/step_definitions/ - -RUN if [ -z "$MOCK_SERVER_DOCKER" ]; then \ - g++ -std=c++11 -g -o BoostSteps.o -c features/step_definitions/BoostSteps.cpp \ - -Icucumber-cpp/include -Icucumber-cpp/build/src/ -Iposix -Icore -I. -Icpp \ - -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SSL=0; \ - else \ - g++ -std=c++11 -g -o BoostSteps.o -c features/step_definitions/BoostSteps.cpp \ - -Icucumber-cpp/include -Icucumber-cpp/build/src/ -Iposix -Icore -I. -Icpp \ - -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SSL=0 -D MOCK_SERVER_DOCKER; \ - fi - - -RUN g++ -o steps BoostSteps.o cpp/pubnub_sync.a cucumber-cpp/build/src/libcucumber-cpp.a \ - -Lboost -lboost_unit_test_framework -lpthread -lboost_regex \ - -lboost_thread -lboost_program_options -lboost_filesystem \ - -lssl -lcrypto -D PUBNUB_USE_SSL=0 +COPY cpp cpp +COPY core core +COPY lib lib +COPY posix posix +COPY openssl openssl -COPY run_contract_tests.py . +WORKDIR /openssl +RUN USE_IPV6=1 make -f posix.mk clean pubnub_publish_via_post_sample -ENTRYPOINT [ "python3", "/home/run_contract_tests.py", "/home/features/access/revoke-token.feature", "mock_server"] +CMD ["./pubnub_publish_via_post_sample"] \ No newline at end of file diff --git a/openssl/posix.mk b/openssl/posix.mk index 4b7bf53f..95b6fd62 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -182,7 +182,7 @@ pubnub_sync.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFIL ar rcs pubnub_sync.a $(OBJFILES) $(SYNC_INTF_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(GRANT_TOKEN_OBJFILES) pubnub_sync_dynamiciv.a : $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) - $(CC) -c $(CFLAGS) -D PUBNUB_RAND_INIT_VECTOR=1 $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) + $(CC) -c $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) -D PUBNUB_RAND_INIT_VECTOR=1 $(INCLUDES) $(SOURCEFILES) $(SYNC_INTF_SOURCEFILES) $(REVOKE_TOKEN_SOURCEFILES) $(GRANT_TOKEN_SOURCEFILES) ar rcs pubnub_sync_dynamiciv.a $(OBJFILES) $(SYNC_INTF_OBJFILES) $(REVOKE_TOKEN_OBJFILES) $(GRANT_TOKEN_OBJFILES) CALLBACK_INTF_SOURCEFILES=pubnub_ntf_callback_posix.c pubnub_get_native_socket.c ../core/pubnub_timer_list.c ../lib/sockets/pbpal_ntf_callback_poller_poll.c ../lib/sockets/pbpal_adns_sockets.c ../lib/pubnub_dns_codec.c ../core/pbpal_ntf_callback_queue.c ../core/pbpal_ntf_callback_admin.c ../core/pbpal_ntf_callback_handle_timer_list.c ../core/pubnub_callback_subscribe_loop.c diff --git a/posix/posix.mk b/posix/posix.mk index 5da74da7..06825549 100644 --- a/posix/posix.mk +++ b/posix/posix.mk @@ -132,7 +132,7 @@ OBJFILES += monotonic_clock_get_time_posix.o LDLIBS=-lrt -lpthread endif -CFLAGS =-g -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_DEBUG -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=$(USE_SUBSCRIBE_EVENT_ENGINE) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) +CFLAGS =-g -Wall -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API) -D PUBNUB_PROXY_API=$(USE_PROXY) -D PUBNUB_USE_RETRY_CONFIGURATION=$(USE_RETRY_CONFIGURATION) -D PUBNUB_USE_GZIP_COMPRESSION=$(USE_GZIP_COMPRESSION) -D PUBNUB_RECEIVE_GZIP_RESPONSE=$(RECEIVE_GZIP_RESPONSE) -D PUBNUB_USE_SUBSCRIBE_V2=$(USE_SUBSCRIBE_V2) -D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=$(USE_SUBSCRIBE_EVENT_ENGINE) -D PUBNUB_USE_OBJECTS_API=$(USE_OBJECTS_API) -D PUBNUB_USE_ACTIONS_API=$(USE_ACTIONS_API) -D PUBNUB_USE_AUTO_HEARTBEAT=$(USE_AUTO_HEARTBEAT) -D PUBNUB_USE_GRANT_TOKEN_API=$(USE_GRANT_TOKEN) -D PUBNUB_USE_REVOKE_TOKEN_API=$(USE_REVOKE_TOKEN) -D PUBNUB_USE_FETCH_HISTORY=$(USE_FETCH_HISTORY) # -g # enables debugging, remove to get a smaller executable # -fsanitize=address # Use AddressSanitizer # -fsanitize=thread # Use ThreadSanitizer: From 9dc125274b41a2568f3efd2073f5c0b4f201c28a Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 22:48:52 +0200 Subject: [PATCH 32/36] test(docker): restore original Dockerfile --- Dockerfile | 99 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 075863fe..125ccbf5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,95 @@ FROM ubuntu:20.04 AS cucumber_cpp ARG DEBIAN_FRONTEND=noninteractive +WORKDIR /home -RUN apt update -RUN apt install -y build-essential libssl-dev pkg-config +ENV GMOCK_VER=1.7.0 +ENV CMAKE_CXX_COMPILER=/usr/bin/g++ + +RUN apt-get update +RUN apt-get install -y cmake g++ ruby ruby-dev git ninja-build libboost-all-dev gcovr libssl-dev gdb curl +RUN gem install bundler + +ENV GMOCK_VER=1.7.0 +ENV CMAKE_CXX_COMPILER=/usr/bin/g++ + +RUN git clone https://github.com/cucumber/cucumber-cpp.git + +WORKDIR /home/cucumber-cpp + +RUN bundle install +RUN git submodule init +RUN git submodule update +RUN cmake -E make_directory build +RUN cmake -E chdir build cmake --DCUKE_ENABLE_EXAMPLES=on .. +RUN cmake --build build +RUN cmake --build build --target test + +FROM ubuntu:20.04 AS cgreen +ARG DEBIAN_FRONTEND=noninteractive +WORKDIR /home + +ENV GMOCK_VER=1.7.0 +ENV CMAKE_CXX_COMPILER=/usr/bin/g++ + +RUN apt-get update +RUN apt-get install -y cmake g++ ruby ruby-dev git ninja-build libboost-all-dev gcovr libssl-dev gdb curl +RUN git clone https://github.com/cgreen-devs/cgreen.git +RUN cd cgreen && git checkout 1.4.1 && make + +FROM ubuntu:20.04 +ARG DEBIAN_FRONTEND=noninteractive +WORKDIR /home + +ENV GMOCK_VER=1.7.0 ENV CMAKE_CXX_COMPILER=/usr/bin/g++ -ENV PUBNUB_ORIGIN=h2.pubnubapi.com -ENV PUBNUB_USE_IPV6_CONNECTIVITY=1 -COPY cpp cpp -COPY core core -COPY lib lib -COPY posix posix -COPY openssl openssl +RUN apt-get update +RUN apt-get install -y cmake g++ ruby ruby-dev git ninja-build libboost-all-dev gcovr libssl-dev gdb curl + +RUN gem install cucumber +RUN apt-get install -y python3-pip +RUN pip install requests + +COPY --from=cucumber_cpp /home/cucumber-cpp /home/cucumber-cpp/ +COPY --from=cgreen /home/cgreen /home/cgreen/ + +COPY core /home/core/ +COPY lib /home/lib/ +RUN cd core && make generate_report +COPY posix /home/posix/ +COPY cpp /home/cpp/ +COPY openssl /home/openssl/ +RUN cd cpp && make -f posix_openssl.mk openssl/pubnub_sync + +ARG SUB_KEY +ARG PUB_KEY +ARG SEC_KEY +ARG MOCK_SERVER_DOCKER +ENV PAM_SUB_KEY=${SUB_KEY} +ENV PAM_PUB_KEY=${PUB_KEY} +ENV PAM_SEC_KEY=${SEC_KEY} + + +COPY sdk-specifications/features /home/features/ +COPY features/step_definitions /home/features/step_definitions/ + +RUN if [ -z "$MOCK_SERVER_DOCKER" ]; then \ + g++ -std=c++11 -g -o BoostSteps.o -c features/step_definitions/BoostSteps.cpp \ + -Icucumber-cpp/include -Icucumber-cpp/build/src/ -Iposix -Icore -I. -Icpp \ + -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SSL=0; \ + else \ + g++ -std=c++11 -g -o BoostSteps.o -c features/step_definitions/BoostSteps.cpp \ + -Icucumber-cpp/include -Icucumber-cpp/build/src/ -Iposix -Icore -I. -Icpp \ + -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SSL=0 -D MOCK_SERVER_DOCKER; \ + fi + + +RUN g++ -o steps BoostSteps.o cpp/pubnub_sync.a cucumber-cpp/build/src/libcucumber-cpp.a \ + -Lboost -lboost_unit_test_framework -lpthread -lboost_regex \ + -lboost_thread -lboost_program_options -lboost_filesystem \ + -lssl -lcrypto -D PUBNUB_USE_SSL=0 -WORKDIR /openssl -RUN USE_IPV6=1 make -f posix.mk clean pubnub_publish_via_post_sample +COPY run_contract_tests.py . -CMD ["./pubnub_publish_via_post_sample"] \ No newline at end of file +ENTRYPOINT [ "python3", "/home/run_contract_tests.py", "/home/features/access/revoke-token.feature", "mock_server"] From e5f1027c4f73f774475219aad12560cf050ac650 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 22:52:29 +0200 Subject: [PATCH 33/36] test(sample): change condition in publish via post sample --- core/samples/pubnub_publish_via_post_sample.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/samples/pubnub_publish_via_post_sample.c b/core/samples/pubnub_publish_via_post_sample.c index bca89677..b1e0ac87 100644 --- a/core/samples/pubnub_publish_via_post_sample.c +++ b/core/samples/pubnub_publish_via_post_sample.c @@ -98,6 +98,7 @@ int main() if (NULL == my_env_subscribe_key) { my_env_subscribe_key = "demo"; } if (NULL == my_env_secret_key) { my_env_secret_key = "demo"; } if (NULL == my_env_origin) { my_env_origin = "ps.pndsn.com"; } + if (NULL == my_env_ipv6_connectivity) { my_env_ipv6_connectivity = "0"; } printf("%s\n%s\n%s\n",my_env_publish_key,my_env_subscribe_key,my_env_secret_key); pubnub_init(pbp, my_env_publish_key, my_env_subscribe_key); @@ -105,7 +106,7 @@ int main() pubnub_origin_set(pbp, my_env_origin); #if PUBNUB_USE_IPV6 // Enable IPv6 connectivity. - if (NULL != my_env_ipv6_connectivity) { + if (0 == strcmp(my_env_ipv6_connectivity, "1")) { pubnub_set_ipv6_connectivity(pbp); } #endif From f29325342437149c51f2af938151f76e4f318ae9 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 23:15:31 +0200 Subject: [PATCH 34/36] test(sample): add IPv6 flags for callback based sample --- core/samples/publish_queue_callback_subloop.c | 17 +++++++++++++++++ core/samples/pubnub_publish_via_post_sample.c | 1 - openssl/posix.mk | 2 +- posix/posix.mk | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/samples/publish_queue_callback_subloop.c b/core/samples/publish_queue_callback_subloop.c index 927f41f8..cc8afec5 100644 --- a/core/samples/publish_queue_callback_subloop.c +++ b/core/samples/publish_queue_callback_subloop.c @@ -2,6 +2,7 @@ #include "pubnub_callback.h" #include "core/pubnub_callback_subscribe_loop.h" +#include "core/pubnub_coreapi.h" #include "core/pubnub_timers.h" #include "core/pubnub_helper.h" #include "core/pubnub_log.h" @@ -158,6 +159,11 @@ int main() time_t start = time(NULL); unsigned i = 0; + char* my_env_ipv6_connectivity = getenv("PUBNUB_USE_IPV6_CONNECTIVITY"); + char* my_env_origin = getenv("PUBNUB_ORIGIN"); + if (NULL == my_env_origin) { my_env_origin = "ps.pndsn.com"; } + if (NULL == my_env_ipv6_connectivity) { my_env_ipv6_connectivity = "0"; } + if ((NULL == pbp) || (NULL == pbp_2)) { printf("Failed to allocate Pubnub context(1 or 2)!\n"); return -1; @@ -168,6 +174,17 @@ int main() pubnub_set_user_id(pbp, "demo"); pubnub_set_user_id(pbp_2, "demo_2"); + pubnub_origin_set(pbp, my_env_origin); + pubnub_origin_set(pbp_2, my_env_origin); + +#if PUBNUB_USE_IPV6 + // Enable IPv6 connectivity. + if (0 == strcmp(my_env_ipv6_connectivity, "1")) { + pubnub_set_ipv6_connectivity(pbp); + pubnub_set_ipv6_connectivity(pbp_2); + } +#endif + pubnub_register_callback(pbp_2, publish_callback, (void*)chan); pubnub_mutex_init_static(m_lock); diff --git a/core/samples/pubnub_publish_via_post_sample.c b/core/samples/pubnub_publish_via_post_sample.c index b1e0ac87..2ba85c48 100644 --- a/core/samples/pubnub_publish_via_post_sample.c +++ b/core/samples/pubnub_publish_via_post_sample.c @@ -3,7 +3,6 @@ #include "core/pubnub_coreapi_ex.h" #include "core/pubnub_coreapi.h" -#include "core/pubnub_dns_servers.h" #include "core/pubnub_helper.h" #include "core/pubnub_timers.h" diff --git a/openssl/posix.mk b/openssl/posix.mk index 95b6fd62..5f96541f 100644 --- a/openssl/posix.mk +++ b/openssl/posix.mk @@ -269,7 +269,7 @@ publish_callback_subloop_sample: ../core/samples/publish_callback_subloop_sample $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_callback_subloop_sample.c pubnub_callback.a $(LDLIBS) publish_queue_callback_subloop: ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a $(LDLIBS) + $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a $(LDLIBS) pubnub_crypto_module_sample: ../core/samples/pubnub_crypto_module_sample.c pubnub_sync.a $(CC) -o $@ $(CFLAGS) $(INCLUDES) -I ../core/ ../core/samples/pubnub_crypto_module_sample.c pubnub_sync.a $(LDLIBS) diff --git a/posix/posix.mk b/posix/posix.mk index 06825549..0a1cab5f 100644 --- a/posix/posix.mk +++ b/posix/posix.mk @@ -220,7 +220,7 @@ publish_callback_subloop_sample: ../core/samples/publish_callback_subloop_sample $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_callback_subloop_sample.c pubnub_callback.a $(LDLIBS) publish_queue_callback_subloop: ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a - $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a $(LDLIBS) + $(CC) -o $@ -D PUBNUB_CALLBACK_API $(CFLAGS) -D PUBNUB_USE_IPV6=$(USE_IPV6) $(CFLAGS_CALLBACK) $(INCLUDES) ../core/samples/publish_queue_callback_subloop.c pubnub_callback.a $(LDLIBS) pubnub_fntest: ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c fntest/pubnub_fntest_posix.c fntest/pubnub_fntest_runner.c pubnub_sync.a $(CC) -o $@ $(CFLAGS) $(INCLUDES) ../core/fntest/pubnub_fntest.c ../core/fntest/pubnub_fntest_basic.c ../core/fntest/pubnub_fntest_medium.c fntest/pubnub_fntest_posix.c fntest/pubnub_fntest_runner.c pubnub_sync.a $(LDLIBS) -lpthread From 666f8d1111dca6c48f6ce8fa604ceb2cc4040477 Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Mon, 25 Nov 2024 21:30:55 +0000 Subject: [PATCH 35/36] PubNub SDK v4.15.0 release. --- .pubnub.yml | 25 +++++++++++++++++-------- CHANGELOG.md | 10 ++++++++++ core/pubnub_version_internal.h | 2 +- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 76c5b55c..15d6fe90 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,17 @@ name: c-core schema: 1 -version: "4.14.1" +version: "4.15.0" scm: github.com/pubnub/c-core changelog: + - date: 2024-11-25 + version: v4.15.0 + changes: + - type: feature + text: "Add custom message type support for the following APIs: publish, signal, share file, subscribe and history." + - type: feature + text: "Add connectivity setter." + - type: bug + text: "Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` to `pubnub_coreapi` to switch preferred connectivity protocol. Make sure that in case of connection close (including because of error) proxy context object will be reset." - date: 2024-10-24 version: v4.14.1 changes: @@ -875,7 +884,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.14.1 + location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 requires: - name: "miniz" @@ -941,7 +950,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.14.1 + location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 requires: - name: "miniz" @@ -1007,7 +1016,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.14.1 + location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 requires: - name: "miniz" @@ -1069,7 +1078,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.14.1 + location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 requires: - name: "miniz" @@ -1130,7 +1139,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.14.1 + location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 requires: - name: "miniz" @@ -1186,7 +1195,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.14.1 + location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 requires: - name: "miniz" @@ -1239,7 +1248,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.14.1 + location: https://github.com/pubnub/c-core/releases/tag/v4.15.0 requires: - name: "miniz" diff --git a/CHANGELOG.md b/CHANGELOG.md index a266a427..21bc5954 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v4.15.0 +November 25 2024 + +#### Added +- Add custom message type support for the following APIs: publish, signal, share file, subscribe and history. +- Add connectivity setter. + +#### Fixed +- Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` to `pubnub_coreapi` to switch preferred connectivity protocol. Make sure that in case of connection close (including because of error) proxy context object will be reset. + ## v4.14.1 October 24 2024 diff --git a/core/pubnub_version_internal.h b/core/pubnub_version_internal.h index ecd52c95..2512985b 100644 --- a/core/pubnub_version_internal.h +++ b/core/pubnub_version_internal.h @@ -3,7 +3,7 @@ #define INC_PUBNUB_VERSION_INTERNAL -#define PUBNUB_SDK_VERSION "4.14.1" +#define PUBNUB_SDK_VERSION "4.15.0" #endif /* !defined INC_PUBNUB_VERSION_INTERNAL */ From 0557529ad4efdd02bb84edf2ec2af0021141013a Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 25 Nov 2024 23:35:14 +0200 Subject: [PATCH 36/36] doc(changelog): fix changelog entries --- .pubnub.yml | 4 ++-- CHANGELOG.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 15d6fe90..343bfd48 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -9,9 +9,9 @@ changelog: - type: feature text: "Add custom message type support for the following APIs: publish, signal, share file, subscribe and history." - type: feature - text: "Add connectivity setter." + text: "Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` to `pubnub_coreapi` to switch preferred connectivity protocol." - type: bug - text: "Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` to `pubnub_coreapi` to switch preferred connectivity protocol. Make sure that in case of connection close (including because of error) proxy context object will be reset." + text: "Make sure that in case of connection close (including because of error) proxy context object will be reset." - date: 2024-10-24 version: v4.14.1 changes: diff --git a/CHANGELOG.md b/CHANGELOG.md index 21bc5954..2d05815a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,10 @@ November 25 2024 #### Added - Add custom message type support for the following APIs: publish, signal, share file, subscribe and history. -- Add connectivity setter. +- Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` to `pubnub_coreapi` to switch preferred connectivity protocol. #### Fixed -- Add `pubnub_set_ipv4_connectivity` and `pubnub_set_ipv6_connectivity` to `pubnub_coreapi` to switch preferred connectivity protocol. Make sure that in case of connection close (including because of error) proxy context object will be reset. +- Make sure that in case of connection close (including because of error) proxy context object will be reset. ## v4.14.1 October 24 2024