Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
andywolk committed Feb 16, 2024
2 parents 9ab8480 + 2653d51 commit ad8b7b7
Show file tree
Hide file tree
Showing 3 changed files with 257 additions and 6 deletions.
252 changes: 252 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
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 <[email protected]>'
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 }}
5 changes: 3 additions & 2 deletions src/kws.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -1484,7 +1485,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];
}
}
Expand Down
6 changes: 2 additions & 4 deletions tests/testwebsock2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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] = "";
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit ad8b7b7

Please sign in to comment.