From 8ea893b9981bf75dc4f0b5c88530d2b74b758567 Mon Sep 17 00:00:00 2001 From: Aye Min Aung <2681318+ayeminag@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:33:16 +0700 Subject: [PATCH 01/30] build image and push on merge (#167) * [CI] build libks image when pushed to master * updated to use pr-mpt/actions-commit-hash@v2 * added mkissing new line in Dockerfile --------- Co-authored-by: Aye Min Aung --- .github/workflows/build.yml | 51 +++++++++++++++++++++++++++++++++++++ Dockerfile | 13 ++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..032b632 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,51 @@ +name: Build + +on: + push: + branches: + - "master" + - "min/build-image" + workflow_call: + secrets: + # Secrets used to build + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true + GH_BOT_DEPLOY_KEY: + required: true + +jobs: + hash: + runs-on: ubuntu-latest + outputs: + HASH: ${{ steps.hash.outputs.short }} + steps: + - id: hash + uses: pr-mpt/actions-commit-hash@v2 + with: + # NOTE: since this workflow is only triggered by `push` event + # github.sha have correct commit sha + commit: ${{ github.sha }} + build: + needs: hash + strategy: + matrix: + include: + - tag: libks-libs10-${{ needs.hash.outputs.HASH }} + baseimage: "signalwire/freeswitch-base:debian-10" + - tag: libks-libs11-${{ needs.hash.outputs.HASH }} + baseimage: "signalwire/freeswitch-base:debian-11" + name: "build libks" + uses: signalwire/actions-template/.github/workflows/ci-build.yml@main + with: + CONTAINER_SCAN: true + CONTAINER_TEST: false + PROJECT_NAME: "freeswitch-libs" + FILE: ./Dockerfile + PUSH: true + RUNNER: ubuntu-latest + TAG: ${{ matrix.tag }} + BUILD_ARGS: | + BASEIMAGE=${{ matrix.baseimage }} + secrets: inherit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..18a9423 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +ARG BASE_IMAGE=signalwire/freeswitch-base:debian-10 +FROM ${BASE_IMAGE} + +RUN apt-get update && apt-get install -yq build-essential autotools-dev lsb-release pkg-config automake autoconf libtool-bin clang-tools-7 +RUN apt-get install -yq cmake uuid-dev libssl-dev + +RUN mkdir -p /sw/libks + +WORKDIR /sw/libks + +COPY . . + +RUN sed -i -e 's/GIT_FOUND AND GZIP_CMD AND DATE_CMD/WE_DO_NOT_WANT_A_DEBIAN_PACKAGE_THANK_YOU/' CMakeLists.txt && cmake . -DCMAKE_INSTALL_PREFIX=/usr -DWITH_LIBBACKTRACE=1 && make install From 6a4bc398723584af60e6947a3dfd7235490cf66d Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Sun, 6 Aug 2023 23:42:26 -0700 Subject: [PATCH 02/30] Revert "build image and push on merge (#167)" (#170) This reverts commit 8ea893b9981bf75dc4f0b5c88530d2b74b758567. --- .github/workflows/build.yml | 51 ------------------------------------- Dockerfile | 13 ---------- 2 files changed, 64 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 032b632..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Build - -on: - push: - branches: - - "master" - - "min/build-image" - workflow_call: - secrets: - # Secrets used to build - DOCKERHUB_USERNAME: - required: true - DOCKERHUB_TOKEN: - required: true - GH_BOT_DEPLOY_KEY: - required: true - -jobs: - hash: - runs-on: ubuntu-latest - outputs: - HASH: ${{ steps.hash.outputs.short }} - steps: - - id: hash - uses: pr-mpt/actions-commit-hash@v2 - with: - # NOTE: since this workflow is only triggered by `push` event - # github.sha have correct commit sha - commit: ${{ github.sha }} - build: - needs: hash - strategy: - matrix: - include: - - tag: libks-libs10-${{ needs.hash.outputs.HASH }} - baseimage: "signalwire/freeswitch-base:debian-10" - - tag: libks-libs11-${{ needs.hash.outputs.HASH }} - baseimage: "signalwire/freeswitch-base:debian-11" - name: "build libks" - uses: signalwire/actions-template/.github/workflows/ci-build.yml@main - with: - CONTAINER_SCAN: true - CONTAINER_TEST: false - PROJECT_NAME: "freeswitch-libs" - FILE: ./Dockerfile - PUSH: true - RUNNER: ubuntu-latest - TAG: ${{ matrix.tag }} - BUILD_ARGS: | - BASEIMAGE=${{ matrix.baseimage }} - secrets: inherit diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 18a9423..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -ARG BASE_IMAGE=signalwire/freeswitch-base:debian-10 -FROM ${BASE_IMAGE} - -RUN apt-get update && apt-get install -yq build-essential autotools-dev lsb-release pkg-config automake autoconf libtool-bin clang-tools-7 -RUN apt-get install -yq cmake uuid-dev libssl-dev - -RUN mkdir -p /sw/libks - -WORKDIR /sw/libks - -COPY . . - -RUN sed -i -e 's/GIT_FOUND AND GZIP_CMD AND DATE_CMD/WE_DO_NOT_WANT_A_DEBIAN_PACKAGE_THANK_YOU/' CMakeLists.txt && cmake . -DCMAKE_INSTALL_PREFIX=/usr -DWITH_LIBBACKTRACE=1 && make install From 3551509a9206ca03c031c8f2580aed648120e708 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 6 Sep 2023 23:32:31 +0000 Subject: [PATCH 03/30] maybe fix, at least doesn't crash --- src/kws.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/kws.c b/src/kws.c index 1bbb26f..5d6dc7f 100644 --- a/src/kws.c +++ b/src/kws.c @@ -1328,14 +1328,12 @@ KS_DECLARE(ks_ssize_t) kws_read_frame(kws_t *kws, kws_opcode_t *oc, uint8_t **da blen = (int)(kws->body - kws->bbuffer); /* The bbuffer for the body of the message should always be 1 larger than the total size (for null term) */ - if (blen + kws->plen >= (ks_ssize_t)kws->bbuflen) { + /* Check if existing buffer size is big enough already */ + if (need + blen > (ks_ssize_t)kws->bbuflen) { void *tmp; - /* must be a sum of the size already written to the body (blen) plus the size to be written (kws->plen) */ - kws->bbuflen = blen + kws->plen; /* total size */ - - /* and 1 more for NULL term */ - kws->bbuflen++; + /* Increase allocated buffer size by difference needed including extra NULL byte */ + kws->bbuflen += need + 1; if (kws->payload_size_max && kws->bbuflen > kws->payload_size_max) { /* size limit */ From a3b58f070113fc02c397dc66ca2a507681c7c53e Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Thu, 19 Oct 2023 17:54:31 +0300 Subject: [PATCH 04/30] send WSOC_CLOSE when closing websocket connection (per protocol). --- src/include/libks/kws.h | 2 ++ src/kws.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/include/libks/kws.h b/src/include/libks/kws.h index 832acf8..fe8c681 100644 --- a/src/include/libks/kws.h +++ b/src/include/libks/kws.h @@ -35,6 +35,8 @@ typedef enum { WS_DATA_TOO_BIG = 1009 } kws_cause_t; +#define WS_NORMAL_CLOSE 1000 + typedef enum { WSOC_CONTINUATION = 0x0, WSOC_TEXT = 0x1, diff --git a/src/kws.c b/src/kws.c index 1bbb26f..71841aa 100644 --- a/src/kws.c +++ b/src/kws.c @@ -1037,12 +1037,17 @@ KS_DECLARE(ks_ssize_t) kws_close(kws_t *kws, int16_t reason) kws->uri = NULL; } - if (reason && kws->sock != KS_SOCK_INVALID) { + if (kws->handshake && kws->sock != KS_SOCK_INVALID) { uint16_t *u16; uint8_t fr[4] = {WSOC_CLOSE | 0x80, 2, 0}; u16 = (uint16_t *) &fr[2]; - *u16 = htons((int16_t)reason); + if (reason) { + *u16 = htons((int16_t)reason); + } else { + *u16 = htons((int16_t)WS_NORMAL_CLOSE); /* regular close initiated by us */ + } + kws_raw_write(kws, fr, 4); } From 9e84c34d51d6a4b54b692850e2f15a85009b8e99 Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Mon, 23 Oct 2023 02:32:00 +0300 Subject: [PATCH 05/30] set mask and use the masking key for the WSOC_CLOSE Reason (per protocol). (#173) * set mask and use the masking key for the WSOC_CLOSE Reason (per protocol). * only mask from client to server (per protocol). --- src/kws.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/kws.c b/src/kws.c index 71841aa..da2b0f3 100644 --- a/src/kws.c +++ b/src/kws.c @@ -1039,16 +1039,32 @@ KS_DECLARE(ks_ssize_t) kws_close(kws_t *kws, int16_t reason) if (kws->handshake && kws->sock != KS_SOCK_INVALID) { uint16_t *u16; - uint8_t fr[4] = {WSOC_CLOSE | 0x80, 2, 0}; + int16_t got_reason = reason ? reason : WS_NORMAL_CLOSE /* regular close initiated by us */; - u16 = (uint16_t *) &fr[2]; - if (reason) { - *u16 = htons((int16_t)reason); + if (kws->type == KWS_CLIENT) { + const uint8_t maskb = 0x80; + uint8_t size = 0x02, fr[8] = {WSOC_CLOSE | 0x80, size | maskb, 0, 0, 0, 0, 0, 0}, masking_key[4], i; + uint8_t *p; + + u16 = (uint16_t *) &fr[6]; + *u16 = htons((int16_t)got_reason); + p = (uint8_t *)u16; /*use p for masking the reason which is the payload */ + + gen_nonce(masking_key, 4); + memcpy((uint8_t *)fr + 2, &masking_key, 4); + + for (i = 0; i < size; i++) { + *(p + i) = (*((uint8_t *)p + i)) ^ (*(masking_key + (i % 4))); + } + + kws_raw_write(kws, fr, 8); } else { - *u16 = htons((int16_t)WS_NORMAL_CLOSE); /* regular close initiated by us */ - } + uint8_t fr[4] = {WSOC_CLOSE | 0x80, 2, 0}; - kws_raw_write(kws, fr, 4); + u16 = (uint16_t *) &fr[2]; + *u16 = htons((int16_t)got_reason); + kws_raw_write(kws, fr, 4); + } } if (kws->ssl && kws->sock != KS_SOCK_INVALID) { From fff36c6530d68da4d4a2328aa1a5b0c3c6604ec3 Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Thu, 2 Nov 2023 11:52:22 +0000 Subject: [PATCH 06/30] Make SSL shutdown procedure strict to openssl documentation. --- src/kws.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 8 deletions(-) diff --git a/src/kws.c b/src/kws.c index da2b0f3..dd87b78 100644 --- a/src/kws.c +++ b/src/kws.c @@ -28,7 +28,8 @@ #pragma warning(disable: 4706) #endif -#define WS_BLOCK 1 +#define WS_BLOCK 10000 /* ms, blocks read operation for 10 seconds */ +#define WS_SOFT_BLOCK 1000 /* ms, blocks read operation for 1 second */ #define WS_NOBLOCK 0 #define WS_INIT_SANITY 5000 @@ -70,6 +71,7 @@ struct kws_s { char cipher_name[128]; kws_flag_t flags; int x; + int ssl_io_error; void *write_buffer; ks_size_t write_buffer_len; char *req_uri; @@ -397,12 +399,14 @@ static int ws_server_handshake(kws_t *kws) } +#define SSL_IO_ERROR(err) (err == SSL_ERROR_SYSCALL || err == SSL_ERROR_SSL) #define SSL_ERROR_WANT_READ_WRITE(err) (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) KS_DECLARE(ks_ssize_t) kws_raw_read(kws_t *kws, void *data, ks_size_t bytes, int block) { int r; int ssl_err = 0; + int block_n = block / 10; if (kws->unprocessed_buffer_len > 0) { if (kws->unprocessed_buffer_len > bytes) { @@ -430,6 +434,9 @@ KS_DECLARE(ks_ssize_t) kws_raw_read(kws_t *kws, void *data, ks_size_t bytes, int ssl_err = SSL_get_error(kws->ssl, r); if (ssl_err != SSL_ERROR_ZERO_RETURN) { ks_log(KS_LOG_WARNING, "Weird SSL_read error: %d\n", ssl_err); + if (SSL_IO_ERROR(ssl_err)) { + kws->ssl_io_error = 1; + } } } @@ -444,12 +451,16 @@ KS_DECLARE(ks_ssize_t) kws_raw_read(kws_t *kws, void *data, ks_size_t bytes, int kws->x++; ks_sleep_ms(10); } else { + if (SSL_IO_ERROR(ssl_err)) { + kws->ssl_io_error = 1; + } + r = -1; goto end; } } - } while (r < 0 && SSL_ERROR_WANT_READ_WRITE(ssl_err) && kws->x < 1000); + } while (r < 0 && SSL_ERROR_WANT_READ_WRITE(ssl_err) && kws->x < block_n); goto end; } @@ -468,11 +479,11 @@ KS_DECLARE(ks_ssize_t) kws_raw_read(kws_t *kws, void *data, ks_size_t bytes, int ks_sleep_ms(10); } } - } while (r == -1 && ks_errno_is_blocking(ks_errno()) && kws->x < 1000); + } while (r == -1 && ks_errno_is_blocking(ks_errno()) && kws->x < block_n); end: - if (kws->x >= 10000 || (block && kws->x >= 1000)) { + if (kws->x >= 10000 || (block && kws->x >= block_n)) { r = -1; } @@ -555,6 +566,11 @@ KS_DECLARE(ks_ssize_t) kws_raw_write(kws_t *kws, void *data, ks_size_t bytes) r = SSL_write(kws->ssl, (void *)((unsigned char *)data + wrote), (int)(bytes - wrote)); if (r == 0) { + ssl_err = SSL_get_error(kws->ssl, r); + if (SSL_IO_ERROR(ssl_err)) { + kws->ssl_io_error = 1; + } + ssl_err = 42; break; } @@ -573,6 +589,7 @@ KS_DECLARE(ks_ssize_t) kws_raw_write(kws_t *kws, void *data, ks_size_t bytes) ms = 25; } } + ks_sleep_ms(ms); } @@ -580,8 +597,13 @@ KS_DECLARE(ks_ssize_t) kws_raw_write(kws_t *kws, void *data, ks_size_t bytes) ssl_err = SSL_get_error(kws->ssl, r); if (!SSL_ERROR_WANT_READ_WRITE(ssl_err)) { + if (SSL_IO_ERROR(ssl_err)) { + kws->ssl_io_error = 1; + } + break; } + ssl_err = 0; } @@ -873,7 +895,7 @@ KS_DECLARE(ks_status_t) kws_init_ex(kws_t **kwsP, ks_socket_t sock, SSL_CTX *ssl kws->payload_size_max = ks_json_get_object_number_int(params, "payload_size_max", 0); if ((flags & KWS_BLOCK)) { - kws->block = 1; + kws->block = WS_BLOCK; } if (client_data) { @@ -1068,17 +1090,78 @@ KS_DECLARE(ks_ssize_t) kws_close(kws_t *kws, int16_t reason) } if (kws->ssl && kws->sock != KS_SOCK_INVALID) { - /* first invocation of SSL_shutdown() would normally return 0 and just try to send SSL protocol close request. + /* first invocation of SSL_shutdown() would normally return 0 and just try to send SSL protocol close request (close_notify_alert). we just slightly polite, since we want to close socket fast and not bother waiting for SSL protocol close response before closing socket, since we want cleanup to be done fast for scenarios like: client change NAT (like jump from one WiFi to another) and now unreachable from old ip:port, however immidiately reconnect with new ip:port but old session id (and thus should replace the old session/channel) + However it is recommended to do bidirectional shutdown + and also to read all the remaining data sent by the client + before it indicates EOF (SSL_ERROR_ZERO_RETURN). + To avoid stuck in this process in case of dead peers, + we wait for WS_SOFT_BLOCK time (1s) before we give up. */ - ERR_clear_error(); - SSL_shutdown(kws->ssl); + int code = 0, rcode = 0; + int ssl_error = 0; + int n = 0, block_n = WS_SOFT_BLOCK / 10; + + /* SSL layer was never established or underlying IO error occured */ + if (!kws->secure_established || kws->ssl_io_error) { + goto end; + } + + /* connection has been already closed */ + if (SSL_get_shutdown(kws->ssl) & SSL_SENT_SHUTDOWN) { + goto end; + } + + /* peer closes the connection */ + if (SSL_get_shutdown(kws->ssl) & SSL_RECEIVED_SHUTDOWN) { + ERR_clear_error(); + SSL_shutdown(kws->ssl); + goto end; + } + + /* us closes the connection. We do bidirection shutdown handshake */ + for(;;) { + ERR_clear_error(); + code = SSL_shutdown(kws->ssl); + ssl_error = SSL_get_error(kws->ssl, code); + if (code <= 0 && ssl_error == SSL_ERROR_WANT_READ) { + /* need to make sure there are no more data to read */ + for(;;) { + ERR_clear_error(); + if ((rcode = SSL_read(kws->ssl, kws->buffer, 9)) <= 0) { + ssl_error = SSL_get_error(kws->ssl, rcode); + if (ssl_error == SSL_ERROR_ZERO_RETURN) { + break; + } else if (SSL_IO_ERROR(ssl_error)) { + goto end; + } else if (ssl_error == SSL_ERROR_WANT_READ) { + if (++n == block_n) { + goto end; + } + + ks_sleep_ms(10); + } else { + goto end; + } + } + } + } else if (code == 0 || (code < 0 && ssl_error == SSL_ERROR_WANT_WRITE)) { + if (++n == block_n) { + goto end; + } + + ks_sleep_ms(10); + } else { /* code != 0 */ + goto end; + } + } } + end: /* restore to blocking here, so any further read/writes will block */ restore_socket(kws->sock); From d5a6be05bfd49545cb0843eddf49fa41edd0ff02 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Tue, 7 Nov 2023 16:35:49 +0300 Subject: [PATCH 07/30] Bump version to 2.0.3 --- CMakeLists.txt | 2 +- src/include/libks/ks.h | 4 ++-- win/libks-version.props | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01a4ff7..1184b7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if (KS_PLAT_WIN OR WITH_KS_TEST) endif() # Declare our project, libks2 -project(LibKS2 VERSION 2.0.2 LANGUAGES C CXX) +project(LibKS2 VERSION 2.0.3 LANGUAGES C CXX) message("LibKS2 Version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") # Set package version diff --git a/src/include/libks/ks.h b/src/include/libks/ks.h index e5a015b..ca64892 100644 --- a/src/include/libks/ks.h +++ b/src/include/libks/ks.h @@ -30,10 +30,10 @@ #endif /* libks version as a string */ -#define KS_VERSION "2.0.2" +#define KS_VERSION "2.0.3" /* libks version as a number */ -#define KS_VERSION_NUM 20002 +#define KS_VERSION_NUM 20003 /* Use this to allow enabling TCP_KEEPIDLE and TCP_KEEPINTVL socket options */ //#define KS_KEEP_IDLE_INTVL 1 diff --git a/win/libks-version.props b/win/libks-version.props index ef72326..ce8ea5d 100644 --- a/win/libks-version.props +++ b/win/libks-version.props @@ -4,7 +4,7 @@ - 2.0.2 + 2.0.3 0 $(BaseDir)../ From 188ca1fb0c10be54f566a99b0f37bdecf23d7443 Mon Sep 17 00:00:00 2001 From: chucongqing Date: Fri, 10 Nov 2023 00:33:35 -0800 Subject: [PATCH 08/30] fix playload unmask overflow --- src/kws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kws.c b/src/kws.c index 162c3b2..973e746 100644 --- a/src/kws.c +++ b/src/kws.c @@ -1482,7 +1482,7 @@ KS_DECLARE(ks_ssize_t) kws_read_frame(kws_t *kws, kws_opcode_t *oc, uint8_t **da if (mask && maskp) { ks_ssize_t i; - for (i = 0; i < kws->datalen; i++) { + for (i = 0; i < kws->plen; i++) { kws->body[i] ^= maskp[i % 4]; } } From 432a75739bc83c42640a1fca9ed2029b487cc6fc Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 10 Jan 2024 00:04:30 +0300 Subject: [PATCH 09/30] Revert "maybe fix, at least doesn't crash" --- src/kws.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kws.c b/src/kws.c index 973e746..19e6bd7 100644 --- a/src/kws.c +++ b/src/kws.c @@ -1432,12 +1432,14 @@ KS_DECLARE(ks_ssize_t) kws_read_frame(kws_t *kws, kws_opcode_t *oc, uint8_t **da blen = (int)(kws->body - kws->bbuffer); /* The bbuffer for the body of the message should always be 1 larger than the total size (for null term) */ - /* Check if existing buffer size is big enough already */ - if (need + blen > (ks_ssize_t)kws->bbuflen) { + if (blen + kws->plen >= (ks_ssize_t)kws->bbuflen) { void *tmp; - /* Increase allocated buffer size by difference needed including extra NULL byte */ - kws->bbuflen += need + 1; + /* must be a sum of the size already written to the body (blen) plus the size to be written (kws->plen) */ + kws->bbuflen = blen + kws->plen; /* total size */ + + /* and 1 more for NULL term */ + kws->bbuflen++; if (kws->payload_size_max && kws->bbuflen > kws->payload_size_max) { /* size limit */ From cf6a7f138687457795e4a10493e3eb6c5249ab9c Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 10 Jan 2024 00:58:22 +0300 Subject: [PATCH 10/30] Fix build of unit-tests on Windows. --- tests/testwebsock2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/testwebsock2.c b/tests/testwebsock2.c index ae6ca86..872df22 100644 --- a/tests/testwebsock2.c +++ b/tests/testwebsock2.c @@ -164,8 +164,8 @@ static ssize_t append_text_frame(void *bp) } memcpy(bp, (void *) &hdr[0], hlen); - memcpy(bp + hlen, data, bytes); - *(uint8_t *)(bp + hlen + bytes) = '\0'; + memcpy((unsigned char *)bp + hlen, data, bytes); + *(uint8_t *)((unsigned char *)bp + hlen + bytes) = '\0'; return hlen + bytes; } @@ -247,7 +247,6 @@ static void start_tcp_server_and_test_ws(char *ip) { ks_thread_t *thread_p = NULL; ks_pool_t *pool; - ks_sockaddr_t addr; int family = AF_INET; ks_socket_t cl_sock = KS_SOCK_INVALID; char buf[8192] = ""; @@ -302,7 +301,6 @@ static int test_ws(char *url) ks_pool_t *pool; kws_opcode_t oc; uint8_t *rdata; - ks_ssize_t ret; ks_json_t *req = ks_json_create_object(); ks_json_add_string_to_object(req, "url", url); From 52643ee62a072b4390214d3c60b49d68f1377c57 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 10 Jan 2024 01:01:41 +0300 Subject: [PATCH 11/30] WebSockets: move assert out of the loop in kws_read_frame() --- src/kws.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kws.c b/src/kws.c index 19e6bd7..71ab949 100644 --- a/src/kws.c +++ b/src/kws.c @@ -1465,8 +1465,9 @@ KS_DECLARE(ks_ssize_t) kws_read_frame(kws_t *kws, kws_opcode_t *oc, uint8_t **da memcpy(kws->body, kws->payload, kws->rplen); } + ks_assert((kws->body + kws->plen) <= (kws->bbuffer + kws->bbuflen)); + while(need) { - ks_assert((kws->body + need + kws->rplen) <= (kws->bbuffer + kws->bbuflen)); ks_ssize_t r = kws_string_read(kws, kws->body + kws->rplen, need + 1, WS_BLOCK); if (r < 1) { From bef765cca617c29de4098453a69fc9d3e3a34f84 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Tue, 23 Jan 2024 00:00:15 +0100 Subject: [PATCH 12/30] GHA: Add build and publish DEBs workflow. --- .github/workflows/build.yml | 137 ++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..296bede --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,137 @@ +name: Build and Distribute + +on: + # pull_request: + push: + branches: [ master ] + paths: + - "**" + - "!debian/changelog" + workflow_dispatch: + +concurrency: + group: ${{ github.head_ref || github.ref }} + +jobs: + build_deb: + name: 'Build DEB' + uses: signalwire/actions-template/.github/workflows/ci-deb-packages-v2.yml@main + strategy: + fail-fast: false + matrix: + codename: + - bookworm + - bullseye + - buster + - stretch + platform: + - amd64 + with: + PROJECT_NAME: libks + RUNNER: ubuntu-latest + BASE_IMAGE: signalwire/build-deb-action + DISTRO_CODENAME: ${{ matrix.codename }} + PLATFORM: ${{ matrix.platform }} + USE_CMAKE: true + CMAKE_BUILD_TYPE: 'Debug' + + generate_meta_deb: + name: 'Meta DEB' + needs: [ build_deb ] + strategy: + matrix: + os: + - deb + codename: + - bookworm + - bullseye + - buster + - stretch + platform: + - amd64 + uses: signalwire/actions-template/.github/workflows/ci-libs-metadata-v2.yml@main + with: + ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact + OS_PLATFORM: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }} + RUNNER: ubuntu-latest + FILE_PATH_PREFIX: /var/www/libks-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} + + distribute_matrix_deb: + permissions: write-all + name: 'Copy to remote DEB' + needs: [ build_deb ] + strategy: + matrix: + os: + - deb + codename: + - bookworm + - bullseye + - buster + - stretch + platform: + - amd64 + uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main + with: + ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact + TARGET_FOLDER: /var/www/libks-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} + RUNNER: ubuntu-latest + FILES: '*.tar.gz' + CREATE_DESTINATION_FOLDERS: true + secrets: + # Explicit define secrets for better understanding but it could be just inherit + PROXY_URL: ${{ secrets.PROXY_URL }} + USERNAME: ${{ secrets.USERNAME }} + HOSTNAME: ${{ secrets.HOSTNAME }} + TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} + + distribute_meta_deb: + permissions: write-all + name: 'Copy meta to remote DEB' + needs: [ generate_meta_deb ] + strategy: + max-parallel: 1 + matrix: + os: + - deb + codename: + - bookworm + - bullseye + - buster + - stretch + platform: + - amd64 + uses: signalwire/actions-template/.github/workflows/cd-libs-metadata.yml@main + with: + ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-meta + LIB_NAME: libks + TARGET_OS: ${{ matrix.os }} + TARGET_PLATFORM: ${{ matrix.platform }} + RUNNER: ubuntu-latest + TARGET_REPO: signalwire/bamboo_gha_trigger + secrets: + GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} + concurrency: + group: libks-${{ matrix.os }}-${{ matrix.platform }} + cancel-in-progress: true + + distribute_hash_deb: + permissions: write-all + name: 'Copy hash to remote DEB' + needs: [ distribute_meta_deb ] + uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main + strategy: + matrix: + os: + - deb + platform: + - amd64 + with: + RUNNER: ubuntu-latest + CREATE_DESTINATION_FOLDERS: false + EXEC_COMMANDS: 'echo "${{ github.sha }}" > /var/www/libks-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }}/hash.txt' + secrets: + PROXY_URL: ${{ secrets.PROXY_URL }} + USERNAME: ${{ secrets.USERNAME }} + HOSTNAME: ${{ secrets.HOSTNAME }} + TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} From bc43a5810b1f131653b498e8f15162655af976d4 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Thu, 25 Jan 2024 17:36:03 +0100 Subject: [PATCH 13/30] GHA: Use branch name in metarepo branch naming. --- .github/workflows/build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 296bede..d8d7f28 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: Build and Distribute on: - # pull_request: + pull_request: push: branches: [ master ] paths: @@ -36,6 +36,7 @@ jobs: CMAKE_BUILD_TYPE: 'Debug' generate_meta_deb: + if: (github.ref_type == 'branch' && github.base_ref == '') name: 'Meta DEB' needs: [ build_deb ] strategy: @@ -54,9 +55,10 @@ jobs: ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact OS_PLATFORM: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }} RUNNER: ubuntu-latest - FILE_PATH_PREFIX: /var/www/libks-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} + FILE_PATH_PREFIX: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} distribute_matrix_deb: + if: (github.ref_type == 'branch' && github.base_ref == '') permissions: write-all name: 'Copy to remote DEB' needs: [ build_deb ] @@ -74,7 +76,7 @@ jobs: uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main with: ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact - TARGET_FOLDER: /var/www/libks-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} + TARGET_FOLDER: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} RUNNER: ubuntu-latest FILES: '*.tar.gz' CREATE_DESTINATION_FOLDERS: true @@ -86,6 +88,7 @@ jobs: TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} distribute_meta_deb: + if: (github.ref_type == 'branch' && github.base_ref == '') permissions: write-all name: 'Copy meta to remote DEB' needs: [ generate_meta_deb ] @@ -116,6 +119,7 @@ jobs: cancel-in-progress: true distribute_hash_deb: + if: (github.ref_type == 'branch' && github.base_ref == '') permissions: write-all name: 'Copy hash to remote DEB' needs: [ distribute_meta_deb ] @@ -129,7 +133,7 @@ jobs: with: RUNNER: ubuntu-latest CREATE_DESTINATION_FOLDERS: false - EXEC_COMMANDS: 'echo "${{ github.sha }}" > /var/www/libks-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }}/hash.txt' + EXEC_COMMANDS: 'echo "${{ github.sha }}" > /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }}/hash.txt' secrets: PROXY_URL: ${{ secrets.PROXY_URL }} USERNAME: ${{ secrets.USERNAME }} From fd5299b0ea5240fe158eb9cdf558dcaa4abe645f Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Thu, 25 Jan 2024 19:05:26 +0100 Subject: [PATCH 14/30] GHA: Set source branch name variable. --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8d7f28..c46c829 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,6 +108,7 @@ jobs: with: ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-meta LIB_NAME: libks + SOURCE_BRANCH: ${{ github.ref_name }} TARGET_OS: ${{ matrix.os }} TARGET_PLATFORM: ${{ matrix.platform }} RUNNER: ubuntu-latest From 1f26381e1e1adfa9e0c9c6fc526d517b52d56557 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Thu, 25 Jan 2024 21:38:08 +0100 Subject: [PATCH 15/30] GHA: Trigger build workflow in `release` branch also. --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c46c829..9a38f1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,9 @@ name: Build and Distribute on: pull_request: push: - branches: [ master ] + branches: + - release + - master paths: - "**" - "!debian/changelog" From a896ee9ba18e908c28899e2daa7d2d1bae6f35c6 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Fri, 26 Jan 2024 14:25:33 +0100 Subject: [PATCH 16/30] GHA: Add DEB armhf support. --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a38f1e..abc084a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,7 @@ jobs: - stretch platform: - amd64 + - armhf with: PROJECT_NAME: libks RUNNER: ubuntu-latest @@ -52,6 +53,7 @@ jobs: - stretch platform: - amd64 + - armhf uses: signalwire/actions-template/.github/workflows/ci-libs-metadata-v2.yml@main with: ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact @@ -75,6 +77,7 @@ jobs: - stretch platform: - amd64 + - armhf uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main with: ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact @@ -106,6 +109,7 @@ jobs: - stretch platform: - amd64 + - armhf uses: signalwire/actions-template/.github/workflows/cd-libs-metadata.yml@main with: ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-meta @@ -133,6 +137,7 @@ jobs: - deb platform: - amd64 + - armhf with: RUNNER: ubuntu-latest CREATE_DESTINATION_FOLDERS: false From 86269ec7f184ab640674ed048b5984d53b9b3836 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Fri, 26 Jan 2024 17:57:42 +0100 Subject: [PATCH 17/30] [GHA] Add support for building RPMs using GHA. --- .github/workflows/build.yml | 103 ++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abc084a..4cd6609 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,18 @@ concurrency: group: ${{ github.head_ref || github.ref }} jobs: + build_rpm: + name: 'Build RPM' + uses: signalwire/actions-template/.github/workflows/ci-rpm-packages.yml@main + with: + PROJECT_NAME: libks + RUNNER: ubuntu-latest + PACKAGER: 'packager Andrey Volk ' + PLATFORM: amd64 + USE_CMAKE: true + CMAKE_BUILD_TYPE: 'Debug' + secrets: inherit + build_deb: name: 'Build DEB' uses: signalwire/actions-template/.github/workflows/ci-deb-packages-v2.yml@main @@ -38,6 +50,23 @@ jobs: USE_CMAKE: true CMAKE_BUILD_TYPE: 'Debug' + generate_meta_rpm: + if: (github.ref_type == 'branch' && github.base_ref == '') + name: 'Meta RPM' + needs: [ build_rpm ] + strategy: + matrix: + os: + - rpm + platform: + - amd64 + uses: signalwire/actions-template/.github/workflows/ci-libs-metadata-v2.yml@main + with: + ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.platform }}-artifact + OS_PLATFORM: ${{ matrix.os }}-${{ matrix.platform }} + RUNNER: ubuntu-latest + FILE_PATH_PREFIX: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} + generate_meta_deb: if: (github.ref_type == 'branch' && github.base_ref == '') name: 'Meta DEB' @@ -61,6 +90,31 @@ jobs: RUNNER: ubuntu-latest FILE_PATH_PREFIX: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} + distribute_matrix_rpm: + if: (github.ref_type == 'branch' && github.base_ref == '') + permissions: write-all + name: 'Copy to remote RPM' + needs: [ build_rpm ] + strategy: + matrix: + os: + - rpm + platform: + - amd64 + uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main + with: + ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.platform }}-artifact + TARGET_FOLDER: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} + RUNNER: ubuntu-latest + FILES: '*.tar.gz' + CREATE_DESTINATION_FOLDERS: true + secrets: + # Explicit define secrets for better understanding but it could be just inherit + PROXY_URL: ${{ secrets.PROXY_URL }} + USERNAME: ${{ secrets.USERNAME }} + HOSTNAME: ${{ secrets.HOSTNAME }} + TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} + distribute_matrix_deb: if: (github.ref_type == 'branch' && github.base_ref == '') permissions: write-all @@ -92,6 +146,33 @@ jobs: HOSTNAME: ${{ secrets.HOSTNAME }} TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} + distribute_meta_rpm: + if: (github.ref_type == 'branch' && github.base_ref == '') + permissions: write-all + name: 'Copy meta to remote RPM' + needs: [ generate_meta_rpm ] + strategy: + max-parallel: 1 + matrix: + os: + - rpm + platform: + - amd64 + uses: signalwire/actions-template/.github/workflows/cd-libs-metadata.yml@main + with: + ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.platform }}-meta + LIB_NAME: sofia-sip + SOURCE_BRANCH: ${{ github.ref_name }} + TARGET_OS: ${{ matrix.os }} + TARGET_PLATFORM: ${{ matrix.platform }} + RUNNER: ubuntu-latest + TARGET_REPO: signalwire/bamboo_gha_trigger + secrets: + GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} + concurrency: + group: libks-${{ matrix.os }}-${{ matrix.platform }} + cancel-in-progress: false + distribute_meta_deb: if: (github.ref_type == 'branch' && github.base_ref == '') permissions: write-all @@ -125,6 +206,28 @@ jobs: group: libks-${{ matrix.os }}-${{ matrix.platform }} cancel-in-progress: true + distribute_hash_rpm: + if: (github.ref_type == 'branch' && github.base_ref == '') + permissions: write-all + name: 'Copy hash to remote RPM' + needs: [ distribute_meta_rpm ] + uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main + strategy: + matrix: + os: + - rpm + platform: + - amd64 + with: + RUNNER: ubuntu-latest + CREATE_DESTINATION_FOLDERS: false + EXEC_COMMANDS: 'echo "${{ github.sha }}" > /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }}/hash.txt' + secrets: + PROXY_URL: ${{ secrets.PROXY_URL }} + USERNAME: ${{ secrets.USERNAME }} + HOSTNAME: ${{ secrets.HOSTNAME }} + TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} + distribute_hash_deb: if: (github.ref_type == 'branch' && github.base_ref == '') permissions: write-all From 9b8a09ec4aec56389305e7792fa905a27ea810c8 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Tue, 30 Jan 2024 19:43:56 +0100 Subject: [PATCH 18/30] GHA: Fix invalid LIB_NAME value name. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4cd6609..2b8a0ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -161,7 +161,7 @@ jobs: uses: signalwire/actions-template/.github/workflows/cd-libs-metadata.yml@main with: ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.platform }}-meta - LIB_NAME: sofia-sip + LIB_NAME: libks SOURCE_BRANCH: ${{ github.ref_name }} TARGET_OS: ${{ matrix.os }} TARGET_PLATFORM: ${{ matrix.platform }} From de9b4cd1842f68141795abadf8da755fdd2125b4 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Fri, 16 Feb 2024 22:54:04 +0300 Subject: [PATCH 19/30] Bump version to 2.0.4 --- CMakeLists.txt | 2 +- src/include/libks/ks.h | 4 ++-- win/libks-version.props | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1184b7f..29c190a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if (KS_PLAT_WIN OR WITH_KS_TEST) endif() # Declare our project, libks2 -project(LibKS2 VERSION 2.0.3 LANGUAGES C CXX) +project(LibKS2 VERSION 2.0.4 LANGUAGES C CXX) message("LibKS2 Version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") # Set package version diff --git a/src/include/libks/ks.h b/src/include/libks/ks.h index ca64892..935bf5e 100644 --- a/src/include/libks/ks.h +++ b/src/include/libks/ks.h @@ -30,10 +30,10 @@ #endif /* libks version as a string */ -#define KS_VERSION "2.0.3" +#define KS_VERSION "2.0.4" /* libks version as a number */ -#define KS_VERSION_NUM 20003 +#define KS_VERSION_NUM 20004 /* Use this to allow enabling TCP_KEEPIDLE and TCP_KEEPINTVL socket options */ //#define KS_KEEP_IDLE_INTVL 1 diff --git a/win/libks-version.props b/win/libks-version.props index ce8ea5d..f376268 100644 --- a/win/libks-version.props +++ b/win/libks-version.props @@ -4,7 +4,7 @@ - 2.0.3 + 2.0.4 0 $(BaseDir)../ From 6713a0a35e78aa6b88e82a6a7b2afdc1430ea80c Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Tue, 20 Feb 2024 22:19:12 +0100 Subject: [PATCH 20/30] [cmake] Don't use CPACK_DEBIAN_PACKAGE_RELEASE, set CPACK_DEBIAN_PACKAGE_VERSION directly. --- CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29c190a..c130588 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,23 +260,24 @@ if("${CMAKE_OS_NAME}" STREQUAL "Debian") set(CHANGELOG_FOOTER " -- ${CPACK_DEBIAN_PACKAGE_MAINTAINER} ${RFC2822_TIMESTAMP}") endif() - # Set version release from environment variable + # Guess version release from environment variable + # (usage of CPACK_DEBIAN_PACKAGE_RELEASE breaks ability to set CPACK_DEBIAN_PACKAGE_VERSION properly) if (NOT "$ENV{PACKAGE_RELEASE}" STREQUAL "") - set(CPACK_DEBIAN_PACKAGE_RELEASE "$ENV{PACKAGE_RELEASE}") + set(PACKAGE_RELEASE "$ENV{PACKAGE_RELEASE}") else() if(DATE_CMD) execute_process(COMMAND ${DATE_CMD} +%Y%m%d OUTPUT_VARIABLE DATE_YMD) - set(CPACK_DEBIAN_PACKAGE_RELEASE ${DATE_YMD}) + set(PACKAGE_RELEASE ${DATE_YMD}) else() - set(CPACK_DEBIAN_PACKAGE_RELEASE "1") + set(PACKAGE_RELEASE "1") endif() endif() # Set package version - set(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}~${DISTRO_CODENAME}) + set(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION}-${PACKAGE_RELEASE}~${DISTRO_CODENAME}) # Set debian file name format - set(CPACK_DEBIAN_FILE_NAME "${PACKAGE_NAME}_${PROJECT_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${DISTRO_CODENAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") + set(CPACK_DEBIAN_FILE_NAME "${PACKAGE_NAME}_${PROJECT_VERSION}-${PACKAGE_RELEASE}_${DISTRO_CODENAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") # Set a Debian compliant changelog header set(CHANGELOG_HEADER "libks (${CPACK_DEBIAN_PACKAGE_VERSION}) ${DISTRO_CODENAME}\; urgency=${CPACK_DEBIAN_PACKAGE_PRIORITY}") @@ -328,6 +329,7 @@ if("${CMAKE_OS_NAME}" STREQUAL "Debian") else() message(WARNING "DEB Generator: Can't find git and/or gzip and/or date in your path. DEB packages will be missing changelog.Debian.gz.") endif() + endif() # Enable packaging module From aa54525e1b53596730fe64617ddc882ea12d3b5c Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Wed, 13 Mar 2024 16:17:26 +0200 Subject: [PATCH 21/30] Check ks buffer pointer overflow before dereferencing it. (#203) --- src/ks_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ks_buffer.c b/src/ks_buffer.c index 31d5857..03a0ed7 100644 --- a/src/ks_buffer.c +++ b/src/ks_buffer.c @@ -194,7 +194,7 @@ KS_DECLARE(ks_size_t) ks_buffer_packet_count(ks_buffer_t *buffer) e = (head + buffer->used); - for (p = head; p && *p && p < e; p++) { + for (p = head; p && p < e && *p; p++) { if (*p == '\n') { pe = p + 1; if (*pe == '\r') @@ -219,7 +219,7 @@ KS_DECLARE(ks_size_t) ks_buffer_read_packet(ks_buffer_t *buffer, void *data, ks_ e = (head + buffer->used); - for (p = head; p && *p && p < e; p++) { + for (p = head; p && p < e && *p; p++) { if (*p == '\n') { pe = p + 1; if (*pe == '\r') From 1a4fb7557d1ac1358cc2a4c7ee8d16a33222a6f1 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Tue, 9 Apr 2024 22:55:51 +0200 Subject: [PATCH 22/30] [GHA] Use `cicd-docker-build-and-distribute.yml`. --- .github/docker/centos/7/amd64/Dockerfile | 95 +++++++ .../docker/debian/bookworm/amd64/Dockerfile | 51 ++++ .../docker/debian/bookworm/arm32v7/Dockerfile | 51 ++++ .../docker/debian/bullseye/amd64/Dockerfile | 51 ++++ .../docker/debian/bullseye/arm32v7/Dockerfile | 51 ++++ .github/docker/debian/buster/amd64/Dockerfile | 51 ++++ .../docker/debian/buster/arm32v7/Dockerfile | 51 ++++ .github/workflows/build.yml | 252 ------------------ .github/workflows/cicd.yml | 99 +++++++ 9 files changed, 500 insertions(+), 252 deletions(-) create mode 100644 .github/docker/centos/7/amd64/Dockerfile create mode 100644 .github/docker/debian/bookworm/amd64/Dockerfile create mode 100644 .github/docker/debian/bookworm/arm32v7/Dockerfile create mode 100644 .github/docker/debian/bullseye/amd64/Dockerfile create mode 100644 .github/docker/debian/bullseye/arm32v7/Dockerfile create mode 100644 .github/docker/debian/buster/amd64/Dockerfile create mode 100644 .github/docker/debian/buster/arm32v7/Dockerfile delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/cicd.yml diff --git a/.github/docker/centos/7/amd64/Dockerfile b/.github/docker/centos/7/amd64/Dockerfile new file mode 100644 index 0000000..3c159c9 --- /dev/null +++ b/.github/docker/centos/7/amd64/Dockerfile @@ -0,0 +1,95 @@ +ARG BUILDER_IMAGE=centos:7.2.1511 + +FROM ${BUILDER_IMAGE} AS builder + +ARG MAINTAINER="Andrey Volk " +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} +ENV MAINTAINER=${MAINTAINER} + +RUN yum -y update && \ + yum install -y \ + audiofile-devel \ + autoconf \ + automake \ + bind-license \ + centos-release-scl \ + cyrus-sasl-lib \ + dbus \ + dbus-libs \ + devtoolset-9-gcc* \ + dos2unix \ + doxygen \ + dpkg-dev \ + dracut \ + epel-release \ + expat \ + gcc \ + gcc-c++ \ + git \ + glib2 \ + glib2-devel \ + gnupg2 \ + gzip \ + krb5-dxevel \ + libatomic \ + libcurl-devel \ + libtool \ + libuuid-devel \ + libxml2 \ + lksctp-tools-devel \ + lsb_release \ + make \ + multilib-rpm-config \ + openssl-devel \ + pkg-config \ + procps-ng \ + python \ + python-libs \ + rpm-build \ + rpmdevtools \ + scl-utils \ + sqlite \ + swig \ + unzip \ + uuid-devel \ + vim-minimal \ + wget \ + which \ + xz \ + xz-libs \ + yum-plugin-fastestmirror \ + yum-plugin-ovl \ + yum-utils \ + zlib-devel && \ + yum -y clean all + +ENV CMAKE_VERSION 3.22.2 + +RUN set -ex \ + && curl -kfsSLO --compressed https://cmake.org/files/v3.22/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz \ + && curl -kfsSLO --compressed https://cmake.org/files/v3.22/cmake-${CMAKE_VERSION}-SHA-256.txt \ + && grep "cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz\$" cmake-${CMAKE_VERSION}-SHA-256.txt | sha256sum -c - \ + && tar xzf cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz -C /usr/local --strip-components=1 --no-same-owner \ + && rm -rf cmake-${CMAKE_VERSION}* \ + && cmake --version + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR}/ +RUN cd ${DATA_DIR}/ && \ + git reset --hard HEAD && git clean -xfd && \ + cd ${DATA_DIR} + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.rpm OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/bookworm/amd64/Dockerfile b/.github/docker/debian/bookworm/amd64/Dockerfile new file mode 100644 index 0000000..5315c23 --- /dev/null +++ b/.github/docker/debian/bookworm/amd64/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=debian:bookworm +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/bookworm/arm32v7/Dockerfile b/.github/docker/debian/bookworm/arm32v7/Dockerfile new file mode 100644 index 0000000..4b7242e --- /dev/null +++ b/.github/docker/debian/bookworm/arm32v7/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=arm32v7/debian:bookworm +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/bullseye/amd64/Dockerfile b/.github/docker/debian/bullseye/amd64/Dockerfile new file mode 100644 index 0000000..3c7e3db --- /dev/null +++ b/.github/docker/debian/bullseye/amd64/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=debian:bullseye +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/bullseye/arm32v7/Dockerfile b/.github/docker/debian/bullseye/arm32v7/Dockerfile new file mode 100644 index 0000000..af0d27f --- /dev/null +++ b/.github/docker/debian/bullseye/arm32v7/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=arm32v7/debian:bullseye +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/buster/amd64/Dockerfile b/.github/docker/debian/buster/amd64/Dockerfile new file mode 100644 index 0000000..103b778 --- /dev/null +++ b/.github/docker/debian/buster/amd64/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=debian:buster +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/buster/arm32v7/Dockerfile b/.github/docker/debian/buster/arm32v7/Dockerfile new file mode 100644 index 0000000..5d90822 --- /dev/null +++ b/.github/docker/debian/buster/arm32v7/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=arm32v7/debian:buster +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 2b8a0ef..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,252 +0,0 @@ -name: Build and Distribute - -on: - pull_request: - push: - branches: - - release - - master - paths: - - "**" - - "!debian/changelog" - workflow_dispatch: - -concurrency: - group: ${{ github.head_ref || github.ref }} - -jobs: - build_rpm: - name: 'Build RPM' - uses: signalwire/actions-template/.github/workflows/ci-rpm-packages.yml@main - with: - PROJECT_NAME: libks - RUNNER: ubuntu-latest - PACKAGER: 'packager Andrey Volk ' - PLATFORM: amd64 - USE_CMAKE: true - CMAKE_BUILD_TYPE: 'Debug' - secrets: inherit - - build_deb: - name: 'Build DEB' - uses: signalwire/actions-template/.github/workflows/ci-deb-packages-v2.yml@main - strategy: - fail-fast: false - matrix: - codename: - - bookworm - - bullseye - - buster - - stretch - platform: - - amd64 - - armhf - with: - PROJECT_NAME: libks - RUNNER: ubuntu-latest - BASE_IMAGE: signalwire/build-deb-action - DISTRO_CODENAME: ${{ matrix.codename }} - PLATFORM: ${{ matrix.platform }} - USE_CMAKE: true - CMAKE_BUILD_TYPE: 'Debug' - - generate_meta_rpm: - if: (github.ref_type == 'branch' && github.base_ref == '') - name: 'Meta RPM' - needs: [ build_rpm ] - strategy: - matrix: - os: - - rpm - platform: - - amd64 - uses: signalwire/actions-template/.github/workflows/ci-libs-metadata-v2.yml@main - with: - ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.platform }}-artifact - OS_PLATFORM: ${{ matrix.os }}-${{ matrix.platform }} - RUNNER: ubuntu-latest - FILE_PATH_PREFIX: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} - - generate_meta_deb: - if: (github.ref_type == 'branch' && github.base_ref == '') - name: 'Meta DEB' - needs: [ build_deb ] - strategy: - matrix: - os: - - deb - codename: - - bookworm - - bullseye - - buster - - stretch - platform: - - amd64 - - armhf - uses: signalwire/actions-template/.github/workflows/ci-libs-metadata-v2.yml@main - with: - ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact - OS_PLATFORM: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }} - RUNNER: ubuntu-latest - FILE_PATH_PREFIX: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} - - distribute_matrix_rpm: - if: (github.ref_type == 'branch' && github.base_ref == '') - permissions: write-all - name: 'Copy to remote RPM' - needs: [ build_rpm ] - strategy: - matrix: - os: - - rpm - platform: - - amd64 - uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main - with: - ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.platform }}-artifact - TARGET_FOLDER: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} - RUNNER: ubuntu-latest - FILES: '*.tar.gz' - CREATE_DESTINATION_FOLDERS: true - secrets: - # Explicit define secrets for better understanding but it could be just inherit - PROXY_URL: ${{ secrets.PROXY_URL }} - USERNAME: ${{ secrets.USERNAME }} - HOSTNAME: ${{ secrets.HOSTNAME }} - TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} - - distribute_matrix_deb: - if: (github.ref_type == 'branch' && github.base_ref == '') - permissions: write-all - name: 'Copy to remote DEB' - needs: [ build_deb ] - strategy: - matrix: - os: - - deb - codename: - - bookworm - - bullseye - - buster - - stretch - platform: - - amd64 - - armhf - uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main - with: - ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-artifact - TARGET_FOLDER: /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }} - RUNNER: ubuntu-latest - FILES: '*.tar.gz' - CREATE_DESTINATION_FOLDERS: true - secrets: - # Explicit define secrets for better understanding but it could be just inherit - PROXY_URL: ${{ secrets.PROXY_URL }} - USERNAME: ${{ secrets.USERNAME }} - HOSTNAME: ${{ secrets.HOSTNAME }} - TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} - - distribute_meta_rpm: - if: (github.ref_type == 'branch' && github.base_ref == '') - permissions: write-all - name: 'Copy meta to remote RPM' - needs: [ generate_meta_rpm ] - strategy: - max-parallel: 1 - matrix: - os: - - rpm - platform: - - amd64 - uses: signalwire/actions-template/.github/workflows/cd-libs-metadata.yml@main - with: - ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.platform }}-meta - LIB_NAME: libks - SOURCE_BRANCH: ${{ github.ref_name }} - TARGET_OS: ${{ matrix.os }} - TARGET_PLATFORM: ${{ matrix.platform }} - RUNNER: ubuntu-latest - TARGET_REPO: signalwire/bamboo_gha_trigger - secrets: - GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} - concurrency: - group: libks-${{ matrix.os }}-${{ matrix.platform }} - cancel-in-progress: false - - distribute_meta_deb: - if: (github.ref_type == 'branch' && github.base_ref == '') - permissions: write-all - name: 'Copy meta to remote DEB' - needs: [ generate_meta_deb ] - strategy: - max-parallel: 1 - matrix: - os: - - deb - codename: - - bookworm - - bullseye - - buster - - stretch - platform: - - amd64 - - armhf - uses: signalwire/actions-template/.github/workflows/cd-libs-metadata.yml@main - with: - ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.codename }}-${{ matrix.platform }}-meta - LIB_NAME: libks - SOURCE_BRANCH: ${{ github.ref_name }} - TARGET_OS: ${{ matrix.os }} - TARGET_PLATFORM: ${{ matrix.platform }} - RUNNER: ubuntu-latest - TARGET_REPO: signalwire/bamboo_gha_trigger - secrets: - GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} - concurrency: - group: libks-${{ matrix.os }}-${{ matrix.platform }} - cancel-in-progress: true - - distribute_hash_rpm: - if: (github.ref_type == 'branch' && github.base_ref == '') - permissions: write-all - name: 'Copy hash to remote RPM' - needs: [ distribute_meta_rpm ] - uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main - strategy: - matrix: - os: - - rpm - platform: - - amd64 - with: - RUNNER: ubuntu-latest - CREATE_DESTINATION_FOLDERS: false - EXEC_COMMANDS: 'echo "${{ github.sha }}" > /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }}/hash.txt' - secrets: - PROXY_URL: ${{ secrets.PROXY_URL }} - USERNAME: ${{ secrets.USERNAME }} - HOSTNAME: ${{ secrets.HOSTNAME }} - TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} - - distribute_hash_deb: - if: (github.ref_type == 'branch' && github.base_ref == '') - permissions: write-all - name: 'Copy hash to remote DEB' - needs: [ distribute_meta_deb ] - uses: signalwire/actions-template/.github/workflows/cd-scp.yml@main - strategy: - matrix: - os: - - deb - platform: - - amd64 - - armhf - with: - RUNNER: ubuntu-latest - CREATE_DESTINATION_FOLDERS: false - EXEC_COMMANDS: 'echo "${{ github.sha }}" > /var/www/libks-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.platform }}/${{ github.run_id }}-${{ github.run_number }}/hash.txt' - secrets: - PROXY_URL: ${{ secrets.PROXY_URL }} - USERNAME: ${{ secrets.USERNAME }} - HOSTNAME: ${{ secrets.HOSTNAME }} - TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..4531fbb --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,99 @@ +name: Build and Distribute + +on: + pull_request: + push: + branches: + - release + - master + paths: + - "**" + workflow_dispatch: + +concurrency: + group: ${{ github.head_ref || github.ref }} + +jobs: + deb: + name: 'DEB' + permissions: + id-token: write + contents: read + uses: signalwire/actions-template/.github/workflows/cicd-docker-build-and-distribute.yml@main + strategy: + # max-parallel: 1 + fail-fast: false + matrix: + os: + - debian + version: + - bookworm + - bullseye + - buster + platform: + - name: amd64 + runner: ubuntu-latest + - name: arm32v7 + runner: ubuntu-latest + # exclude: + # - version: bookworm + # platform: + # name: arm32v7 + with: + RUNNER: ${{ matrix.platform.runner }} + ARTIFACTS_PATTERN: '.*\.(deb)$' + DOCKERFILE: .github/docker/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }}/Dockerfile + MAINTAINER: 'Andrey Volk ' + META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ matrix.os }}-${{ matrix.platform.name }}/${{ github.run_id }}-${{ github.run_number }} + META_REPO: signalwire/bamboo_gha_trigger + META_REPO_BRANCH: libks/${{ github.ref_name }}/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }} + PLATFORM: ${{ matrix.platform.name }} + # REPO_DOMAIN: freeswitch.signalwire.com + TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-artifact + UPLOAD_BUILD_ARTIFACTS: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }} + secrets: + GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} + HOSTNAME: ${{ secrets.HOSTNAME }} + PROXY_URL: ${{ secrets.PROXY_URL }} + USERNAME: ${{ secrets.USERNAME }} + TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} + # REPO_USERNAME: 'signalwire' + # REPO_PASSWORD: ${{ secrets.REPOTOKEN }} + + rpm: + name: 'RPM' + permissions: + id-token: write + contents: read + uses: signalwire/actions-template/.github/workflows/cicd-docker-build-and-distribute.yml@main + strategy: + # max-parallel: 1 + fail-fast: false + matrix: + os: + - centos + version: + - 7 + platform: + - name: amd64 + runner: ubuntu-latest + with: + RUNNER: ${{ matrix.platform.runner }} + ARTIFACTS_PATTERN: '.*\.(rpm)$' + DOCKERFILE: .github/docker/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }}/Dockerfile + MAINTAINER: 'Andrey Volk ' + META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ matrix.os }}-${{ matrix.platform.name }}/${{ github.run_id }}-${{ github.run_number }} + META_REPO: signalwire/bamboo_gha_trigger + META_REPO_BRANCH: libks/${{ github.ref_name }}/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }} + PLATFORM: ${{ matrix.platform.name }} + # REPO_DOMAIN: freeswitch.signalwire.com + TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-artifact + UPLOAD_BUILD_ARTIFACTS: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }} + secrets: + GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} + HOSTNAME: ${{ secrets.HOSTNAME }} + PROXY_URL: ${{ secrets.PROXY_URL }} + USERNAME: ${{ secrets.USERNAME }} + TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} + # REPO_USERNAME: ${{ secrets.FSAUSER }} + # REPO_PASSWORD: ${{ secrets.FSAPASS }} From 2c3cafbc0ff2b63e04ebaf9411fbb1aa76cbf683 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Thu, 11 Apr 2024 21:27:03 +0200 Subject: [PATCH 23/30] [GHA] Use `meta-repo-content` workflow. --- .github/workflows/cicd.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 4531fbb..f01e6bd 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -45,8 +45,6 @@ jobs: DOCKERFILE: .github/docker/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }}/Dockerfile MAINTAINER: 'Andrey Volk ' META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ matrix.os }}-${{ matrix.platform.name }}/${{ github.run_id }}-${{ github.run_number }} - META_REPO: signalwire/bamboo_gha_trigger - META_REPO_BRANCH: libks/${{ github.ref_name }}/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }} PLATFORM: ${{ matrix.platform.name }} # REPO_DOMAIN: freeswitch.signalwire.com TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-artifact @@ -83,8 +81,6 @@ jobs: DOCKERFILE: .github/docker/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }}/Dockerfile MAINTAINER: 'Andrey Volk ' META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ matrix.os }}-${{ matrix.platform.name }}/${{ github.run_id }}-${{ github.run_number }} - META_REPO: signalwire/bamboo_gha_trigger - META_REPO_BRANCH: libks/${{ github.ref_name }}/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }} PLATFORM: ${{ matrix.platform.name }} # REPO_DOMAIN: freeswitch.signalwire.com TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-artifact @@ -97,3 +93,20 @@ jobs: TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} # REPO_USERNAME: ${{ secrets.FSAUSER }} # REPO_PASSWORD: ${{ secrets.FSAPASS }} + + meta: + name: 'Publish build data to meta-repo' + if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }} + needs: + - deb + - rpm + permissions: + id-token: write + contents: read + uses: signalwire/actions-template/.github/workflows/meta-repo-content.yml@main + with: + META_CONTENT: '/var/www/libks/${{ github.ref_name }}/*/${{ github.run_id }}-${{ github.run_number }}' + META_REPO: signalwire/bamboo_gha_trigger + META_REPO_BRANCH: trigger/libks/${{ github.ref_name }} + secrets: + GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} From c1b967b40bd49e42424872636f02ff31e4af7bad Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Sun, 14 Apr 2024 16:06:16 +0200 Subject: [PATCH 24/30] [GHA] Shorten artifact path store location. --- .github/workflows/cicd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index f01e6bd..24d895a 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -44,7 +44,7 @@ jobs: ARTIFACTS_PATTERN: '.*\.(deb)$' DOCKERFILE: .github/docker/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }}/Dockerfile MAINTAINER: 'Andrey Volk ' - META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ matrix.os }}-${{ matrix.platform.name }}/${{ github.run_id }}-${{ github.run_number }} + META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ github.run_id }}-${{ github.run_number }} PLATFORM: ${{ matrix.platform.name }} # REPO_DOMAIN: freeswitch.signalwire.com TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-artifact @@ -80,7 +80,7 @@ jobs: ARTIFACTS_PATTERN: '.*\.(rpm)$' DOCKERFILE: .github/docker/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }}/Dockerfile MAINTAINER: 'Andrey Volk ' - META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ matrix.os }}-${{ matrix.platform.name }}/${{ github.run_id }}-${{ github.run_number }} + META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ github.run_id }}-${{ github.run_number }} PLATFORM: ${{ matrix.platform.name }} # REPO_DOMAIN: freeswitch.signalwire.com TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-artifact @@ -105,7 +105,7 @@ jobs: contents: read uses: signalwire/actions-template/.github/workflows/meta-repo-content.yml@main with: - META_CONTENT: '/var/www/libks/${{ github.ref_name }}/*/${{ github.run_id }}-${{ github.run_number }}' + META_CONTENT: '/var/www/libks/${{ github.ref_name }}/${{ github.run_id }}-${{ github.run_number }}' META_REPO: signalwire/bamboo_gha_trigger META_REPO_BRANCH: trigger/libks/${{ github.ref_name }} secrets: From 2661b49c74d6cc18620a2d5a80fa02dad50c0dd8 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Wed, 17 Apr 2024 00:41:33 +0200 Subject: [PATCH 25/30] [GHA] Add `arm64v8` build target. --- .../docker/debian/bookworm/arm64v8/Dockerfile | 51 +++++++++++++++++++ .../docker/debian/bullseye/arm64v8/Dockerfile | 51 +++++++++++++++++++ .../docker/debian/buster/arm64v8/Dockerfile | 51 +++++++++++++++++++ .github/workflows/cicd.yml | 2 + 4 files changed, 155 insertions(+) create mode 100644 .github/docker/debian/bookworm/arm64v8/Dockerfile create mode 100644 .github/docker/debian/bullseye/arm64v8/Dockerfile create mode 100644 .github/docker/debian/buster/arm64v8/Dockerfile diff --git a/.github/docker/debian/bookworm/arm64v8/Dockerfile b/.github/docker/debian/bookworm/arm64v8/Dockerfile new file mode 100644 index 0000000..c04a80d --- /dev/null +++ b/.github/docker/debian/bookworm/arm64v8/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=arm64v8/debian:bookworm +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/bullseye/arm64v8/Dockerfile b/.github/docker/debian/bullseye/arm64v8/Dockerfile new file mode 100644 index 0000000..27c7c36 --- /dev/null +++ b/.github/docker/debian/bullseye/arm64v8/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=arm64v8/debian:bullseye +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/buster/arm64v8/Dockerfile b/.github/docker/debian/buster/arm64v8/Dockerfile new file mode 100644 index 0000000..b7825d3 --- /dev/null +++ b/.github/docker/debian/buster/arm64v8/Dockerfile @@ -0,0 +1,51 @@ +ARG BUILDER_IMAGE=arm64v8/debian:buster +ARG MAINTAINER="Andrey Volk " + +FROM ${BUILDER_IMAGE} AS builder + +ARG BUILD_NUMBER=42 +ARG GIT_SHA=0000000000 + +MAINTAINER ${MAINTAINER} + +SHELL ["/bin/bash", "-c"] + +RUN apt-get -q update && \ + DEBIAN_FRONTEND=noninteractive apt-get -yq install \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + debhelper \ + devscripts \ + dh-autoreconf \ + dos2unix \ + doxygen \ + git \ + graphviz \ + libglib2.0-dev \ + libssl-dev \ + lsb-release \ + pkg-config \ + wget + +RUN update-ca-certificates --fresh + +ENV DATA_DIR=/data +WORKDIR ${DATA_DIR} + +COPY . ${DATA_DIR} +RUN git reset --hard HEAD && git clean -xfd + +RUN git config --global --add safe.directory '*' + +# Bootstrap and Build +RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="/usr" && \ + make package && mkdir OUT && mv -v *.deb OUT/. + +# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) +FROM scratch +COPY --from=builder /data/OUT/ / diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 24d895a..05527dd 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -35,6 +35,8 @@ jobs: runner: ubuntu-latest - name: arm32v7 runner: ubuntu-latest + - name: arm64v8 + runner: ubuntu-latest # exclude: # - version: bookworm # platform: From 1f777b0aa3217cea68b0bcad9c44d2b6bef575be Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Tue, 23 Apr 2024 15:34:52 +0300 Subject: [PATCH 26/30] Bump version to 2.0.5 --- CMakeLists.txt | 2 +- src/include/libks/ks.h | 4 ++-- win/libks-version.props | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c130588..15a676e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if (KS_PLAT_WIN OR WITH_KS_TEST) endif() # Declare our project, libks2 -project(LibKS2 VERSION 2.0.4 LANGUAGES C CXX) +project(LibKS2 VERSION 2.0.5 LANGUAGES C CXX) message("LibKS2 Version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") # Set package version diff --git a/src/include/libks/ks.h b/src/include/libks/ks.h index 935bf5e..76e3951 100644 --- a/src/include/libks/ks.h +++ b/src/include/libks/ks.h @@ -30,10 +30,10 @@ #endif /* libks version as a string */ -#define KS_VERSION "2.0.4" +#define KS_VERSION "2.0.5" /* libks version as a number */ -#define KS_VERSION_NUM 20004 +#define KS_VERSION_NUM 20005 /* Use this to allow enabling TCP_KEEPIDLE and TCP_KEEPINTVL socket options */ //#define KS_KEEP_IDLE_INTVL 1 diff --git a/win/libks-version.props b/win/libks-version.props index f376268..4e94927 100644 --- a/win/libks-version.props +++ b/win/libks-version.props @@ -4,7 +4,7 @@ - 2.0.4 + 2.0.5 0 $(BaseDir)../ From dcddb83ce7d7341e5dfcd93f12f68cd6ac3ab1ca Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Fri, 28 Jun 2024 07:00:48 -0700 Subject: [PATCH 27/30] Delete drone config (#212) --- .drone.yml | 90 ------------------------------------------------------ 1 file changed, 90 deletions(-) delete mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 4aa19fc..0000000 --- a/.drone.yml +++ /dev/null @@ -1,90 +0,0 @@ ---- -kind: pipeline -name: default - -steps: - - name: scan-build - image: debian:buster - pull: always - commands: - - apt-get update && apt-get install -yq build-essential autotools-dev lsb-release pkg-config automake autoconf libtool-bin clang-tools-7 - - apt-get install -yq cmake uuid-dev libssl-dev - - sed -i '/cotire/d' ./CMakeLists.txt - - mkdir -p scan-build - - scan-build-7 -o ./scan-build/ cmake . - - echo '#!/bin/bash\nscan-build-7 -o ./scan-build/ make -j`nproc --all` |& tee ./scan-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./scan-build-status.txt\n' > scan.sh - - chmod +x scan.sh - - ./scan.sh - - exitstatus=`cat ./scan-build-status.txt` - - echo "*** Exit status is $exitstatus" - - - name: notify - image: signalwire/drone-notify - pull: always - environment: - SLACK_WEBHOOK_URL: - from_secret: slack_webhook_url - ENV_FILE: - from_secret: notify_env - commands: - - /root/scan-build-notify.sh - -trigger: - branch: - - master - - v2.0 - -trigger: - event: - - pull_request - - push ---- - -kind: pipeline -name: tests - -steps: - - name: tests - image: debian:buster - pull: always - commands: - - apt-get update && apt-get install -yq build-essential autotools-dev lsb-release pkg-config automake autoconf libtool-bin clang-tools-7 - - apt-get install -yq cmake uuid-dev libssl-dev colorized-logs - - sed -i '/cotire/d' ./CMakeLists.txt - - mkdir -p scan-build - - scan-build-7 -o ./scan-build/ cmake . - - mkdir -p tests/unit/logs - - echo '#!/bin/bash\nmake -j`nproc --all` |& tee ./unit-tests-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./build-status.txt\n' > build.sh - - chmod +x build.sh - - ./build.sh - - echo 0 > tests/unit/run-tests-status.txt - - echo '#!/bin/bash\nenv CTEST_OUTPUT_ON_FAILURE=1 make test |& tee >(ansi2html > ./tests/unit/logs/artifacts.html)\nexitstatus=$${PIPESTATUS[0]}\nexit $$exitstatus\n' > test.sh - - chmod +x test.sh - - ./test.sh && exit 0 || echo 'Some tests failed' - - echo 1 > tests/unit/run-tests-status.txt - - - name: notify - image: signalwire/drone-notify - pull: always - environment: - SLACK_WEBHOOK_URL: - from_secret: slack_webhook_url - ENV_FILE: - from_secret: notify_env - commands: - - /root/unit-tests-notify.sh - -trigger: - branch: - - master - - v2.0 - -trigger: - event: - - pull_request - - push ---- -kind: signature -hmac: fe1e87b032687d1bbddba7dffa029891e4a4076f194eaf43139b1c5ceaa83a5d - -... From 1769030c283132446cd18515f378b4f907077289 Mon Sep 17 00:00:00 2001 From: Shane Bryldt Date: Tue, 16 Jul 2024 14:31:47 -0600 Subject: [PATCH 28/30] Fix return from kws_raw_write on fragmented frame sending (#214) * kws_raw_write should return the total number of bytes sent, not just the last fragment sent * Adjustment to make sure returns of -1 are captured as well, and fix missing spot in SSL block * Added zero to be inclusive as successful write when using raw sockets, but according to SSL lib 0 is an error so the behavior is slightly different using SSL versus not on the writing returns * Adjust the kws_write_frame so that when it sees a return <=0 it returns the error instead of the total written bytes --- src/kws.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kws.c b/src/kws.c index 71ab949..f1180c2 100644 --- a/src/kws.c +++ b/src/kws.c @@ -615,7 +615,7 @@ KS_DECLARE(ks_ssize_t) kws_raw_write(kws_t *kws, void *data, ks_size_t bytes) r = ssl_err * -1; } - return r; + return r > 0 ? wrote : r; } do { @@ -650,7 +650,7 @@ KS_DECLARE(ks_ssize_t) kws_raw_write(kws_t *kws, void *data, ks_size_t bytes) //printf("wRITE FAIL: %s\n", strerror(errno)); //} - return r; + return r >= 0 ? wrote : r; } static void setup_socket(ks_socket_t sock) @@ -1622,7 +1622,7 @@ KS_DECLARE(ks_ssize_t) kws_write_frame(kws_t *kws, kws_opcode_t oc, const void * raw_ret = kws_raw_write(kws, bp, (hlen + bytes)); - if (raw_ret != (ks_ssize_t) (hlen + bytes)) { + if (raw_ret <= 0 || raw_ret != (ks_ssize_t) (hlen + bytes)) { return raw_ret; } From 34d2430249d5c61583e4423133c3fefc1660cb37 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Tue, 23 Jul 2024 21:31:56 +0200 Subject: [PATCH 29/30] [GHA] Remove unsupported build targets. --- .github/docker/centos/7/amd64/Dockerfile | 95 ------------------- .github/docker/debian/buster/amd64/Dockerfile | 51 ---------- .../docker/debian/buster/arm32v7/Dockerfile | 51 ---------- .../docker/debian/buster/arm64v8/Dockerfile | 51 ---------- .github/workflows/cicd.yml | 38 -------- 5 files changed, 286 deletions(-) delete mode 100644 .github/docker/centos/7/amd64/Dockerfile delete mode 100644 .github/docker/debian/buster/amd64/Dockerfile delete mode 100644 .github/docker/debian/buster/arm32v7/Dockerfile delete mode 100644 .github/docker/debian/buster/arm64v8/Dockerfile diff --git a/.github/docker/centos/7/amd64/Dockerfile b/.github/docker/centos/7/amd64/Dockerfile deleted file mode 100644 index 3c159c9..0000000 --- a/.github/docker/centos/7/amd64/Dockerfile +++ /dev/null @@ -1,95 +0,0 @@ -ARG BUILDER_IMAGE=centos:7.2.1511 - -FROM ${BUILDER_IMAGE} AS builder - -ARG MAINTAINER="Andrey Volk " -ARG BUILD_NUMBER=42 -ARG GIT_SHA=0000000000 - -MAINTAINER ${MAINTAINER} -ENV MAINTAINER=${MAINTAINER} - -RUN yum -y update && \ - yum install -y \ - audiofile-devel \ - autoconf \ - automake \ - bind-license \ - centos-release-scl \ - cyrus-sasl-lib \ - dbus \ - dbus-libs \ - devtoolset-9-gcc* \ - dos2unix \ - doxygen \ - dpkg-dev \ - dracut \ - epel-release \ - expat \ - gcc \ - gcc-c++ \ - git \ - glib2 \ - glib2-devel \ - gnupg2 \ - gzip \ - krb5-dxevel \ - libatomic \ - libcurl-devel \ - libtool \ - libuuid-devel \ - libxml2 \ - lksctp-tools-devel \ - lsb_release \ - make \ - multilib-rpm-config \ - openssl-devel \ - pkg-config \ - procps-ng \ - python \ - python-libs \ - rpm-build \ - rpmdevtools \ - scl-utils \ - sqlite \ - swig \ - unzip \ - uuid-devel \ - vim-minimal \ - wget \ - which \ - xz \ - xz-libs \ - yum-plugin-fastestmirror \ - yum-plugin-ovl \ - yum-utils \ - zlib-devel && \ - yum -y clean all - -ENV CMAKE_VERSION 3.22.2 - -RUN set -ex \ - && curl -kfsSLO --compressed https://cmake.org/files/v3.22/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz \ - && curl -kfsSLO --compressed https://cmake.org/files/v3.22/cmake-${CMAKE_VERSION}-SHA-256.txt \ - && grep "cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz\$" cmake-${CMAKE_VERSION}-SHA-256.txt | sha256sum -c - \ - && tar xzf cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz -C /usr/local --strip-components=1 --no-same-owner \ - && rm -rf cmake-${CMAKE_VERSION}* \ - && cmake --version - -ENV DATA_DIR=/data -WORKDIR ${DATA_DIR} - -COPY . ${DATA_DIR}/ -RUN cd ${DATA_DIR}/ && \ - git reset --hard HEAD && git clean -xfd && \ - cd ${DATA_DIR} - -# Bootstrap and Build -RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_INSTALL_PREFIX="/usr" && \ - make package && mkdir OUT && mv -v *.rpm OUT/. - -# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) -FROM scratch -COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/buster/amd64/Dockerfile b/.github/docker/debian/buster/amd64/Dockerfile deleted file mode 100644 index 103b778..0000000 --- a/.github/docker/debian/buster/amd64/Dockerfile +++ /dev/null @@ -1,51 +0,0 @@ -ARG BUILDER_IMAGE=debian:buster -ARG MAINTAINER="Andrey Volk " - -FROM ${BUILDER_IMAGE} AS builder - -ARG BUILD_NUMBER=42 -ARG GIT_SHA=0000000000 - -MAINTAINER ${MAINTAINER} - -SHELL ["/bin/bash", "-c"] - -RUN apt-get -q update && \ - DEBIAN_FRONTEND=noninteractive apt-get -yq install \ - apt-transport-https \ - build-essential \ - ca-certificates \ - cmake \ - curl \ - debhelper \ - devscripts \ - dh-autoreconf \ - dos2unix \ - doxygen \ - git \ - graphviz \ - libglib2.0-dev \ - libssl-dev \ - lsb-release \ - pkg-config \ - wget - -RUN update-ca-certificates --fresh - -ENV DATA_DIR=/data -WORKDIR ${DATA_DIR} - -COPY . ${DATA_DIR} -RUN git reset --hard HEAD && git clean -xfd - -RUN git config --global --add safe.directory '*' - -# Bootstrap and Build -RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_INSTALL_PREFIX="/usr" && \ - make package && mkdir OUT && mv -v *.deb OUT/. - -# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) -FROM scratch -COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/buster/arm32v7/Dockerfile b/.github/docker/debian/buster/arm32v7/Dockerfile deleted file mode 100644 index 5d90822..0000000 --- a/.github/docker/debian/buster/arm32v7/Dockerfile +++ /dev/null @@ -1,51 +0,0 @@ -ARG BUILDER_IMAGE=arm32v7/debian:buster -ARG MAINTAINER="Andrey Volk " - -FROM ${BUILDER_IMAGE} AS builder - -ARG BUILD_NUMBER=42 -ARG GIT_SHA=0000000000 - -MAINTAINER ${MAINTAINER} - -SHELL ["/bin/bash", "-c"] - -RUN apt-get -q update && \ - DEBIAN_FRONTEND=noninteractive apt-get -yq install \ - apt-transport-https \ - build-essential \ - ca-certificates \ - cmake \ - curl \ - debhelper \ - devscripts \ - dh-autoreconf \ - dos2unix \ - doxygen \ - git \ - graphviz \ - libglib2.0-dev \ - libssl-dev \ - lsb-release \ - pkg-config \ - wget - -RUN update-ca-certificates --fresh - -ENV DATA_DIR=/data -WORKDIR ${DATA_DIR} - -COPY . ${DATA_DIR} -RUN git reset --hard HEAD && git clean -xfd - -RUN git config --global --add safe.directory '*' - -# Bootstrap and Build -RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_INSTALL_PREFIX="/usr" && \ - make package && mkdir OUT && mv -v *.deb OUT/. - -# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) -FROM scratch -COPY --from=builder /data/OUT/ / diff --git a/.github/docker/debian/buster/arm64v8/Dockerfile b/.github/docker/debian/buster/arm64v8/Dockerfile deleted file mode 100644 index b7825d3..0000000 --- a/.github/docker/debian/buster/arm64v8/Dockerfile +++ /dev/null @@ -1,51 +0,0 @@ -ARG BUILDER_IMAGE=arm64v8/debian:buster -ARG MAINTAINER="Andrey Volk " - -FROM ${BUILDER_IMAGE} AS builder - -ARG BUILD_NUMBER=42 -ARG GIT_SHA=0000000000 - -MAINTAINER ${MAINTAINER} - -SHELL ["/bin/bash", "-c"] - -RUN apt-get -q update && \ - DEBIAN_FRONTEND=noninteractive apt-get -yq install \ - apt-transport-https \ - build-essential \ - ca-certificates \ - cmake \ - curl \ - debhelper \ - devscripts \ - dh-autoreconf \ - dos2unix \ - doxygen \ - git \ - graphviz \ - libglib2.0-dev \ - libssl-dev \ - lsb-release \ - pkg-config \ - wget - -RUN update-ca-certificates --fresh - -ENV DATA_DIR=/data -WORKDIR ${DATA_DIR} - -COPY . ${DATA_DIR} -RUN git reset --hard HEAD && git clean -xfd - -RUN git config --global --add safe.directory '*' - -# Bootstrap and Build -RUN PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_INSTALL_PREFIX="/usr" && \ - make package && mkdir OUT && mv -v *.deb OUT/. - -# Artifacts image (mandatory part, the resulting image must have a single filesystem layer) -FROM scratch -COPY --from=builder /data/OUT/ / diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 05527dd..f710225 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -29,7 +29,6 @@ jobs: version: - bookworm - bullseye - - buster platform: - name: amd64 runner: ubuntu-latest @@ -60,48 +59,11 @@ jobs: # REPO_USERNAME: 'signalwire' # REPO_PASSWORD: ${{ secrets.REPOTOKEN }} - rpm: - name: 'RPM' - permissions: - id-token: write - contents: read - uses: signalwire/actions-template/.github/workflows/cicd-docker-build-and-distribute.yml@main - strategy: - # max-parallel: 1 - fail-fast: false - matrix: - os: - - centos - version: - - 7 - platform: - - name: amd64 - runner: ubuntu-latest - with: - RUNNER: ${{ matrix.platform.runner }} - ARTIFACTS_PATTERN: '.*\.(rpm)$' - DOCKERFILE: .github/docker/${{ matrix.os }}/${{ matrix.version }}/${{ matrix.platform.name }}/Dockerfile - MAINTAINER: 'Andrey Volk ' - META_FILE_PATH_PREFIX: /var/www/libks/${{ github.ref_name }}/${{ github.run_id }}-${{ github.run_number }} - PLATFORM: ${{ matrix.platform.name }} - # REPO_DOMAIN: freeswitch.signalwire.com - TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-artifact - UPLOAD_BUILD_ARTIFACTS: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }} - secrets: - GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }} - HOSTNAME: ${{ secrets.HOSTNAME }} - PROXY_URL: ${{ secrets.PROXY_URL }} - USERNAME: ${{ secrets.USERNAME }} - TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} - # REPO_USERNAME: ${{ secrets.FSAUSER }} - # REPO_PASSWORD: ${{ secrets.FSAPASS }} - meta: name: 'Publish build data to meta-repo' if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }} needs: - deb - - rpm permissions: id-token: write contents: read From fb4d1f6219c505f7854f74080743ddb1cdfdbca4 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Tue, 23 Jul 2024 22:57:51 +0300 Subject: [PATCH 30/30] Bump version to 2.0.6 --- CMakeLists.txt | 2 +- src/include/libks/ks.h | 4 ++-- win/libks-version.props | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15a676e..91b75bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if (KS_PLAT_WIN OR WITH_KS_TEST) endif() # Declare our project, libks2 -project(LibKS2 VERSION 2.0.5 LANGUAGES C CXX) +project(LibKS2 VERSION 2.0.6 LANGUAGES C CXX) message("LibKS2 Version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") # Set package version diff --git a/src/include/libks/ks.h b/src/include/libks/ks.h index 76e3951..8fc1e23 100644 --- a/src/include/libks/ks.h +++ b/src/include/libks/ks.h @@ -30,10 +30,10 @@ #endif /* libks version as a string */ -#define KS_VERSION "2.0.5" +#define KS_VERSION "2.0.6" /* libks version as a number */ -#define KS_VERSION_NUM 20005 +#define KS_VERSION_NUM 20006 /* Use this to allow enabling TCP_KEEPIDLE and TCP_KEEPINTVL socket options */ //#define KS_KEEP_IDLE_INTVL 1 diff --git a/win/libks-version.props b/win/libks-version.props index 4e94927..3e46280 100644 --- a/win/libks-version.props +++ b/win/libks-version.props @@ -4,7 +4,7 @@ - 2.0.5 + 2.0.6 0 $(BaseDir)../