diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 63838cfb73..0000000000 --- a/.drone.yml +++ /dev/null @@ -1,184 +0,0 @@ ---- -kind: pipeline -name: unit-tests - -steps: - - name: bootstrap - image: signalwire/freeswitch-public-base:bullseye - pull: always - commands: - - cat /proc/sys/kernel/core_pattern - - ./bootstrap.sh -j - - - name: configure - image: signalwire/freeswitch-public-base:bullseye - pull: always - environment: - REPOTOKEN: - from_secret: repotoken - commands: - - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libsofia-sip-ua0 libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libspandsp3-dev - - export REPOTOKEN='' - - rm -rf /etc/apt/auth.conf - - git clone https://github.com/freeswitch/sofia-sip.git - - cd sofia-sip && ./autogen.sh && ./configure.gnu && make -j`nproc` && make install && cd .. - - echo 'codecs/mod_openh264' >> modules.conf - - sed -i '/applications\\/mod_http_cache/s/^#//g' modules.conf - - sed -i '/event_handlers\\/mod_rayo/s/^#//g' modules.conf - - sed -i '/formats\\/mod_opusfile/s/^#//g' modules.conf - - sed -i '/languages\\/mod_lua/s/^#//g' modules.conf - - export ASAN_OPTIONS=log_path=stdout:disable_coredump=0:unmap_shadow_on_exit=1:fast_unwind_on_malloc=0 - - ./configure --enable-address-sanitizer --enable-fake-dlclose - - - name: build - image: signalwire/freeswitch-public-base:bullseye - pull: always - environment: - REPOTOKEN: - from_secret: repotoken - commands: - - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libsofia-sip-ua0 libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libspandsp3-dev - - export REPOTOKEN='' - - rm -rf /etc/apt/auth.conf - - cd sofia-sip && make install && cd .. - - 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 - - - name: run-tests - image: signalwire/freeswitch-public-base:bullseye - pull: always - environment: - REPOTOKEN: - from_secret: repotoken - commands: - - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libsofia-sip-ua0 libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libspandsp3-dev - - export REPOTOKEN='' - - rm -rf /etc/apt/auth.conf - - cd sofia-sip && make install && cd .. - - make install || true - - cd tests/unit - - export ASAN_OPTIONS=log_path=stdout:disable_coredump=0:unmap_shadow_on_exit=1:fast_unwind_on_malloc=0 - - ./run-tests.sh - - ls -la /cores - - mkdir logs && (mv log_run-tests_*.html logs || true) && (mv backtrace_*.txt logs || true) - - echo 0 > run-tests-status.txt - - ./collect-test-logs.sh && exit 0 || echo 'Some tests failed' - - echo 1 > run-tests-status.txt - - cd logs && ls -la - - - 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 - event: - - pull_request - - push - ---- -kind: pipeline -name: scan-build - -steps: - - name: bootstrap - image: signalwire/freeswitch-public-base:bookworm - pull: always - commands: - - apt-get update && apt-get -yq install autoconf - - ./bootstrap.sh -j - - - name: configure - image: signalwire/freeswitch-public-base:bookworm - pull: always - environment: - REPOTOKEN: - from_secret: repotoken - commands: - - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libsofia-sip-ua-dev libspandsp3-dev - - export REPOTOKEN='' - - rm -rf /etc/apt/auth.conf - - cp build/modules.conf.most modules.conf - #Enable/Uncomment mods - - echo 'codecs/mod_openh264' >> modules.conf - - sed -i "/mod_mariadb/s/^#//g" modules.conf - - sed -i "/mod_v8/s/^#//g" modules.conf - #Disable/Comment out mods - - sed -i '/mod_ilbc/s/^/#/g' modules.conf - - sed -i '/mod_isac/s/^/#/g' modules.conf - - sed -i '/mod_mp4/s/^/#/g' modules.conf - - sed -i '/mod_mongo/s/^/#/g' modules.conf - - sed -i '/mod_pocketsphinx/s/^/#/g' modules.conf - - sed -i '/mod_sangoma_codec/s/^/#/g' modules.conf - - sed -i '/mod_siren/s/^/#/g' modules.conf - #Comment out mods for a while - - sed -i '/mod_avmd/s/^/#/g' modules.conf - - sed -i '/mod_basic/s/^/#/g' modules.conf - - sed -i '/mod_cdr_mongodb/s/^/#/g' modules.conf - - sed -i '/mod_cv/s/^/#/g' modules.conf - - sed -i '/mod_erlang_event/s/^/#/g' modules.conf - - sed -i '/mod_perl/s/^/#/g' modules.conf - - sed -i '/mod_rtmp/s/^/#/g' modules.conf - - sed -i '/mod_unimrcp/s/^/#/g' modules.conf - - sed -i '/mod_xml_rpc/s/^/#/g' modules.conf - - ./configure - - - name: scan-build - image: signalwire/freeswitch-public-base:bookworm - pull: always - environment: - REPOTOKEN: - from_secret: repotoken - commands: - - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libsofia-sip-ua-dev libspandsp3-dev - - export REPOTOKEN='' - - rm -rf /etc/apt/auth.conf - - mkdir -p scan-build - - echo '#!/bin/bash\nscan-build-14 --force-analyze-debug-code -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 - event: - - pull_request - - push - ---- -kind: signature -hmac: 7e5f6cafc88da0be59243daf47a2a5607ff00b45f441ce4c1041d4b690e8a853 - -... diff --git a/.github/docker/debian/bookworm/amd64/Dockerfile b/.github/docker/debian/bookworm/amd64/Dockerfile index b500830148..3ef7b38b38 100644 --- a/.github/docker/debian/bookworm/amd64/Dockerfile +++ b/.github/docker/debian/bookworm/amd64/Dockerfile @@ -8,7 +8,6 @@ ARG MAINTAINER_EMAIL="andrey@signalwire.com" # Credentials ARG REPO_DOMAIN=freeswitch.signalwire.com ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password ARG BUILD_NUMBER=42 ARG GIT_SHA=0000000000 @@ -51,19 +50,10 @@ deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${COD deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main EOF -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - RUN git config --global --add safe.directory '*' \ && git config --global user.name "${MAINTAINER_NAME}" \ && git config --global user.email "${MAINTAINER_EMAIL}" -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg - # Bootstrap and Build COPY . ${DATA_DIR} WORKDIR ${DATA_DIR} @@ -72,9 +62,25 @@ RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x RUN . ~/.env && ./debian/util.sh prep-create-dsc ${CODENAME} -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install +RUN --mount=type=secret,id=REPO_PASSWORD,required=true \ + printf "machine ${REPO_DOMAIN} " > /etc/apt/auth.conf && \ + printf "login ${REPO_USERNAME} " >> /etc/apt/auth.conf && \ + printf "password " >> /etc/apt/auth.conf && \ + cat /run/secrets/REPO_PASSWORD >> /etc/apt/auth.conf && \ + sha512sum /run/secrets/REPO_PASSWORD && \ + curl \ + --fail \ + --netrc-file /etc/apt/auth.conf \ + --output ${GPG_KEY} \ + https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg && \ + file ${GPG_KEY} && \ + apt-get --quiet update && \ + mk-build-deps \ + --install \ + --remove debian/control \ + --tool "apt-get --yes --no-install-recommends" && \ + apt-get --yes --fix-broken install && \ + rm -f /etc/apt/auth.conf ENV DEB_BUILD_OPTIONS="parallel=1" RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ diff --git a/.github/docker/debian/bookworm/arm32v7/Dockerfile b/.github/docker/debian/bookworm/arm32v7/Dockerfile index 43b4778b3e..6259c7e8e9 100644 --- a/.github/docker/debian/bookworm/arm32v7/Dockerfile +++ b/.github/docker/debian/bookworm/arm32v7/Dockerfile @@ -8,7 +8,6 @@ ARG MAINTAINER_EMAIL="andrey@signalwire.com" # Credentials ARG REPO_DOMAIN=freeswitch.signalwire.com ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password ARG BUILD_NUMBER=42 ARG GIT_SHA=0000000000 @@ -51,19 +50,10 @@ deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev ${CODE deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev ${CODENAME} main EOF -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - RUN git config --global --add safe.directory '*' \ && git config --global user.name "${MAINTAINER_NAME}" \ && git config --global user.email "${MAINTAINER_EMAIL}" -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev/signalwire-freeswitch-repo.gpg - # Bootstrap and Build COPY . ${DATA_DIR} WORKDIR ${DATA_DIR} @@ -72,9 +62,25 @@ RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x RUN . ~/.env && ./debian/util.sh prep-create-dsc -a armhf ${CODENAME} -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install +RUN --mount=type=secret,id=REPO_PASSWORD,required=true \ + printf "machine ${REPO_DOMAIN} " > /etc/apt/auth.conf && \ + printf "login ${REPO_USERNAME} " >> /etc/apt/auth.conf && \ + printf "password " >> /etc/apt/auth.conf && \ + cat /run/secrets/REPO_PASSWORD >> /etc/apt/auth.conf && \ + sha512sum /run/secrets/REPO_PASSWORD && \ + curl \ + --fail \ + --netrc-file /etc/apt/auth.conf \ + --output ${GPG_KEY} \ + https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev/signalwire-freeswitch-repo.gpg && \ + file ${GPG_KEY} && \ + apt-get --quiet update && \ + mk-build-deps \ + --install \ + --remove debian/control \ + --tool "apt-get --yes --no-install-recommends" && \ + apt-get --yes --fix-broken install && \ + rm -f /etc/apt/auth.conf ENV DEB_BUILD_OPTIONS="parallel=1" RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ diff --git a/.github/docker/debian/bookworm/arm64v8/Dockerfile b/.github/docker/debian/bookworm/arm64v8/Dockerfile index 50c24957f1..0df5a178fe 100644 --- a/.github/docker/debian/bookworm/arm64v8/Dockerfile +++ b/.github/docker/debian/bookworm/arm64v8/Dockerfile @@ -8,7 +8,6 @@ ARG MAINTAINER_EMAIL="andrey@signalwire.com" # Credentials ARG REPO_DOMAIN=freeswitch.signalwire.com ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password ARG BUILD_NUMBER=42 ARG GIT_SHA=0000000000 @@ -51,19 +50,10 @@ deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${COD deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main EOF -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - RUN git config --global --add safe.directory '*' \ && git config --global user.name "${MAINTAINER_NAME}" \ && git config --global user.email "${MAINTAINER_EMAIL}" -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg - # Bootstrap and Build COPY . ${DATA_DIR} WORKDIR ${DATA_DIR} @@ -72,9 +62,25 @@ RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x RUN . ~/.env && ./debian/util.sh prep-create-dsc -a arm64 ${CODENAME} -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install +RUN --mount=type=secret,id=REPO_PASSWORD,required=true \ + printf "machine ${REPO_DOMAIN} " > /etc/apt/auth.conf && \ + printf "login ${REPO_USERNAME} " >> /etc/apt/auth.conf && \ + printf "password " >> /etc/apt/auth.conf && \ + cat /run/secrets/REPO_PASSWORD >> /etc/apt/auth.conf && \ + sha512sum /run/secrets/REPO_PASSWORD && \ + curl \ + --fail \ + --netrc-file /etc/apt/auth.conf \ + --output ${GPG_KEY} \ + https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg && \ + file ${GPG_KEY} && \ + apt-get --quiet update && \ + mk-build-deps \ + --install \ + --remove debian/control \ + --tool "apt-get --yes --no-install-recommends" && \ + apt-get --yes --fix-broken install && \ + rm -f /etc/apt/auth.conf ENV DEB_BUILD_OPTIONS="parallel=1" RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ diff --git a/.github/docker/debian/bullseye/amd64/Dockerfile b/.github/docker/debian/bullseye/amd64/Dockerfile index aefbd38224..56586d338e 100644 --- a/.github/docker/debian/bullseye/amd64/Dockerfile +++ b/.github/docker/debian/bullseye/amd64/Dockerfile @@ -8,7 +8,6 @@ ARG MAINTAINER_EMAIL="andrey@signalwire.com" # Credentials ARG REPO_DOMAIN=freeswitch.signalwire.com ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password ARG BUILD_NUMBER=42 ARG GIT_SHA=0000000000 @@ -51,19 +50,10 @@ deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${COD deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main EOF -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - RUN git config --global --add safe.directory '*' \ && git config --global user.name "${MAINTAINER_NAME}" \ && git config --global user.email "${MAINTAINER_EMAIL}" -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg - # Bootstrap and Build COPY . ${DATA_DIR} WORKDIR ${DATA_DIR} @@ -72,9 +62,25 @@ RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x RUN . ~/.env && ./debian/util.sh prep-create-dsc ${CODENAME} -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install +RUN --mount=type=secret,id=REPO_PASSWORD,required=true \ + printf "machine ${REPO_DOMAIN} " > /etc/apt/auth.conf && \ + printf "login ${REPO_USERNAME} " >> /etc/apt/auth.conf && \ + printf "password " >> /etc/apt/auth.conf && \ + cat /run/secrets/REPO_PASSWORD >> /etc/apt/auth.conf && \ + sha512sum /run/secrets/REPO_PASSWORD && \ + curl \ + --fail \ + --netrc-file /etc/apt/auth.conf \ + --output ${GPG_KEY} \ + https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg && \ + file ${GPG_KEY} && \ + apt-get --quiet update && \ + mk-build-deps \ + --install \ + --remove debian/control \ + --tool "apt-get --yes --no-install-recommends" && \ + apt-get --yes --fix-broken install && \ + rm -f /etc/apt/auth.conf ENV DEB_BUILD_OPTIONS="parallel=1" RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ diff --git a/.github/docker/debian/bullseye/arm32v7/Dockerfile b/.github/docker/debian/bullseye/arm32v7/Dockerfile index b3a6f00c36..24c5804b68 100644 --- a/.github/docker/debian/bullseye/arm32v7/Dockerfile +++ b/.github/docker/debian/bullseye/arm32v7/Dockerfile @@ -8,7 +8,6 @@ ARG MAINTAINER_EMAIL="andrey@signalwire.com" # Credentials ARG REPO_DOMAIN=freeswitch.signalwire.com ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password ARG BUILD_NUMBER=42 ARG GIT_SHA=0000000000 @@ -51,19 +50,10 @@ deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev ${CODE deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev ${CODENAME} main EOF -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - RUN git config --global --add safe.directory '*' \ && git config --global user.name "${MAINTAINER_NAME}" \ && git config --global user.email "${MAINTAINER_EMAIL}" -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev/signalwire-freeswitch-repo.gpg - # Bootstrap and Build COPY . ${DATA_DIR} WORKDIR ${DATA_DIR} @@ -72,9 +62,25 @@ RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x RUN . ~/.env && ./debian/util.sh prep-create-dsc -a armhf ${CODENAME} -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install +RUN --mount=type=secret,id=REPO_PASSWORD,required=true \ + printf "machine ${REPO_DOMAIN} " > /etc/apt/auth.conf && \ + printf "login ${REPO_USERNAME} " >> /etc/apt/auth.conf && \ + printf "password " >> /etc/apt/auth.conf && \ + cat /run/secrets/REPO_PASSWORD >> /etc/apt/auth.conf && \ + sha512sum /run/secrets/REPO_PASSWORD && \ + curl \ + --fail \ + --netrc-file /etc/apt/auth.conf \ + --output ${GPG_KEY} \ + https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev/signalwire-freeswitch-repo.gpg && \ + file ${GPG_KEY} && \ + apt-get --quiet update && \ + mk-build-deps \ + --install \ + --remove debian/control \ + --tool "apt-get --yes --no-install-recommends" && \ + apt-get --yes --fix-broken install && \ + rm -f /etc/apt/auth.conf ENV DEB_BUILD_OPTIONS="parallel=1" RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ diff --git a/.github/docker/debian/bullseye/arm64v8/Dockerfile b/.github/docker/debian/bullseye/arm64v8/Dockerfile index dfa899540e..f5a6a906c4 100644 --- a/.github/docker/debian/bullseye/arm64v8/Dockerfile +++ b/.github/docker/debian/bullseye/arm64v8/Dockerfile @@ -8,7 +8,6 @@ ARG MAINTAINER_EMAIL="andrey@signalwire.com" # Credentials ARG REPO_DOMAIN=freeswitch.signalwire.com ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password ARG BUILD_NUMBER=42 ARG GIT_SHA=0000000000 @@ -51,19 +50,10 @@ deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${COD deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main EOF -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - RUN git config --global --add safe.directory '*' \ && git config --global user.name "${MAINTAINER_NAME}" \ && git config --global user.email "${MAINTAINER_EMAIL}" -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg - # Bootstrap and Build COPY . ${DATA_DIR} WORKDIR ${DATA_DIR} @@ -72,9 +62,25 @@ RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x RUN . ~/.env && ./debian/util.sh prep-create-dsc -a arm64 ${CODENAME} -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install +RUN --mount=type=secret,id=REPO_PASSWORD,required=true \ + printf "machine ${REPO_DOMAIN} " > /etc/apt/auth.conf && \ + printf "login ${REPO_USERNAME} " >> /etc/apt/auth.conf && \ + printf "password " >> /etc/apt/auth.conf && \ + cat /run/secrets/REPO_PASSWORD >> /etc/apt/auth.conf && \ + sha512sum /run/secrets/REPO_PASSWORD && \ + curl \ + --fail \ + --netrc-file /etc/apt/auth.conf \ + --output ${GPG_KEY} \ + https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg && \ + file ${GPG_KEY} && \ + apt-get --quiet update && \ + mk-build-deps \ + --install \ + --remove debian/control \ + --tool "apt-get --yes --no-install-recommends" && \ + apt-get --yes --fix-broken install && \ + rm -f /etc/apt/auth.conf ENV DEB_BUILD_OPTIONS="parallel=1" RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ diff --git a/.github/docker/debian/buster/amd64/Dockerfile b/.github/docker/debian/buster/amd64/Dockerfile deleted file mode 100644 index 119a18076e..0000000000 --- a/.github/docker/debian/buster/amd64/Dockerfile +++ /dev/null @@ -1,97 +0,0 @@ -ARG BUILDER_IMAGE=debian:buster-20240513 - -FROM ${BUILDER_IMAGE} AS builder - -ARG MAINTAINER_NAME="Andrey Volk" -ARG MAINTAINER_EMAIL="andrey@signalwire.com" - -# Credentials -ARG REPO_DOMAIN=freeswitch.signalwire.com -ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password - -ARG BUILD_NUMBER=42 -ARG GIT_SHA=0000000000 - -ARG DATA_DIR=/data -ARG CODENAME=buster -ARG GPG_KEY="/usr/share/keyrings/signalwire-freeswitch-repo.gpg" - -MAINTAINER "${MAINTAINER_NAME} <${MAINTAINER_EMAIL}>" - -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 - -RUN echo "export CODENAME=${CODENAME}" | tee ~/.env && \ - chmod +x ~/.env - -RUN . ~/.env && cat < /etc/apt/sources.list.d/freeswitch.list -deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main -deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main -EOF - -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - -RUN git config --global --add safe.directory '*' \ - && git config --global user.name "${MAINTAINER_NAME}" \ - && git config --global user.email "${MAINTAINER_EMAIL}" - -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg - -# Bootstrap and Build -COPY . ${DATA_DIR} -WORKDIR ${DATA_DIR} - -RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a ~/.env - -RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x -RUN . ~/.env && ./debian/util.sh prep-create-dsc ${CODENAME} - -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install - -ENV DEB_BUILD_OPTIONS="parallel=1" -RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ - --force-distribution -D "${CODENAME}" "Nightly build, ${GIT_SHA}" -RUN . ~/.env && ./debian/util.sh create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x - -RUN dpkg-source \ - --diff-ignore=.* \ - --compression=xz \ - --compression-level=9 \ - --build \ - . \ - && debuild -b -us -uc \ - && mkdir OUT \ - && mv -v ../*.{deb,dsc,changes,tar.*} 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 2113f55bd8..0000000000 --- a/.github/docker/debian/buster/arm32v7/Dockerfile +++ /dev/null @@ -1,96 +0,0 @@ -ARG BUILDER_IMAGE=arm32v7/debian:buster-20240513 - -FROM --platform=linux/arm32 ${BUILDER_IMAGE} AS builder - -ARG MAINTAINER_NAME="Andrey Volk" -ARG MAINTAINER_EMAIL="andrey@signalwire.com" - -# Credentials -ARG REPO_DOMAIN=freeswitch.signalwire.com -ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password - -ARG BUILD_NUMBER=42 -ARG GIT_SHA=0000000000 - -ARG DATA_DIR=/data -ARG CODENAME=buster -ARG GPG_KEY="/usr/share/keyrings/signalwire-freeswitch-repo.gpg" - -MAINTAINER "${MAINTAINER_NAME} <${MAINTAINER_EMAIL}>" - -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 - -RUN echo "export CODENAME=${CODENAME}" | tee ~/.env && \ - chmod +x ~/.env - -RUN . ~/.env && cat < /etc/apt/sources.list.d/freeswitch.list -deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev ${CODENAME} main -deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev ${CODENAME} main -EOF - -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - -RUN git config --global --add safe.directory '*' \ - && git config --global user.name "${MAINTAINER_NAME}" \ - && git config --global user.email "${MAINTAINER_EMAIL}" - -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/rpi/debian-dev/signalwire-freeswitch-repo.gpg - -# Bootstrap and Build -COPY . ${DATA_DIR} -WORKDIR ${DATA_DIR} -RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a ~/.env - -RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x -RUN . ~/.env && ./debian/util.sh prep-create-dsc -a armhf ${CODENAME} - -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install - -ENV DEB_BUILD_OPTIONS="parallel=1" -RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ - --force-distribution -D "${CODENAME}" "Nightly build, ${GIT_SHA}" -RUN . ~/.env && ./debian/util.sh create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x - -RUN dpkg-source \ - --diff-ignore=.* \ - --compression=xz \ - --compression-level=9 \ - --build \ - . \ - && debuild -b -us -uc \ - && mkdir OUT \ - && mv -v ../*.{deb,dsc,changes,tar.*} 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 150a77fec2..0000000000 --- a/.github/docker/debian/buster/arm64v8/Dockerfile +++ /dev/null @@ -1,96 +0,0 @@ -ARG BUILDER_IMAGE=arm64v8/debian:buster-20240513 - -FROM --platform=linux/arm64 ${BUILDER_IMAGE} AS builder - -ARG MAINTAINER_NAME="Andrey Volk" -ARG MAINTAINER_EMAIL="andrey@signalwire.com" - -# Credentials -ARG REPO_DOMAIN=freeswitch.signalwire.com -ARG REPO_USERNAME=user -ARG REPO_PASSWORD=password - -ARG BUILD_NUMBER=42 -ARG GIT_SHA=0000000000 - -ARG DATA_DIR=/data -ARG CODENAME=buster -ARG GPG_KEY="/usr/share/keyrings/signalwire-freeswitch-repo.gpg" - -MAINTAINER "${MAINTAINER_NAME} <${MAINTAINER_EMAIL}>" - -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 - -RUN echo "export CODENAME=${CODENAME}" | tee ~/.env && \ - chmod +x ~/.env - -RUN . ~/.env && cat < /etc/apt/sources.list.d/freeswitch.list -deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main -deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-unstable ${CODENAME} main -EOF - -RUN --mount=type=secret,id=REPO_PASSWORD \ - printf "machine ${REPO_DOMAIN} " > ~/.netrc && \ - printf "login ${REPO_USERNAME} " >> ~/.netrc && \ - printf "password " >> ~/.netrc && \ - cat /run/secrets/REPO_PASSWORD >> ~/.netrc && \ - cp -f ~/.netrc /etc/apt/auth.conf - -RUN git config --global --add safe.directory '*' \ - && git config --global user.name "${MAINTAINER_NAME}" \ - && git config --global user.email "${MAINTAINER_EMAIL}" - -RUN curl --netrc -o ${GPG_KEY} https://${REPO_DOMAIN}/repo/deb/debian-unstable/signalwire-freeswitch-repo.gpg - -# Bootstrap and Build -COPY . ${DATA_DIR} -WORKDIR ${DATA_DIR} -RUN echo "export VERSION=$(cat ./build/next-release.txt | tr -d '\n')" | tee -a ~/.env - -RUN . ~/.env && ./debian/util.sh prep-create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x -RUN . ~/.env && ./debian/util.sh prep-create-dsc -a arm64 ${CODENAME} - -RUN apt-get -q update && \ - mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \ - apt-get -y -f install - -ENV DEB_BUILD_OPTIONS="parallel=1" -RUN . ~/.env && dch -b -M -v "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \ - --force-distribution -D "${CODENAME}" "Nightly build, ${GIT_SHA}" -RUN . ~/.env && ./debian/util.sh create-orig -n -V${VERSION}-${BUILD_NUMBER}-${GIT_SHA} -x - -RUN dpkg-source \ - --diff-ignore=.* \ - --compression=xz \ - --compression-level=9 \ - --build \ - . \ - && debuild -b -us -uc \ - && mkdir OUT \ - && mv -v ../*.{deb,dsc,changes,tar.*} 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 index e16da9a364..37e29568a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - v1.10 paths: - "**" workflow_dispatch: @@ -14,6 +15,8 @@ concurrency: jobs: excludes: + name: 'Excludes' + # if: github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest outputs: deb: ${{ steps.deb.outputs.excludes }} @@ -25,12 +28,6 @@ jobs: if [[ "${{ github.event_name }}" == "pull_request" ]]; then JSON=$(jq -n '[ - { - "version": "bookworm", - "platform": { - "name": "amd64" - } - }, { "version": "bookworm", "platform": { @@ -38,7 +35,16 @@ jobs: } }, { - "version": "bullseye" + "version": "bullseye", + "platform": { + "name": "amd64" + } + }, + { + "version": "bullseye", + "platform": { + "name": "arm32v7" + } } ]') fi @@ -47,6 +53,7 @@ jobs: deb: name: 'DEB' + # if: github.event.pull_request.head.repo.full_name == github.repository permissions: id-token: write contents: read @@ -62,7 +69,6 @@ jobs: version: - bookworm - bullseye - - buster platform: - name: amd64 runner: ubuntu-latest @@ -87,7 +93,7 @@ jobs: PROXY_URL: ${{ secrets.PROXY_URL }} USERNAME: ${{ secrets.USERNAME }} TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }} - REPO_USERNAME: 'signalwire' + REPO_USERNAME: 'SWUSERNAME' REPO_PASSWORD: ${{ secrets.REPOTOKEN }} meta: diff --git a/build/next-release.txt b/build/next-release.txt index a3426275e7..27cbef8a6e 100644 --- a/build/next-release.txt +++ b/build/next-release.txt @@ -1 +1 @@ -1.10.12-dev +1.10.13-dev diff --git a/configure.ac b/configure.ac index 348103f8db..6991398ae7 100644 --- a/configure.ac +++ b/configure.ac @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.10.12-dev], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.10.13-dev], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [10]) -AC_SUBST(SWITCH_VERSION_MICRO, [12-dev]) +AC_SUBST(SWITCH_VERSION_MICRO, [13-dev]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) diff --git a/debian/util.sh b/debian/util.sh index 46c1f95346..dab53b1d47 100755 --- a/debian/util.sh +++ b/debian/util.sh @@ -203,11 +203,16 @@ create_orig () { done shift $(($OPTIND-1)) - local orig + local commit_epoch=$(git log -1 --format=%ct) + local source_date=$(date -u -d @$commit_epoch +'%Y-%m-%d %H:%M:%S') + + local orig git_archive_prefix if $auto_orig; then orig="../freeswitch_$(debian/version-omit_revision.pl).orig.tar.xz" + git_archive_prefix="freeswitch/" else orig="../freeswitch_$(mk_dver "$uver")~$(lsb_release -sc).orig.tar.xz" + git_archive_prefix="freeswitch-$uver/" fi mv .gitattributes .gitattributes.orig @@ -226,12 +231,32 @@ create_orig () { git add -f configure.ac .version git commit --allow-empty -m "nightly v$uver" + local tmpsrcdir="$(mktemp -d)" git archive -v \ --worktree-attributes \ --format=tar \ - --prefix=freeswitch-$uver/ \ - HEAD \ - | xz -c -${zl}v > $orig + --prefix=$git_archive_prefix \ + HEAD | tar --extract --directory="$tmpsrcdir" + + # https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html + tar \ + --sort=name \ + --format=posix \ + --pax-option='exthdr.name=%d/PaxHeaders/%f' \ + --pax-option='delete=atime,delete=ctime' \ + --clamp-mtime \ + --mtime="$source_date" \ + --numeric-owner \ + --owner=0 \ + --group=0 \ + --mode='go+u,go-w' \ + --create \ + --directory="$tmpsrcdir" \ + . | xz -v -c -${zl} > "$orig" && \ + rm -rf "$tmpsrcdir" + + echo "Source archive checksum:" + sha256sum $orig mv .gitattributes.orig .gitattributes diff --git a/src/include/switch_stun.h b/src/include/switch_stun.h index 54b03088e8..ca612c06aa 100644 --- a/src/include/switch_stun.h +++ b/src/include/switch_stun.h @@ -141,6 +141,13 @@ typedef struct { uint32_t address; } switch_stun_ip_t; +typedef struct { + uint8_t wasted; + uint8_t family; + uint16_t port; + uint8_t address[16]; +} switch_stun_ipv6_t; + #if SWITCH_BYTE_ORDER == __BIG_ENDIAN typedef struct { diff --git a/src/include/switch_types.h b/src/include/switch_types.h index f8ae00790d..c4c9131bd6 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -599,6 +599,13 @@ SWITCH_DECLARE_DATA extern switch_filenames SWITCH_GLOBAL_filenames; #define SWITCH_ACCEPTABLE_INTERVAL(_i) (_i && _i <= SWITCH_MAX_INTERVAL && (_i % 10) == 0) +/* Check if RAND_MAX is a power of 2 minus 1 or in other words all bits set */ +#if ((RAND_MAX) & ((RAND_MAX) + 1)) == 0 && (RAND_MAX) != 0 +#define SWITCH_RAND_MAX RAND_MAX +#else +#define SWITCH_RAND_MAX 0x7fff +#endif + typedef enum { SWITCH_RW_READ, SWITCH_RW_WRITE diff --git a/src/mod/databases/mod_mariadb/mariadb_dsn.cpp b/src/mod/databases/mod_mariadb/mariadb_dsn.cpp index eb7bfeedbd..aa7fb89412 100644 --- a/src/mod/databases/mod_mariadb/mariadb_dsn.cpp +++ b/src/mod/databases/mod_mariadb/mariadb_dsn.cpp @@ -81,13 +81,13 @@ public: std::string value = pair[1]; if ("server" == key || "host" == key) { - _host = value; + _host = std::move(value); } else if ("uid" == key || "user" == key || "username" == key) { - _user = value; + _user = std::move(value); } else if ("pwd" == key || "passwd" == key || "password" == key) { - _passwd = value; + _passwd = std::move(value); } else if ("database" == key || "db" == key) { - _db = value; + _db = std::move(value); } else if ("port" == key) { _port = std::stoi(value); } else if ("option" == key || "options" == key) { diff --git a/src/mod/databases/mod_mariadb/mod_mariadb.c b/src/mod/databases/mod_mariadb/mod_mariadb.c index 09b67468bb..c39c2ce818 100644 --- a/src/mod/databases/mod_mariadb/mod_mariadb.c +++ b/src/mod/databases/mod_mariadb/mod_mariadb.c @@ -641,7 +641,7 @@ switch_status_t mariadb_send_query(mariadb_handle_t *handle, const char* sql) switch_safe_free(err_str); /* We are waiting for 500 ms and random time is not more than 500 ms. This is necessary so that the delay on the primary and secondary servers does not coincide and deadlock does not occur again. */ - switch_yield(500 + (rand() & 511)); + switch_yield(500 + (switch_rand() & 511)); goto again; } diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 7cec120fbe..c09f650f5a 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -3401,6 +3401,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_SWITCH_MAX_MANAGEMENT_BUFFER } +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_SWITCH_RAND_MAX_get___() { + int jresult ; + int result; + + result = (int)(0x7fff); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_error_period_t_start_set___(void * jarg1, long long jarg2) { error_period *arg1 = (error_period *) 0 ; int64_t arg2 ; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 6ca27764cf..20bcbf4273 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -15184,6 +15184,7 @@ else public static readonly int SWITCH_MAX_STATE_HANDLERS = freeswitchPINVOKE.SWITCH_MAX_STATE_HANDLERS_get(); public static readonly int SWITCH_CORE_QUEUE_LEN = freeswitchPINVOKE.SWITCH_CORE_QUEUE_LEN_get(); public static readonly int SWITCH_MAX_MANAGEMENT_BUFFER_LEN = freeswitchPINVOKE.SWITCH_MAX_MANAGEMENT_BUFFER_LEN_get(); + public static readonly int SWITCH_RAND_MAX = freeswitchPINVOKE.SWITCH_RAND_MAX_get(); public static readonly int SWITCH_RTP_CNG_PAYLOAD = freeswitchPINVOKE.SWITCH_RTP_CNG_PAYLOAD_get(); public static readonly int SWITCH_MEDIA_TYPE_TOTAL = freeswitchPINVOKE.SWITCH_MEDIA_TYPE_TOTAL_get(); public static readonly int SWITCH_SOCK_INVALID = freeswitchPINVOKE.SWITCH_SOCK_INVALID_get(); @@ -16292,6 +16293,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_SWITCH_MAX_MANAGEMENT_BUFFER_LEN_get___")] public static extern int SWITCH_MAX_MANAGEMENT_BUFFER_LEN_get(); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_SWITCH_RAND_MAX_get___")] + public static extern int SWITCH_RAND_MAX_get(); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_error_period_t_start_set___")] public static extern void switch_error_period_t_start_set(global::System.Runtime.InteropServices.HandleRef jarg1, long jarg2); diff --git a/src/mod/languages/mod_v8/src/fssession.cpp b/src/mod/languages/mod_v8/src/fssession.cpp index d3bc77ae13..2510457175 100644 --- a/src/mod/languages/mod_v8/src/fssession.cpp +++ b/src/mod/languages/mod_v8/src/fssession.cpp @@ -671,7 +671,7 @@ JS_SESSION_FUNCTION_IMPL(SayPhrase) String::Utf8Value str(info[2]); tmp = js_safe_str(*str); if (!zstr(tmp.c_str())) { - phrase_lang = tmp; + phrase_lang = std::move(tmp); } } diff --git a/src/switch_core_port_allocator.c b/src/switch_core_port_allocator.c index 074ce5f5ea..2ed956c6fb 100644 --- a/src/switch_core_port_allocator.c +++ b/src/switch_core_port_allocator.c @@ -155,7 +155,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c uint32_t tries = 0; /* randomly pick a port */ - index = rand() % alloc->track_len; + index = switch_rand() % alloc->track_len; /* if it is used walk up the list to find a free one */ while (alloc->track[index] && tries < alloc->track_len) { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 1125e2f59b..46e13253b7 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -185,6 +185,10 @@ typedef struct { char body[SWITCH_RTCP_MAX_BUF_LEN]; } rtcp_msg_t; +typedef struct { + switch_rtcp_hdr_t header; + uint32_t ssrc; +} sdes_ssrc_t; typedef enum { VAD_FIRE_TALK = (1 << 0), @@ -2228,9 +2232,9 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) struct switch_rtcp_report_block *rtcp_report_block = NULL; switch_size_t rtcp_bytes = sizeof(struct switch_rtcp_hdr_s)+sizeof(uint32_t); /* add size of the packet header and the ssrc */ switch_rtcp_hdr_t *sdes; + sdes_ssrc_t *sdes_ssrc; uint8_t *p; switch_size_t sdes_bytes = sizeof(struct switch_rtcp_hdr_s); - uint32_t *ssrc; switch_rtcp_sdes_unit_t *unit; switch_bool_t is_only_receiver = FALSE; @@ -2426,14 +2430,13 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) //SDES + CNAME p = (uint8_t *) (&rtp_session->rtcp_send_msg) + rtcp_bytes; - sdes = (switch_rtcp_hdr_t *) p; + sdes_ssrc = (sdes_ssrc_t *) p; + sdes = &sdes_ssrc->header; sdes->version = 2; sdes->type = _RTCP_PT_SDES; sdes->count = 1; sdes->p = 0; - p = (uint8_t *) (sdes) + sdes_bytes; - ssrc = (uint32_t *) p; - *ssrc = htonl(rtp_session->ssrc); + sdes_ssrc->ssrc = htonl(rtp_session->ssrc); sdes_bytes += sizeof(uint32_t); @@ -4514,7 +4517,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session switch_sockaddr_create(&rtp_session->rtcp_from_addr, pool); } - rtp_session->seq = (uint16_t) rand(); + rtp_session->seq = (uint16_t) switch_rand(); rtp_session->ssrc = (uint32_t) ((intptr_t) rtp_session + (switch_time_t) switch_epoch_time_now(NULL)); #ifdef DEBUG_TS_ROLLOVER rtp_session->last_write_ts = TS_ROLLOVER_START; @@ -8264,11 +8267,11 @@ static int rtp_common_write(switch_rtp_t *rtp_session, if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { int external = (flags && *flags & SFF_EXTERNAL); /* Normalize the timestamps to our own base by generating a made up starting point then adding the measured deltas to that base - so if the timestamps and ssrc of the source change, it will not break the other end's jitter bufffer / decoder etc *cough* CHROME *cough* + so if the timestamps and ssrc of the source change, it will not break the other end's jitter buffer / decoder etc *cough* CHROME *cough* */ if (!rtp_session->ts_norm.ts) { - rtp_session->ts_norm.ts = (uint32_t) rand() % 1000000 + 1; + rtp_session->ts_norm.ts = (uint32_t) switch_rand() % 1000000 + 1; } if (!rtp_session->ts_norm.last_ssrc || send_msg->header.ssrc != rtp_session->ts_norm.last_ssrc || rtp_session->ts_norm.last_external != external) { @@ -8517,9 +8520,9 @@ static int rtp_common_write(switch_rtp_t *rtp_session, } if (!rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND_MKI]) { - stat = srtp_protect(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &send_msg->header, &sbytes); + stat = srtp_protect(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], send_msg, &sbytes); } else { - stat = srtp_protect_mki(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &send_msg->header, &sbytes, 1, SWITCH_CRYPTO_MKI_INDEX); + stat = srtp_protect_mki(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], send_msg, &sbytes, 1, SWITCH_CRYPTO_MKI_INDEX); } if (stat) { @@ -9041,9 +9044,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_write_raw(switch_rtp_t *rtp_session, } if (!rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND_MKI]) { - stat = srtp_protect(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &rtp_session->write_msg.header, &sbytes); + stat = srtp_protect(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &rtp_session->write_msg, &sbytes); } else { - stat = srtp_protect_mki(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &rtp_session->write_msg.header, &sbytes, 1, SWITCH_CRYPTO_MKI_INDEX); + stat = srtp_protect_mki(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &rtp_session->write_msg, &sbytes, 1, SWITCH_CRYPTO_MKI_INDEX); } if (stat) { diff --git a/src/switch_stun.c b/src/switch_stun.c index d4a2c96503..d58dd6fd93 100644 --- a/src/switch_stun.c +++ b/src/switch_stun.c @@ -135,7 +135,7 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se max = (int) strlen(set); for (x = 0; x < len; x++) { - int j = (int) (max * 1.0 * rand() / (RAND_MAX + 1.0)); + int j = (int) (max * 1.0 * switch_rand() / (SWITCH_RAND_MAX + 1.0)); buf[x] = set[j]; } } @@ -401,13 +401,17 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_s SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_xor_mapped_address(switch_stun_packet_attribute_t *attribute, switch_stun_packet_header_t *header, char *ipstr, switch_size_t iplen, uint16_t *port) { switch_stun_ip_t *ip; + switch_stun_ipv6_t *ipv6; uint8_t x, *i; char *p = ipstr; ip = (switch_stun_ip_t *) attribute->value; if (ip->family == 2) { - uint8_t *v6addr = (uint8_t *) &ip->address; + uint8_t *v6addr; + + ipv6 = (switch_stun_ipv6_t *)attribute->value; + v6addr = (uint8_t *) &ipv6->address; v6_xor(v6addr, (uint8_t *)header->id); inet_ntop(AF_INET6, v6addr, ipstr, iplen); } else { diff --git a/src/switch_utils.c b/src/switch_utils.c index 64577d3997..aa3fc74cae 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -1160,7 +1160,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, switch_safe_free(dupfile); } - switch_snprintf(filename, 80, "%s%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, (int)(switch_time_t) switch_epoch_time_now(NULL), rand() & 0xffff); + switch_snprintf(filename, 80, "%s%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, (int)(switch_time_t) switch_epoch_time_now(NULL), switch_rand() & 0xffff); if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644)) > -1) { if (file) { @@ -2015,7 +2015,7 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma } doh: - if (tmp_socket > 0) { + if (tmp_socket >= 0) { close(tmp_socket); } #endif @@ -4835,8 +4835,8 @@ SWITCH_DECLARE(int) switch_rand(void) BCryptCloseAlgorithmProvider(hAlgorithm, 0); - /* Make sure we return from 0 to RAND_MAX */ - return (random_number & 0x7FFF); + /* Make sure we return from 0 to SWITCH_RAND_MAX */ + return (random_number & (SWITCH_RAND_MAX)); #elif defined(__unix__) || defined(__APPLE__) int random_fd = open("/dev/urandom", O_RDONLY); ssize_t result; @@ -4865,8 +4865,8 @@ SWITCH_DECLARE(int) switch_rand(void) close(random_fd); - /* Make sure we return from 0 to RAND_MAX */ - return (random_number & 0x7FFF); + /* Make sure we return from 0 to SWITCH_RAND_MAX */ + return (random_number & (SWITCH_RAND_MAX)); #else return rand(); #endif