Compare commits
21 Commits
c7ae6490cc
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1547999ec0 | ||
|
|
e8a15a58dd | ||
|
|
2afa7a88a5 | ||
|
|
d5fb73d4a3 | ||
|
|
1f004cbd6d | ||
|
|
2f6f240ad9 | ||
|
|
596ea37298 | ||
|
|
e6da835fc0 | ||
|
|
0a26a76dc6 | ||
|
|
5a246b4515 | ||
|
|
478f2f112f | ||
|
|
9e9a270550 | ||
|
|
f9667430b9 | ||
|
|
9d7800bb4f | ||
|
|
54c0a3c874 | ||
|
|
8f1e872f1c | ||
|
|
d15dfd9e73 | ||
|
|
a091deddfe | ||
|
|
40ed05608e | ||
|
|
f49ad0b822 | ||
|
|
0c6ea8238c |
80
.github/workflows/cd.yml
vendored
80
.github/workflows/cd.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
run: sudo apt update && sudo apt -y install libsodium-dev cmake libasound2-dev libpulse-dev libjack-dev libsndio-dev libpipewire-0.3-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libwayland-dev libdecor-0-dev libvpx-dev libopus-dev liburing-dev
|
run: sudo apt update && sudo apt -y install libsodium-dev cmake libasound2-dev libpulse-dev libjack-dev libsndio-dev libpipewire-0.3-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libwayland-dev libdecor-0-dev libvpx-dev libopus-dev liburing-dev
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DTOMATO_BREAKPAD=ON -DTOMATO_TOX_AV=ON -DCMAKE_EXE_LINKER_FLAGS=-gz
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DTOMATO_BREAKPAD=ON -DTOMATO_TOX_AV=ON -DCMAKE_C_FLAGS=-gz -DCMAKE_CXX_FLAGS=-gz -DCMAKE_EXE_LINKER_FLAGS=-gz
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
@@ -34,15 +34,7 @@ jobs:
|
|||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
shell: bash
|
shell: bash
|
||||||
# taken from llama.cpp
|
run: . .github/workflows/tag_version.bash
|
||||||
run: |
|
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Compress artifacts
|
- name: Compress artifacts
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -78,12 +70,12 @@ jobs:
|
|||||||
ndk_abi: x86_64
|
ndk_abi: x86_64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
repository: 'Green-Sky/vcpkg_android_triplets'
|
repository: 'Green-Sky/vcpkg_android_triplets'
|
||||||
path: 'vcpkg_android_triplets'
|
path: 'vcpkg_android_triplets'
|
||||||
@@ -119,7 +111,7 @@ jobs:
|
|||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
env:
|
env:
|
||||||
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{matrix.platform.vcpkg_toolkit}} -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=${{matrix.platform.ndk_abi}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDL_ANDROID_JAR=ON -DSDLIMAGE_JPG_SHARED=OFF -DSDLIMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON -DTOMATO_TOX_AV=ON -DTOMATO_ANDROID_HAVE_DEBUG_KEYSTORE=ON -DCMAKE_EXE_LINKER_FLAGS=-gz
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{matrix.platform.vcpkg_toolkit}} -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=${{matrix.platform.ndk_abi}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDL_ANDROID_JAR=ON -DSDLIMAGE_JPG_SHARED=OFF -DSDLIMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON -DTOMATO_TOX_AV=ON -DTOMATO_ANDROID_HAVE_DEBUG_KEYSTORE=ON -DCMAKE_C_FLAGS=-gz -DCMAKE_CXX_FLAGS=-gz -DCMAKE_EXE_LINKER_FLAGS=-gz
|
||||||
|
|
||||||
- name: Build (tomato)
|
- name: Build (tomato)
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
@@ -141,15 +133,7 @@ jobs:
|
|||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
shell: bash
|
shell: bash
|
||||||
# taken from llama.cpp
|
run: . .github/workflows/tag_version.bash
|
||||||
run: |
|
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: rename apk
|
- name: rename apk
|
||||||
id: rename_apk
|
id: rename_apk
|
||||||
@@ -178,7 +162,7 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -204,8 +188,18 @@ jobs:
|
|||||||
#- uses: ilammy/setup-nasm@v1
|
#- uses: ilammy/setup-nasm@v1
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
|
env:
|
||||||
|
CXXFLAGS: "/D_MSVC_STL_HARDENING=1"
|
||||||
# TODO: og asan had this -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
|
# TODO: og asan had this -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_DEP_LIBWEBP_USE_SYSTEM=ON -DSDLIMAGE_VENDORED=OFF -DSDLIMAGE_DEPS_SHARED=OFF -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe -DTOMATO_BREAKPAD=ON -DTOMATO_TOX_AV=ON -DTOMATO_ASAN=${{matrix.type == 'asan' && 'ON' || 'OFF'}}
|
run: cmake -G Ninja
|
||||||
|
-B ${{github.workspace}}/build
|
||||||
|
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||||
|
-DTOMATO_DEP_LIBWEBP_USE_SYSTEM=ON
|
||||||
|
-DSDLIMAGE_VENDORED=OFF -DSDLIMAGE_DEPS_SHARED=OFF -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF
|
||||||
|
-DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
||||||
|
-DTOMATO_BREAKPAD=ON -DTOMATO_TOX_AV=ON
|
||||||
|
-DTOMATO_ASAN=${{matrix.type == 'asan' && 'ON' || 'OFF'}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tomato
|
||||||
@@ -213,15 +207,7 @@ jobs:
|
|||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
shell: bash
|
shell: bash
|
||||||
# taken from llama.cpp
|
run: . .github/workflows/tag_version.bash
|
||||||
run: |
|
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Clean temporary artifacts
|
- name: Clean temporary artifacts
|
||||||
# msvc sometimes produces .ilk files, which are used for linking only
|
# msvc sometimes produces .ilk files, which are used for linking only
|
||||||
@@ -265,22 +251,15 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
shell: bash
|
shell: bash
|
||||||
# taken from llama.cpp
|
run: . .github/workflows/tag_version.bash
|
||||||
run: |
|
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt update && sudo apt -y install unar
|
run: sudo apt update && sudo apt -y install unar
|
||||||
@@ -337,22 +316,15 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
shell: bash
|
shell: bash
|
||||||
# taken from llama.cpp
|
run: . .github/workflows/tag_version.bash
|
||||||
run: |
|
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
id: download-artifact
|
id: download-artifact
|
||||||
|
|||||||
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@@ -179,7 +179,15 @@ jobs:
|
|||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_DEP_LIBWEBP_USE_SYSTEM=ON -DSDLIMAGE_VENDORED=OFF -DSDLIMAGE_DEPS_SHARED=OFF -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
env:
|
||||||
|
CXXFLAGS: "/D_MSVC_STL_HARDENING=1"
|
||||||
|
run: cmake -G Ninja
|
||||||
|
-B ${{github.workspace}}/build
|
||||||
|
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||||
|
-DTOMATO_DEP_LIBWEBP_USE_SYSTEM=ON
|
||||||
|
-DSDLIMAGE_VENDORED=OFF -DSDLIMAGE_DEPS_SHARED=OFF -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF
|
||||||
|
-DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|||||||
10
.github/workflows/tag_version.bash
vendored
Executable file
10
.github/workflows/tag_version.bash
vendored
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
# taken from llama.cpp
|
||||||
|
# needs BRANCH_NAME set
|
||||||
|
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||||
|
DEPTH="$(git rev-list --count HEAD)"
|
||||||
|
if [[ "${BRANCH_NAME}" == "master" ]]; then
|
||||||
|
echo "name=dev-${DEPTH}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
SAFE_NAME=$(echo "${BRANCH_NAME}" | tr '/' '-')
|
||||||
|
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
7
external/imgui/CMakeLists.txt
vendored
7
external/imgui/CMakeLists.txt
vendored
@@ -8,10 +8,13 @@ endif()
|
|||||||
|
|
||||||
if (NOT TARGET imgui)
|
if (NOT TARGET imgui)
|
||||||
FetchContent_Declare(imgui
|
FetchContent_Declare(imgui
|
||||||
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
#GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
||||||
|
GIT_REPOSITORY https://github.com/Green-Sky/imgui.git
|
||||||
#GIT_TAG f5befd2d29e66809cd1110a152e375a7f1981f06 # v1.91.9b
|
#GIT_TAG f5befd2d29e66809cd1110a152e375a7f1981f06 # v1.91.9b
|
||||||
#GIT_TAG 85b2fe8486190fa9326565a2fb5fccb6caea4396 # v1.92.0
|
#GIT_TAG 85b2fe8486190fa9326565a2fb5fccb6caea4396 # v1.92.0
|
||||||
GIT_TAG 5d4126876bc10396d4c6511853ff10964414c776 # v1.92.1
|
#GIT_TAG 5d4126876bc10396d4c6511853ff10964414c776 # v1.92.1
|
||||||
|
#GIT_TAG bf75bfec48fc00f532af8926130b70c0e26eb099 # v1.92.3
|
||||||
|
GIT_TAG 349dbf9c57a15e2148fbfa7cb88df30280e0a362 # v1.92.3 + bitmap scaling patches
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
2
external/libwebp/CMakeLists.txt
vendored
2
external/libwebp/CMakeLists.txt
vendored
@@ -63,7 +63,7 @@ if (NOT TARGET WebP::libwebpmux)
|
|||||||
|
|
||||||
FetchContent_Declare(libwebp
|
FetchContent_Declare(libwebp
|
||||||
GIT_REPOSITORY https://github.com/webmproject/libwebp
|
GIT_REPOSITORY https://github.com/webmproject/libwebp
|
||||||
GIT_TAG v1.5.0
|
GIT_TAG v1.6.0
|
||||||
FIND_PACKAGE_ARGS
|
FIND_PACKAGE_ARGS
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(libwebp)
|
FetchContent_MakeAvailable(libwebp)
|
||||||
|
|||||||
4
external/sdl/CMakeLists.txt
vendored
4
external/sdl/CMakeLists.txt
vendored
@@ -54,7 +54,9 @@ if (NOT TARGET SDL3::SDL3)
|
|||||||
#GIT_TAG b5c3eab6b447111d3c7879bb547b80fb4abd9063 # tip 07-02-2025 (3.2.4)
|
#GIT_TAG b5c3eab6b447111d3c7879bb547b80fb4abd9063 # tip 07-02-2025 (3.2.4)
|
||||||
#GIT_TAG f6864924f76e1a0b4abaefc76ae2ed22b1a8916e # tip 05-03-2025 (3.2.8)
|
#GIT_TAG f6864924f76e1a0b4abaefc76ae2ed22b1a8916e # tip 05-03-2025 (3.2.8)
|
||||||
#GIT_TAG 877399b2b2cf21e67554ed9046410f268ce1d1b2 # 3.2.10
|
#GIT_TAG 877399b2b2cf21e67554ed9046410f268ce1d1b2 # 3.2.10
|
||||||
GIT_TAG 5ac37a8ffcf89da390404c1016833d56e2d67ae4 # 3.2.12
|
#GIT_TAG 5ac37a8ffcf89da390404c1016833d56e2d67ae4 # 3.2.12
|
||||||
|
#GIT_TAG a8589a84226a6202831a3d49ff4edda4acab9acd # 3.2.24
|
||||||
|
GIT_TAG badbf8da4ee72b3ef599c721ffc9899e8d7c8d90 # 3.2.26
|
||||||
|
|
||||||
FIND_PACKAGE_ARGS # for the future
|
FIND_PACKAGE_ARGS # for the future
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -125,15 +125,12 @@ jobs:
|
|||||||
cimple:
|
cimple:
|
||||||
working_directory: /tmp/cirrus-ci-build
|
working_directory: /tmp/cirrus-ci-build
|
||||||
docker:
|
docker:
|
||||||
- image: toxchat/toktok-stack:latest-release
|
- image: toxchat/toktok-stack:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run: git submodule update --init --recursive
|
- run:
|
||||||
- run: /src/workspace/tools/inject-repo c-toxcore
|
CIRCLE_JOB=release bash <(curl -s https://raw.githubusercontent.com/TokTok/ci-tools/refs/heads/master/tools/circleci-bazel-test)
|
||||||
- run: cd /src/workspace &&
|
|
||||||
bazel test
|
|
||||||
-k
|
|
||||||
--build_tag_filters=haskell
|
--build_tag_filters=haskell
|
||||||
--test_tag_filters=haskell
|
--test_tag_filters=haskell
|
||||||
--
|
--
|
||||||
|
|||||||
3
external/toxcore/c-toxcore/.cirrus.yml
vendored
3
external/toxcore/c-toxcore/.cirrus.yml
vendored
@@ -29,4 +29,5 @@ freebsd_task:
|
|||||||
-DAUTOTEST=ON \
|
-DAUTOTEST=ON \
|
||||||
-GNinja
|
-GNinja
|
||||||
cmake --build . --target install
|
cmake --build . --target install
|
||||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3 || ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3
|
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3 ||
|
||||||
|
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ FROM gcr.io/oss-fuzz-base/base-builder:latest
|
|||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get -y install --no-install-suggests --no-install-recommends \
|
&& apt-get -y install --no-install-suggests --no-install-recommends \
|
||||||
cmake \
|
cmake \
|
||||||
|
ninja-build \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -18,12 +18,18 @@ cd "$WORK"
|
|||||||
ls /usr/local/lib/
|
ls /usr/local/lib/
|
||||||
|
|
||||||
# Debug build for asserts
|
# Debug build for asserts
|
||||||
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CC" \
|
cmake -GNinja \
|
||||||
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
|
-DCMAKE_C_COMPILER="$CC" \
|
||||||
-DCMAKE_CXX_COMPILER="$CXX" \
|
-DCMAKE_CXX_COMPILER="$CXX" \
|
||||||
-DCMAKE_C_FLAGS="$CFLAGS" \
|
-DCMAKE_C_FLAGS="$CFLAGS" \
|
||||||
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
|
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
|
||||||
-DBUILD_TOXAV=OFF -DENABLE_SHARED=NO -DBUILD_FUZZ_TESTS=ON \
|
-DBUILD_TOXAV=OFF \
|
||||||
-DDHT_BOOTSTRAP=OFF -DBOOTSTRAP_DAEMON=OFF "$SRC"/c-toxcore
|
-DENABLE_SHARED=OFF \
|
||||||
|
-DBUILD_FUZZ_TESTS=ON \
|
||||||
|
-DDHT_BOOTSTRAP=OFF \
|
||||||
|
-DBOOTSTRAP_DAEMON=OFF \
|
||||||
|
"$SRC"/c-toxcore
|
||||||
|
|
||||||
for TARGET in "${FUZZ_TARGETS[@]}"; do
|
for TARGET in "${FUZZ_TARGETS[@]}"; do
|
||||||
# build fuzzer target
|
# build fuzzer target
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ brew update
|
|||||||
brew install \
|
brew install \
|
||||||
libconfig \
|
libconfig \
|
||||||
libvpx \
|
libvpx \
|
||||||
|
ninja \
|
||||||
opus
|
opus
|
||||||
|
|
||||||
. ".github/scripts/flags-clang.sh"
|
. ".github/scripts/flags-clang.sh"
|
||||||
@@ -23,8 +24,9 @@ add_flag -Werror
|
|||||||
# C99-only compilers we test against anyway. Anything that passes all the
|
# C99-only compilers we test against anyway. Anything that passes all the
|
||||||
# compilers we use is fine.
|
# compilers we use is fine.
|
||||||
add_c_flag -Wno-c11-extensions
|
add_c_flag -Wno-c11-extensions
|
||||||
|
add_c_flag -Wno-pre-c11-compat
|
||||||
|
|
||||||
cmake -B_build -H. \
|
cmake -GNinja -B_build -H. \
|
||||||
-DCMAKE_C_FLAGS="$C_FLAGS" \
|
-DCMAKE_C_FLAGS="$C_FLAGS" \
|
||||||
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
|
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
|
||||||
@@ -37,8 +39,10 @@ cmake -B_build -H. \
|
|||||||
-DUSE_IPV6=OFF \
|
-DUSE_IPV6=OFF \
|
||||||
-DAUTOTEST=ON
|
-DAUTOTEST=ON
|
||||||
|
|
||||||
cd _build # pushd
|
cmake --build _build
|
||||||
make "-j$NPROC" -k install
|
cmake --install _build
|
||||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 ||
|
|
||||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
|
# TODO(iphydf): Investigate if we can get lan discovery to work on macos CI.
|
||||||
cd - # popd
|
# It works, but CI doesn't let us press the "allow broadcast" button.
|
||||||
|
ctest --test-dir _build -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery ||
|
||||||
|
ctest --test-dir _build -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ add_flag -Weverything
|
|||||||
|
|
||||||
# Disable specific warning flags for both C and C++.
|
# Disable specific warning flags for both C and C++.
|
||||||
|
|
||||||
|
# We're not checking nullability, yet.
|
||||||
|
# TODO(iphydf): Remove.
|
||||||
|
add_flag -Wno-nullable-to-nonnull-conversion
|
||||||
|
add_flag -Wno-nullability-completeness
|
||||||
|
|
||||||
# Very verbose, not very useful. This warns about things like int -> uint
|
# Very verbose, not very useful. This warns about things like int -> uint
|
||||||
# conversions that change sign without a cast and narrowing conversions.
|
# conversions that change sign without a cast and narrowing conversions.
|
||||||
add_flag -Wno-conversion
|
add_flag -Wno-conversion
|
||||||
@@ -30,6 +35,8 @@ add_flag -Wno-missing-braces
|
|||||||
add_flag -Wno-missing-field-initializers
|
add_flag -Wno-missing-field-initializers
|
||||||
# We don't use this attribute. It appears in the non-NDEBUG stderr logger.
|
# We don't use this attribute. It appears in the non-NDEBUG stderr logger.
|
||||||
add_flag -Wno-missing-noreturn
|
add_flag -Wno-missing-noreturn
|
||||||
|
# We want to use this extension.
|
||||||
|
add_flag -Wno-nullability-extension
|
||||||
# Useful sometimes, but we accept padding in structs for clarity.
|
# Useful sometimes, but we accept padding in structs for clarity.
|
||||||
# Reordering fields to avoid padding will reduce readability.
|
# Reordering fields to avoid padding will reduce readability.
|
||||||
add_flag -Wno-padded
|
add_flag -Wno-padded
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ add_ld_flag -Wl,-z,defs
|
|||||||
add_flag -Werror
|
add_flag -Werror
|
||||||
|
|
||||||
cmake -B_build -H. -GNinja \
|
cmake -B_build -H. -GNinja \
|
||||||
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||||
-DCMAKE_C_FLAGS="$C_FLAGS" \
|
-DCMAKE_C_FLAGS="$C_FLAGS" \
|
||||||
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
|
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
build-windows-msvc:
|
build-windows-msvc:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: [2019, 2022]
|
version: [2022, 2025]
|
||||||
runs-on: windows-${{ matrix.version }}
|
runs-on: windows-${{ matrix.version }}
|
||||||
env:
|
env:
|
||||||
VCPKG_ROOT: "C:/vcpkg"
|
VCPKG_ROOT: "C:/vcpkg"
|
||||||
@@ -116,12 +116,12 @@ jobs:
|
|||||||
libopus
|
libopus
|
||||||
libsodium
|
libsodium
|
||||||
libvpx
|
libvpx
|
||||||
ninja
|
ninja-build
|
||||||
pkg-config
|
pkg-config
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
# TODO(iphydf): Investigate NetBSD failures on these tests.
|
# TODO(iphydf): Investigate NetBSD failures on these tests.
|
||||||
sed -Ei -e '/\((TCP|dht_nodes_response_api)\)/s/^/#/' auto_tests/CMakeLists.txt
|
sed -Ei -e '/\((TCP|dht_nodes_response_api|tcp_relay)\)/s/^/#/' auto_tests/CMakeLists.txt
|
||||||
cmake . \
|
cmake . \
|
||||||
-DMIN_LOGGER_LEVEL=TRACE \
|
-DMIN_LOGGER_LEVEL=TRACE \
|
||||||
-DMUST_BUILD_TOXAV=ON \
|
-DMUST_BUILD_TOXAV=ON \
|
||||||
|
|||||||
@@ -345,14 +345,12 @@ jobs:
|
|||||||
uses: TokTok/ci-tools/.github/workflows/deploy-artifact.yml@master
|
uses: TokTok/ci-tools/.github/workflows/deploy-artifact.yml@master
|
||||||
with:
|
with:
|
||||||
project-name: toxcore
|
project-name: toxcore
|
||||||
artifact-source: tox-*.tar.{gz,xz}
|
artifact-source: toxcore.tar.{gz,xz}
|
||||||
artifact-versioned: $VERSION.tar.{gz,xz}
|
artifact-versioned: c-toxcore-$VERSION.tar.{gz,xz}
|
||||||
build: tarball
|
build: tarball
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -y --no-install-recommends libsodium-dev
|
sudo apt-get install -y --no-install-recommends libsodium-dev
|
||||||
autoreconf -fi
|
autoreconf -fi
|
||||||
./configure
|
touch toxcore.tar.gz # prevent error of file changes
|
||||||
make dist
|
tar --exclude-vcs --exclude='toxcore.tar.gz' --exclude='third_party/ci-tools' --exclude='*.github' --exclude='autom4te.cache' -zcvf toxcore.tar.gz .
|
||||||
for f in tox-*.tar.gz; do
|
gunzip -c toxcore.tar.gz | xz -z - >"toxcore.tar.xz"
|
||||||
gunzip -c "$f" | xz -z - >"${f%.gz}.xz"
|
|
||||||
done
|
|
||||||
|
|||||||
@@ -8,50 +8,34 @@ on:
|
|||||||
|
|
||||||
# Cancel old PR builds when pushing new commits.
|
# Cancel old PR builds when pushing new commits.
|
||||||
concurrency:
|
concurrency:
|
||||||
group: scan-${{ github.event.pull_request.number || github.ref }}
|
group: sonar-scan-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sonar-scan:
|
sonar-scan:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
SONAR_SCANNER_VERSION: 5.0.1.3006
|
|
||||||
SONAR_SERVER_URL: "https://sonarcloud.io"
|
|
||||||
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
|
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
- name: Set up JDK 17
|
- name: Install Build Wrapper
|
||||||
uses: actions/setup-java@v2
|
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6
|
||||||
with:
|
|
||||||
distribution: "zulu"
|
|
||||||
java-version: 17
|
|
||||||
- name: Download and set up sonar-scanner
|
|
||||||
env:
|
|
||||||
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
|
|
||||||
run: |
|
|
||||||
mkdir -p $HOME/.sonar
|
|
||||||
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
|
|
||||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
|
|
||||||
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
|
|
||||||
- name: Download and set up build-wrapper
|
|
||||||
env:
|
|
||||||
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
|
|
||||||
run: |
|
|
||||||
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
|
|
||||||
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
|
|
||||||
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
|
|
||||||
- name: Install dependencies and prepare build
|
- name: Install dependencies and prepare build
|
||||||
run: |
|
run: |
|
||||||
.github/scripts/sonar-prepare
|
.github/scripts/sonar-prepare
|
||||||
- name: Run build-wrapper
|
- name: Run Build Wrapper
|
||||||
run: |
|
run: |
|
||||||
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} .github/scripts/sonar-build
|
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} .github/scripts/sonar-build
|
||||||
- name: Run sonar-scanner
|
- name: Ensure compile_commands.json is generated
|
||||||
|
run: ls -l "${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
|
||||||
|
- name: SonarQube Scan
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
|
uses: SonarSource/sonarqube-scan-action@v6
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
run: 'sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"'
|
with:
|
||||||
|
args: >
|
||||||
|
--define "sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
|
||||||
|
|||||||
16
external/toxcore/c-toxcore/CMakeLists.txt
vendored
16
external/toxcore/c-toxcore/CMakeLists.txt
vendored
@@ -309,6 +309,8 @@ set(toxcore_SOURCES
|
|||||||
toxcore/mono_time.h
|
toxcore/mono_time.h
|
||||||
toxcore/net_crypto.c
|
toxcore/net_crypto.c
|
||||||
toxcore/net_crypto.h
|
toxcore/net_crypto.h
|
||||||
|
toxcore/net_log.c
|
||||||
|
toxcore/net_log.h
|
||||||
toxcore/net_profile.c
|
toxcore/net_profile.c
|
||||||
toxcore/net_profile.h
|
toxcore/net_profile.h
|
||||||
toxcore/network.c
|
toxcore/network.c
|
||||||
@@ -319,6 +321,10 @@ set(toxcore_SOURCES
|
|||||||
toxcore/onion_client.c
|
toxcore/onion_client.c
|
||||||
toxcore/onion_client.h
|
toxcore/onion_client.h
|
||||||
toxcore/onion.h
|
toxcore/onion.h
|
||||||
|
toxcore/os_memory.c
|
||||||
|
toxcore/os_memory.h
|
||||||
|
toxcore/os_random.c
|
||||||
|
toxcore/os_random.h
|
||||||
toxcore/ping_array.c
|
toxcore/ping_array.c
|
||||||
toxcore/ping_array.h
|
toxcore/ping_array.h
|
||||||
toxcore/ping.c
|
toxcore/ping.c
|
||||||
@@ -340,6 +346,7 @@ set(toxcore_SOURCES
|
|||||||
toxcore/timed_auth.c
|
toxcore/timed_auth.c
|
||||||
toxcore/timed_auth.h
|
toxcore/timed_auth.h
|
||||||
toxcore/tox_api.c
|
toxcore/tox_api.c
|
||||||
|
toxcore/tox_attributes.h
|
||||||
toxcore/tox.c
|
toxcore/tox.c
|
||||||
toxcore/tox.h
|
toxcore/tox.h
|
||||||
toxcore/tox_dispatch.c
|
toxcore/tox_dispatch.c
|
||||||
@@ -350,12 +357,18 @@ set(toxcore_SOURCES
|
|||||||
toxcore/tox_events.h
|
toxcore/tox_events.h
|
||||||
toxcore/tox_log_level.c
|
toxcore/tox_log_level.c
|
||||||
toxcore/tox_log_level.h
|
toxcore/tox_log_level.h
|
||||||
|
toxcore/tox_memory.c
|
||||||
|
toxcore/tox_memory.h
|
||||||
|
toxcore/tox_memory_impl.h
|
||||||
toxcore/tox_options.c
|
toxcore/tox_options.c
|
||||||
toxcore/tox_options.h
|
toxcore/tox_options.h
|
||||||
toxcore/tox_private.c
|
toxcore/tox_private.c
|
||||||
toxcore/tox_private.h
|
toxcore/tox_private.h
|
||||||
toxcore/tox_pack.c
|
toxcore/tox_pack.c
|
||||||
toxcore/tox_pack.h
|
toxcore/tox_pack.h
|
||||||
|
toxcore/tox_random.c
|
||||||
|
toxcore/tox_random.h
|
||||||
|
toxcore/tox_random_impl.h
|
||||||
toxcore/tox_unpack.c
|
toxcore/tox_unpack.c
|
||||||
toxcore/tox_unpack.h
|
toxcore/tox_unpack.h
|
||||||
toxcore/util.c
|
toxcore/util.c
|
||||||
@@ -379,7 +392,8 @@ if(EXPERIMENTAL_API)
|
|||||||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||||
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
|
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
|
||||||
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
|
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
|
||||||
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)
|
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox
|
||||||
|
${toxcore_SOURCE_DIR}/toxcore/tox_random.h^tox)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
24
external/toxcore/c-toxcore/auto_tests/TCP_test.c
vendored
24
external/toxcore/c-toxcore/auto_tests/TCP_test.c
vendored
@@ -10,6 +10,8 @@
|
|||||||
#include "../toxcore/mono_time.h"
|
#include "../toxcore/mono_time.h"
|
||||||
#include "../toxcore/net_profile.h"
|
#include "../toxcore/net_profile.h"
|
||||||
#include "../toxcore/network.h"
|
#include "../toxcore/network.h"
|
||||||
|
#include "../toxcore/os_memory.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
|
|
||||||
#define NUM_PORTS 3
|
#define NUM_PORTS 3
|
||||||
@@ -544,8 +546,8 @@ static void test_client(void)
|
|||||||
|
|
||||||
// The connection status should be unconfirmed here because we have finished
|
// The connection status should be unconfirmed here because we have finished
|
||||||
// sending our data and are awaiting a response.
|
// sending our data and are awaiting a response.
|
||||||
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_UNCONFIRMED, "Wrong connection status. Expected: %d, is: %d.",
|
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_UNCONFIRMED, "Wrong connection status. Expected: %u, is: %u.",
|
||||||
TCP_CLIENT_UNCONFIRMED, tcp_con_status(conn));
|
(unsigned int)TCP_CLIENT_UNCONFIRMED, tcp_con_status(conn));
|
||||||
|
|
||||||
do_tcp_server_delay(tcp_s, mono_time, 50); // Now let the server handle requests...
|
do_tcp_server_delay(tcp_s, mono_time, 50); // Now let the server handle requests...
|
||||||
|
|
||||||
@@ -556,8 +558,8 @@ static void test_client(void)
|
|||||||
do_tcp_connection(logger, mono_time, conn, nullptr); // Run the connection loop.
|
do_tcp_connection(logger, mono_time, conn, nullptr); // Run the connection loop.
|
||||||
|
|
||||||
// The status of the connection should continue to be TCP_CLIENT_CONFIRMED after multiple subsequent do_tcp_connection() calls.
|
// The status of the connection should continue to be TCP_CLIENT_CONFIRMED after multiple subsequent do_tcp_connection() calls.
|
||||||
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong connection status. Expected: %d, is: %d",
|
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong connection status. Expected: %u, is: %u",
|
||||||
TCP_CLIENT_CONFIRMED, tcp_con_status(conn));
|
(unsigned int)TCP_CLIENT_CONFIRMED, tcp_con_status(conn));
|
||||||
|
|
||||||
c_sleep(i == loop_size - 1 ? 0 : 500); // Sleep for 500ms on all except third loop.
|
c_sleep(i == loop_size - 1 ? 0 : 500); // Sleep for 500ms on all except third loop.
|
||||||
}
|
}
|
||||||
@@ -565,7 +567,7 @@ static void test_client(void)
|
|||||||
do_tcp_server_delay(tcp_s, mono_time, 50);
|
do_tcp_server_delay(tcp_s, mono_time, 50);
|
||||||
|
|
||||||
// And still after the server runs again.
|
// And still after the server runs again.
|
||||||
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %d, is: %d", TCP_CLIENT_CONFIRMED,
|
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", (unsigned int)TCP_CLIENT_CONFIRMED,
|
||||||
tcp_con_status(conn));
|
tcp_con_status(conn));
|
||||||
|
|
||||||
uint8_t f2_public_key[CRYPTO_PUBLIC_KEY_SIZE];
|
uint8_t f2_public_key[CRYPTO_PUBLIC_KEY_SIZE];
|
||||||
@@ -680,20 +682,20 @@ static void test_client_invalid(void)
|
|||||||
c_sleep(50);
|
c_sleep(50);
|
||||||
|
|
||||||
// After 50ms of no response...
|
// After 50ms of no response...
|
||||||
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %d, is: %d.",
|
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u.",
|
||||||
TCP_CLIENT_CONNECTING, tcp_con_status(conn));
|
(unsigned int)TCP_CLIENT_CONNECTING, tcp_con_status(conn));
|
||||||
// After 5s...
|
// After 5s...
|
||||||
c_sleep(5000);
|
c_sleep(5000);
|
||||||
mono_time_update(mono_time);
|
mono_time_update(mono_time);
|
||||||
do_tcp_connection(logger, mono_time, conn, nullptr);
|
do_tcp_connection(logger, mono_time, conn, nullptr);
|
||||||
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %d, is: %d.",
|
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u.",
|
||||||
TCP_CLIENT_CONNECTING, tcp_con_status(conn));
|
(unsigned int)TCP_CLIENT_CONNECTING, tcp_con_status(conn));
|
||||||
// 11s... (Should wait for 10 before giving up.)
|
// 11s... (Should wait for 10 before giving up.)
|
||||||
c_sleep(6000);
|
c_sleep(6000);
|
||||||
mono_time_update(mono_time);
|
mono_time_update(mono_time);
|
||||||
do_tcp_connection(logger, mono_time, conn, nullptr);
|
do_tcp_connection(logger, mono_time, conn, nullptr);
|
||||||
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %d, is: %d.",
|
ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %u, is: %u.",
|
||||||
TCP_CLIENT_DISCONNECTED, tcp_con_status(conn));
|
(unsigned int)TCP_CLIENT_DISCONNECTED, tcp_con_status(conn));
|
||||||
|
|
||||||
kill_tcp_connection(conn);
|
kill_tcp_connection(conn);
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../toxcore/announce.h"
|
#include "../toxcore/announce.h"
|
||||||
#include "../toxcore/tox.h"
|
|
||||||
#include "../testing/misc_tools.h"
|
|
||||||
#include "../toxcore/mono_time.h"
|
#include "../toxcore/mono_time.h"
|
||||||
#include "../toxcore/forwarding.h"
|
#include "../toxcore/forwarding.h"
|
||||||
#include "../toxcore/net_crypto.h"
|
#include "../toxcore/os_memory.h"
|
||||||
#include "../toxcore/util.h"
|
#include "../toxcore/os_random.h"
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
@@ -66,9 +64,9 @@ static void test_store_data(void)
|
|||||||
ck_assert(net != nullptr);
|
ck_assert(net != nullptr);
|
||||||
DHT *dht = new_dht(log, mem, rng, ns, mono_time, net, true, true);
|
DHT *dht = new_dht(log, mem, rng, ns, mono_time, net, true, true);
|
||||||
ck_assert(dht != nullptr);
|
ck_assert(dht != nullptr);
|
||||||
Forwarding *forwarding = new_forwarding(log, mem, rng, mono_time, dht);
|
Forwarding *forwarding = new_forwarding(log, mem, rng, mono_time, dht, net);
|
||||||
ck_assert(forwarding != nullptr);
|
ck_assert(forwarding != nullptr);
|
||||||
Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding);
|
Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding, dht, net);
|
||||||
ck_assert(announce != nullptr);
|
ck_assert(announce != nullptr);
|
||||||
|
|
||||||
/* Just to prevent CI from complaining that set_synch_offset is unused: */
|
/* Just to prevent CI from complaining that set_synch_offset is unused: */
|
||||||
|
|||||||
@@ -79,14 +79,14 @@ void bootstrap_tox_live_network(Tox *tox, bool enable_tcp)
|
|||||||
tox_bootstrap(tox, ip, port, key, &err);
|
tox_bootstrap(tox, ip, port, key, &err);
|
||||||
|
|
||||||
if (err != TOX_ERR_BOOTSTRAP_OK) {
|
if (err != TOX_ERR_BOOTSTRAP_OK) {
|
||||||
fprintf(stderr, "Failed to bootstrap node %zu (%s): error %d\n", j, ip, err);
|
fprintf(stderr, "Failed to bootstrap node %zu (%s): error %u\n", j, ip, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_tcp) {
|
if (enable_tcp) {
|
||||||
tox_add_tcp_relay(tox, ip, port, key, &err);
|
tox_add_tcp_relay(tox, ip, port, key, &err);
|
||||||
|
|
||||||
if (err != TOX_ERR_BOOTSTRAP_OK) {
|
if (err != TOX_ERR_BOOTSTRAP_OK) {
|
||||||
fprintf(stderr, "Failed to add TCP relay %zu (%s): error %d\n", j, ip, err);
|
fprintf(stderr, "Failed to add TCP relay %zu (%s): error %u\n", j, ip, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,7 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
|||||||
tox_options_set_tcp_port(options, 0);
|
tox_options_set_tcp_port(options, 0);
|
||||||
autotest_opts->tcp_port = 0;
|
autotest_opts->tcp_port = 0;
|
||||||
autotox->tox = tox_new_log(options, &err, &autotox->index);
|
autotox->tox = tox_new_log(options, &err, &autotox->index);
|
||||||
ck_assert_msg(err == TOX_ERR_NEW_OK, "unexpected tox_new error: %d", err);
|
ck_assert_msg(err == TOX_ERR_NEW_OK, "unexpected tox_new error: %u", err);
|
||||||
} else {
|
} else {
|
||||||
// Try a few ports for the TCP relay.
|
// Try a few ports for the TCP relay.
|
||||||
for (uint16_t tcp_port = autotest_opts->tcp_port; tcp_port < autotest_opts->tcp_port + 200; ++tcp_port) {
|
for (uint16_t tcp_port = autotest_opts->tcp_port; tcp_port < autotest_opts->tcp_port + 200; ++tcp_port) {
|
||||||
@@ -259,7 +259,7 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(err == TOX_ERR_NEW_PORT_ALLOC, "unexpected tox_new error (expected PORT_ALLOC): %d", err);
|
ck_assert_msg(err == TOX_ERR_NEW_PORT_ALLOC, "unexpected tox_new error (expected PORT_ALLOC): %u", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
|||||||
autotox->tox = tox_new_log(options, &err, &autotox->index);
|
autotox->tox = tox_new_log(options, &err, &autotox->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(autotox->tox != nullptr, "failed to create tox instance #%u (error = %d)", index, err);
|
ck_assert_msg(autotox->tox != nullptr, "failed to create tox instance #%u (error = %u)", index, err);
|
||||||
|
|
||||||
set_mono_time_callback(autotox);
|
set_mono_time_callback(autotox);
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ static void bootstrap_autotoxes(const Tox_Options *options, uint32_t tox_count,
|
|||||||
for (uint32_t i = 1; i < tox_count; ++i) {
|
for (uint32_t i = 1; i < tox_count; ++i) {
|
||||||
Tox_Err_Bootstrap err;
|
Tox_Err_Bootstrap err;
|
||||||
tox_bootstrap(autotoxes[i].tox, "localhost", dht_port, dht_key, &err);
|
tox_bootstrap(autotoxes[i].tox, "localhost", dht_port, dht_key, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_BOOTSTRAP_OK, "bootstrap error for port %d: %d", dht_port, err);
|
ck_assert_msg(err == TOX_ERR_BOOTSTRAP_OK, "bootstrap error for port %d: %u", dht_port, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!udp_enabled) {
|
if (!udp_enabled) {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ int main(void)
|
|||||||
|
|
||||||
const Tox_Connection status = tox_self_get_connection_status(tox_udp);
|
const Tox_Connection status = tox_self_get_connection_status(tox_udp);
|
||||||
ck_assert_msg(status == TOX_CONNECTION_UDP,
|
ck_assert_msg(status == TOX_CONNECTION_UDP,
|
||||||
"expected connection status to be UDP, but got %d", status);
|
"expected connection status to be UDP, but got %u", status);
|
||||||
printf("Connection (UDP): %d\n", tox_self_get_connection_status(tox_udp));
|
printf("Connection (UDP): %u\n", tox_self_get_connection_status(tox_udp));
|
||||||
|
|
||||||
tox_kill(tox_udp);
|
tox_kill(tox_udp);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "../toxav/toxav.h"
|
#include "../toxav/toxav.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
#define NUM_AV_GROUP_TOX 16
|
#define NUM_AV_GROUP_TOX 16
|
||||||
@@ -83,7 +84,7 @@ static void handle_conference_invite(
|
|||||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||||
|
|
||||||
ck_assert_msg(type == TOX_CONFERENCE_TYPE_AV, "tox #%u: wrong conference type: %d", autotox->index, type);
|
ck_assert_msg(type == TOX_CONFERENCE_TYPE_AV, "tox #%u: wrong conference type: %u", autotox->index, type);
|
||||||
|
|
||||||
ck_assert_msg(toxav_join_av_groupchat(autotox->tox, friend_number, cookie, length, audio_callback, user_data) == 0,
|
ck_assert_msg(toxav_join_av_groupchat(autotox->tox, friend_number, cookie, length, audio_callback, user_data) == 0,
|
||||||
"tox #%u: failed to join group", autotox->index);
|
"tox #%u: failed to join group", autotox->index);
|
||||||
@@ -101,7 +102,7 @@ static void handle_conference_connected(
|
|||||||
|
|
||||||
Tox_Err_Conference_Invite err;
|
Tox_Err_Conference_Invite err;
|
||||||
tox_conference_invite(autotox->tox, 1, 0, &err);
|
tox_conference_invite(autotox->tox, 1, 0, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox #%u failed to invite next friend: err = %d", autotox->index,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox #%u failed to invite next friend: err = %u", autotox->index,
|
||||||
err);
|
err);
|
||||||
printf("tox #%u: invited next friend\n", autotox->index);
|
printf("tox #%u: invited next friend\n", autotox->index);
|
||||||
state->invited_next = true;
|
state->invited_next = true;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ static void handle_conference_invite(
|
|||||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||||
|
|
||||||
fprintf(stderr, "handle_conference_invite(#%u, %u, %d, uint8_t[%u], _)\n",
|
fprintf(stderr, "handle_conference_invite(#%u, %u, %u, uint8_t[%u], _)\n",
|
||||||
autotox->index, friend_number, type, (unsigned)length);
|
autotox->index, friend_number, type, (unsigned)length);
|
||||||
fprintf(stderr, "tox%u joining conference\n", autotox->index);
|
fprintf(stderr, "tox%u joining conference\n", autotox->index);
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ static void handle_conference_invite(
|
|||||||
Tox_Err_Conference_Join err;
|
Tox_Err_Conference_Join err;
|
||||||
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
||||||
"attempting to join the conference returned with an error: %d", err);
|
"attempting to join the conference returned with an error: %u", err);
|
||||||
fprintf(stderr, "tox%u joined conference %u\n", autotox->index, state->conference);
|
fprintf(stderr, "tox%u joined conference %u\n", autotox->index, state->conference);
|
||||||
state->joined = true;
|
state->joined = true;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ static void conference_double_invite_test(AutoTox *autotoxes)
|
|||||||
state[0]->conference = tox_conference_new(autotoxes[0].tox, &err);
|
state[0]->conference = tox_conference_new(autotoxes[0].tox, &err);
|
||||||
state[0]->joined = true;
|
state[0]->joined = true;
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK,
|
||||||
"attempting to create a new conference returned with an error: %d", err);
|
"attempting to create a new conference returned with an error: %u", err);
|
||||||
fprintf(stderr, "Created conference: index=%u\n", state[0]->conference);
|
fprintf(stderr, "Created conference: index=%u\n", state[0]->conference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ static void conference_double_invite_test(AutoTox *autotoxes)
|
|||||||
Tox_Err_Conference_Invite err;
|
Tox_Err_Conference_Invite err;
|
||||||
tox_conference_invite(autotoxes[0].tox, 0, state[0]->conference, &err);
|
tox_conference_invite(autotoxes[0].tox, 0, state[0]->conference, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK,
|
||||||
"attempting to invite a friend returned with an error: %d", err);
|
"attempting to invite a friend returned with an error: %u", err);
|
||||||
fprintf(stderr, "tox0 invited tox1\n");
|
fprintf(stderr, "tox0 invited tox1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ static void handle_conference_invite(
|
|||||||
Tox_Err_Conference_Join err;
|
Tox_Err_Conference_Join err;
|
||||||
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
||||||
"attempting to join the conference returned with an error: %d", err);
|
"attempting to join the conference returned with an error: %u", err);
|
||||||
fprintf(stderr, "#%u accepted invite to conference %u\n", autotox->index, state->conference);
|
fprintf(stderr, "#%u accepted invite to conference %u\n", autotox->index, state->conference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ static void do_invite(AutoTox *autotoxes, AutoTox *inviter, AutoTox *invitee, ui
|
|||||||
Tox_Err_Conference_Invite err;
|
Tox_Err_Conference_Invite err;
|
||||||
tox_conference_invite(inviter->tox, friendnum, ((State *)inviter->state)->conference, &err);
|
tox_conference_invite(inviter->tox, friendnum, ((State *)inviter->state)->conference, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK,
|
||||||
"#%u attempting to invite #%u (friendnumber %u) returned with an error: %d", inviter->index, invitee->index,
|
"#%u attempting to invite #%u (friendnumber %u) returned with an error: %u", inviter->index, invitee->index,
|
||||||
friendnum, err);
|
friendnum, err);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -110,7 +110,7 @@ static void conference_invite_merge_test(AutoTox *autotoxes)
|
|||||||
state2->conference = tox_conference_new(autotoxes[2].tox, &err);
|
state2->conference = tox_conference_new(autotoxes[2].tox, &err);
|
||||||
state2->connected = true;
|
state2->connected = true;
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK,
|
||||||
"attempting to create a new conference returned with an error: %d", err);
|
"attempting to create a new conference returned with an error: %u", err);
|
||||||
fprintf(stderr, "Created conference: index=%u\n", state2->conference);
|
fprintf(stderr, "Created conference: index=%u\n", state2->conference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ static void handle_conference_invite(
|
|||||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||||
|
|
||||||
fprintf(stderr, "handle_conference_invite(#%u, %u, %d, uint8_t[%u], _)\n",
|
fprintf(stderr, "handle_conference_invite(#%u, %u, %u, uint8_t[%u], _)\n",
|
||||||
autotox->index, friend_number, type, (unsigned)length);
|
autotox->index, friend_number, type, (unsigned)length);
|
||||||
fprintf(stderr, "tox%u joining conference\n", autotox->index);
|
fprintf(stderr, "tox%u joining conference\n", autotox->index);
|
||||||
|
|
||||||
Tox_Err_Conference_Join err;
|
Tox_Err_Conference_Join err;
|
||||||
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
||||||
"attempting to join the conference returned with an error: %d", err);
|
"attempting to join the conference returned with an error: %u", err);
|
||||||
fprintf(stderr, "tox%u joined conference %u\n", autotox->index, state->conference);
|
fprintf(stderr, "tox%u joined conference %u\n", autotox->index, state->conference);
|
||||||
state->joined = true;
|
state->joined = true;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ static void handle_peer_list_changed(const Tox_Event_Conference_Peer_List_Change
|
|||||||
Tox_Err_Conference_Peer_Query err;
|
Tox_Err_Conference_Peer_Query err;
|
||||||
uint32_t const count = tox_conference_peer_count(autotox->tox, conference_number, &err);
|
uint32_t const count = tox_conference_peer_count(autotox->tox, conference_number, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
||||||
"failed to get conference peer count: err = %d", err);
|
"failed to get conference peer count: err = %u", err);
|
||||||
printf("tox%u has %u peers\n", autotox->index, count);
|
printf("tox%u has %u peers\n", autotox->index, count);
|
||||||
state->friend_in_group = count == 2;
|
state->friend_in_group = count == 2;
|
||||||
}
|
}
|
||||||
@@ -60,18 +60,18 @@ static void rebuild_peer_list(Tox *tox)
|
|||||||
Tox_Err_Conference_Peer_Query err;
|
Tox_Err_Conference_Peer_Query err;
|
||||||
uint32_t const count = tox_conference_peer_count(tox, conference_number, &err);
|
uint32_t const count = tox_conference_peer_count(tox, conference_number, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
||||||
"failed to get conference peer count for conference %u: err = %d", conference_number, err);
|
"failed to get conference peer count for conference %u: err = %u", conference_number, err);
|
||||||
|
|
||||||
for (uint32_t peer_number = 0; peer_number < count; peer_number++) {
|
for (uint32_t peer_number = 0; peer_number < count; peer_number++) {
|
||||||
size_t size = tox_conference_peer_get_name_size(tox, conference_number, peer_number, &err);
|
size_t size = tox_conference_peer_get_name_size(tox, conference_number, peer_number, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
||||||
"failed to get conference peer %u's name size (conference = %u): err = %d", peer_number, conference_number, err);
|
"failed to get conference peer %u's name size (conference = %u): err = %u", peer_number, conference_number, err);
|
||||||
|
|
||||||
uint8_t *const name = (uint8_t *)malloc(size);
|
uint8_t *const name = (uint8_t *)malloc(size);
|
||||||
ck_assert(name != nullptr);
|
ck_assert(name != nullptr);
|
||||||
tox_conference_peer_get_name(tox, conference_number, peer_number, name, &err);
|
tox_conference_peer_get_name(tox, conference_number, peer_number, name, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
||||||
"failed to get conference peer %u's name (conference = %u): err = %d", peer_number, conference_number, err);
|
"failed to get conference peer %u's name (conference = %u): err = %u", peer_number, conference_number, err);
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ static void conference_peer_nick_test(AutoTox *autotoxes)
|
|||||||
state[0]->conference = tox_conference_new(autotoxes[0].tox, &err);
|
state[0]->conference = tox_conference_new(autotoxes[0].tox, &err);
|
||||||
state[0]->joined = true;
|
state[0]->joined = true;
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK,
|
||||||
"attempting to create a new conference returned with an error: %d", err);
|
"attempting to create a new conference returned with an error: %u", err);
|
||||||
fprintf(stderr, "Created conference: index=%u\n", state[0]->conference);
|
fprintf(stderr, "Created conference: index=%u\n", state[0]->conference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ static void conference_peer_nick_test(AutoTox *autotoxes)
|
|||||||
Tox_Err_Conference_Invite err;
|
Tox_Err_Conference_Invite err;
|
||||||
tox_conference_invite(autotoxes[0].tox, 0, state[0]->conference, &err);
|
tox_conference_invite(autotoxes[0].tox, 0, state[0]->conference, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK,
|
||||||
"attempting to invite a friend returned with an error: %d", err);
|
"attempting to invite a friend returned with an error: %u", err);
|
||||||
fprintf(stderr, "tox0 invited tox1\n");
|
fprintf(stderr, "tox0 invited tox1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ static void handle_self_connection_status(const Tox_Event_Self_Connection_Status
|
|||||||
State *state = (State *)user_data;
|
State *state = (State *)user_data;
|
||||||
|
|
||||||
const Tox_Connection connection_status = tox_event_self_connection_status_get_connection_status(event);
|
const Tox_Connection connection_status = tox_event_self_connection_status_get_connection_status(event);
|
||||||
fprintf(stderr, "self_connection_status(#%u, %d, _)\n", state->id, connection_status);
|
fprintf(stderr, "self_connection_status(#%u, %u, _)\n", state->id, connection_status);
|
||||||
state->self_online = connection_status != TOX_CONNECTION_NONE;
|
state->self_online = connection_status != TOX_CONNECTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ static void handle_friend_connection_status(const Tox_Event_Friend_Connection_St
|
|||||||
|
|
||||||
const uint32_t friend_number = tox_event_friend_connection_status_get_friend_number(event);
|
const uint32_t friend_number = tox_event_friend_connection_status_get_friend_number(event);
|
||||||
const Tox_Connection connection_status = tox_event_friend_connection_status_get_connection_status(event);
|
const Tox_Connection connection_status = tox_event_friend_connection_status_get_connection_status(event);
|
||||||
fprintf(stderr, "handle_friend_connection_status(#%u, %u, %d, _)\n", state->id, friend_number, connection_status);
|
fprintf(stderr, "handle_friend_connection_status(#%u, %u, %u, _)\n", state->id, friend_number, connection_status);
|
||||||
state->friend_online = connection_status != TOX_CONNECTION_NONE;
|
state->friend_online = connection_status != TOX_CONNECTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,14 +51,14 @@ static void handle_conference_invite(const Tox_Event_Conference_Invite *event, v
|
|||||||
const Tox_Conference_Type type = tox_event_conference_invite_get_type(event);
|
const Tox_Conference_Type type = tox_event_conference_invite_get_type(event);
|
||||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||||
fprintf(stderr, "handle_conference_invite(#%u, %u, %d, uint8_t[%u], _)\n",
|
fprintf(stderr, "handle_conference_invite(#%u, %u, %u, uint8_t[%u], _)\n",
|
||||||
state->id, friend_number, type, (unsigned)length);
|
state->id, friend_number, type, (unsigned)length);
|
||||||
fprintf(stderr, "tox%u joining conference\n", state->id);
|
fprintf(stderr, "tox%u joining conference\n", state->id);
|
||||||
|
|
||||||
{
|
{
|
||||||
Tox_Err_Conference_Join err;
|
Tox_Err_Conference_Join err;
|
||||||
state->conference = tox_conference_join(state->tox, friend_number, cookie, length, &err);
|
state->conference = tox_conference_join(state->tox, friend_number, cookie, length, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK, "failed to join a conference: err = %d", err);
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK, "failed to join a conference: err = %u", err);
|
||||||
fprintf(stderr, "tox%u Joined conference %u\n", state->id, state->conference);
|
fprintf(stderr, "tox%u Joined conference %u\n", state->id, state->conference);
|
||||||
state->joined = true;
|
state->joined = true;
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ static void handle_conference_message(const Tox_Event_Conference_Message *event,
|
|||||||
const uint8_t *message = tox_event_conference_message_get_message(event);
|
const uint8_t *message = tox_event_conference_message_get_message(event);
|
||||||
const size_t length = tox_event_conference_message_get_message_length(event);
|
const size_t length = tox_event_conference_message_get_message_length(event);
|
||||||
|
|
||||||
fprintf(stderr, "handle_conference_message(#%u, %u, %u, %d, uint8_t[%u], _)\n",
|
fprintf(stderr, "handle_conference_message(#%u, %u, %u, %u, uint8_t[%u], _)\n",
|
||||||
state->id, conference_number, peer_number, type, (unsigned)length);
|
state->id, conference_number, peer_number, type, (unsigned)length);
|
||||||
|
|
||||||
fprintf(stderr, "tox%u got message: %s\n", state->id, (const char *)message);
|
fprintf(stderr, "tox%u got message: %s\n", state->id, (const char *)message);
|
||||||
@@ -93,7 +93,7 @@ static void handle_conference_peer_list_changed(const Tox_Event_Conference_Peer_
|
|||||||
uint32_t count = tox_conference_peer_count(state->tox, conference_number, &err);
|
uint32_t count = tox_conference_peer_count(state->tox, conference_number, &err);
|
||||||
|
|
||||||
if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) {
|
if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) {
|
||||||
fprintf(stderr, "ERROR: %d\n", err);
|
fprintf(stderr, "ERROR: %u\n", err);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ static void handle_conference_connected(const Tox_Event_Conference_Connected *ev
|
|||||||
if (state->id == 2 && !state->invited_next) {
|
if (state->id == 2 && !state->invited_next) {
|
||||||
Tox_Err_Conference_Invite err;
|
Tox_Err_Conference_Invite err;
|
||||||
tox_conference_invite(state->tox, 1, state->conference, &err);
|
tox_conference_invite(state->tox, 1, state->conference, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox2 failed to invite tox3: err = %d", err);
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox2 failed to invite tox3: err = %u", err);
|
||||||
|
|
||||||
state->invited_next = true;
|
state->invited_next = true;
|
||||||
fprintf(stderr, "tox2 invited tox3\n");
|
fprintf(stderr, "tox2 invited tox3\n");
|
||||||
@@ -209,7 +209,7 @@ int main(void)
|
|||||||
Tox_Err_Conference_New err;
|
Tox_Err_Conference_New err;
|
||||||
state1.conference = tox_conference_new(state1.tox, &err);
|
state1.conference = tox_conference_new(state1.tox, &err);
|
||||||
state1.joined = true;
|
state1.joined = true;
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create a conference: err = %d", err);
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create a conference: err = %u", err);
|
||||||
fprintf(stderr, "Created conference: id = %u\n", state1.conference);
|
fprintf(stderr, "Created conference: id = %u\n", state1.conference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ int main(void)
|
|||||||
// Invite friend.
|
// Invite friend.
|
||||||
Tox_Err_Conference_Invite err;
|
Tox_Err_Conference_Invite err;
|
||||||
tox_conference_invite(state1.tox, 0, state1.conference, &err);
|
tox_conference_invite(state1.tox, 0, state1.conference, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "failed to invite a friend: err = %d", err);
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "failed to invite a friend: err = %u", err);
|
||||||
state1.invited_next = true;
|
state1.invited_next = true;
|
||||||
fprintf(stderr, "tox1 invited tox2\n");
|
fprintf(stderr, "tox1 invited tox2\n");
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ int main(void)
|
|||||||
(const uint8_t *)"hello!", 7, &err);
|
(const uint8_t *)"hello!", 7, &err);
|
||||||
|
|
||||||
if (err != TOX_ERR_CONFERENCE_SEND_MESSAGE_OK) {
|
if (err != TOX_ERR_CONFERENCE_SEND_MESSAGE_OK) {
|
||||||
fprintf(stderr, "ERROR: %d\n", err);
|
fprintf(stderr, "ERROR: %u\n", err);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/util.h"
|
#include "../toxcore/util.h"
|
||||||
|
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
@@ -53,12 +54,12 @@ static void handle_conference_invite(
|
|||||||
const uint8_t *data, size_t length, void *user_data)
|
const uint8_t *data, size_t length, void *user_data)
|
||||||
{
|
{
|
||||||
const AutoTox *autotox = (AutoTox *)user_data;
|
const AutoTox *autotox = (AutoTox *)user_data;
|
||||||
ck_assert_msg(type == TOX_CONFERENCE_TYPE_TEXT, "tox #%u: wrong conference type: %d", autotox->index, type);
|
ck_assert_msg(type == TOX_CONFERENCE_TYPE_TEXT, "tox #%u: wrong conference type: %u", autotox->index, type);
|
||||||
|
|
||||||
Tox_Err_Conference_Join err;
|
Tox_Err_Conference_Join err;
|
||||||
uint32_t g_num = tox_conference_join(autotox->tox, friendnumber, data, length, &err);
|
uint32_t g_num = tox_conference_join(autotox->tox, friendnumber, data, length, &err);
|
||||||
|
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK, "tox #%u: error joining group: %d", autotox->index, err);
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK, "tox #%u: error joining group: %u", autotox->index, err);
|
||||||
ck_assert_msg(g_num == 0, "tox #%u: group number was not 0", autotox->index);
|
ck_assert_msg(g_num == 0, "tox #%u: group number was not 0", autotox->index);
|
||||||
|
|
||||||
// Try joining again. We should only be allowed to join once.
|
// Try joining again. We should only be allowed to join once.
|
||||||
@@ -79,7 +80,7 @@ static void handle_conference_connected(
|
|||||||
|
|
||||||
Tox_Err_Conference_Invite err;
|
Tox_Err_Conference_Invite err;
|
||||||
tox_conference_invite(autotox->tox, 1, 0, &err);
|
tox_conference_invite(autotox->tox, 1, 0, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox #%u failed to invite next friend: err = %d", autotox->index,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox #%u failed to invite next friend: err = %u", autotox->index,
|
||||||
err);
|
err);
|
||||||
printf("tox #%u: invited next friend\n", autotox->index);
|
printf("tox #%u: invited next friend\n", autotox->index);
|
||||||
state->invited_next = true;
|
state->invited_next = true;
|
||||||
@@ -206,7 +207,7 @@ static void run_conference_tests(AutoTox *autotoxes)
|
|||||||
Tox_Err_Conference_Set_Max_Offline err;
|
Tox_Err_Conference_Set_Max_Offline err;
|
||||||
tox_conference_set_max_offline(autotoxes[i].tox, 0, max_frozen, &err);
|
tox_conference_set_max_offline(autotoxes[i].tox, 0, max_frozen, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_SET_MAX_OFFLINE_OK,
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_SET_MAX_OFFLINE_OK,
|
||||||
"tox #%u failed to set max offline: err = %d", autotoxes[i].index, err);
|
"tox #%u failed to set max offline: err = %u", autotoxes[i].index, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("letting random toxes timeout\n");
|
printf("letting random toxes timeout\n");
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ int main(void)
|
|||||||
// Create two conferences and then exit.
|
// Create two conferences and then exit.
|
||||||
Tox_Err_Conference_New err;
|
Tox_Err_Conference_New err;
|
||||||
tox_conference_new(tox1, &err);
|
tox_conference_new(tox1, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 1: %d", err);
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 1: %u", err);
|
||||||
tox_conference_new(tox1, &err);
|
tox_conference_new(tox1, &err);
|
||||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 2: %d", err);
|
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 2: %u", err);
|
||||||
|
|
||||||
tox_kill(tox1);
|
tox_kill(tox1);
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
|
||||||
#include "../toxcore/crypto_core.h"
|
#include "../toxcore/crypto_core.h"
|
||||||
#include "../toxcore/net_crypto.h"
|
#include "../toxcore/net_crypto.h"
|
||||||
|
#include "../toxcore/os_memory.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
static void rand_bytes(const Random *rng, uint8_t *b, size_t blen)
|
static void rand_bytes(const Random *rng, uint8_t *b, size_t blen)
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
#define NUM_TOXES 30
|
#define NUM_TOXES 30
|
||||||
|
// Maximum number of iterations to wait for all nodes to be crawled. 5 should
|
||||||
|
// be enough. We pick 10 in case things are slow. This makes the test take
|
||||||
|
// less time in case it completely fails, so we can retry it.
|
||||||
|
#define MAX_ITERATIONS 10
|
||||||
|
|
||||||
typedef struct Dht_Node {
|
typedef struct Dht_Node {
|
||||||
uint8_t public_key[TOX_DHT_NODE_PUBLIC_KEY_SIZE];
|
uint8_t public_key[TOX_DHT_NODE_PUBLIC_KEY_SIZE];
|
||||||
@@ -132,9 +136,15 @@ static void test_dht_nodes_request(AutoTox *autotoxes)
|
|||||||
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox));
|
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
|
bool success = false;
|
||||||
|
for (size_t i = 0; i < MAX_ITERATIONS; ++i) {
|
||||||
|
if (all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
iterate_all_wait(autotoxes, NUM_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_TOXES, ITERATION_INTERVAL);
|
||||||
}
|
}
|
||||||
|
ck_assert_msg(success, "Failed to crawl all nodes within %d iterations", MAX_ITERATIONS);
|
||||||
|
|
||||||
for (size_t i = 0; i < NUM_TOXES; ++i) {
|
for (size_t i = 0; i < NUM_TOXES; ++i) {
|
||||||
State *state = (State *)autotoxes[i].state;
|
State *state = (State *)autotoxes[i].state;
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
|
||||||
#include "../toxcore/ccompat.h"
|
#include "../toxcore/ccompat.h"
|
||||||
#include "../toxcore/crypto_core.h"
|
#include "../toxcore/crypto_core.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxencryptsave/toxencryptsave.h"
|
#include "../toxencryptsave/toxencryptsave.h"
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
@@ -48,7 +48,7 @@ static void test_save_friend(void)
|
|||||||
ck_assert(enc_data != nullptr);
|
ck_assert(enc_data != nullptr);
|
||||||
Tox_Err_Encryption error1;
|
Tox_Err_Encryption error1;
|
||||||
bool ret = tox_pass_encrypt(data, size, (const uint8_t *)"correcthorsebatterystaple", 25, enc_data, &error1);
|
bool ret = tox_pass_encrypt(data, size, (const uint8_t *)"correcthorsebatterystaple", 25, enc_data, &error1);
|
||||||
ck_assert_msg(ret, "failed to encrypted save: %d", error1);
|
ck_assert_msg(ret, "failed to encrypted save: %u", error1);
|
||||||
ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing");
|
ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing");
|
||||||
|
|
||||||
struct Tox_Options *options = tox_options_new(nullptr);
|
struct Tox_Options *options = tox_options_new(nullptr);
|
||||||
@@ -58,17 +58,17 @@ static void test_save_friend(void)
|
|||||||
|
|
||||||
Tox_Err_New err2;
|
Tox_Err_New err2;
|
||||||
Tox *tox3 = tox_new_log(options, &err2, nullptr);
|
Tox *tox3 = tox_new_log(options, &err2, nullptr);
|
||||||
ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %d. should fail with %d", err2,
|
ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %d", err2,
|
||||||
TOX_ERR_NEW_LOAD_ENCRYPTED);
|
(int)TOX_ERR_NEW_LOAD_ENCRYPTED);
|
||||||
ck_assert_msg(tox3 == nullptr, "tox_new with error should return NULL");
|
ck_assert_msg(tox3 == nullptr, "tox_new with error should return NULL");
|
||||||
uint8_t *dec_data = (uint8_t *)malloc(size);
|
uint8_t *dec_data = (uint8_t *)malloc(size);
|
||||||
ck_assert(dec_data != nullptr);
|
ck_assert(dec_data != nullptr);
|
||||||
Tox_Err_Decryption err3;
|
Tox_Err_Decryption err3;
|
||||||
ret = tox_pass_decrypt(enc_data, size2, (const uint8_t *)"correcthorsebatterystaple", 25, dec_data, &err3);
|
ret = tox_pass_decrypt(enc_data, size2, (const uint8_t *)"correcthorsebatterystaple", 25, dec_data, &err3);
|
||||||
ck_assert_msg(ret, "failed to decrypt save: %d", err3);
|
ck_assert_msg(ret, "failed to decrypt save: %u", err3);
|
||||||
tox_options_set_savedata_data(options, dec_data, size);
|
tox_options_set_savedata_data(options, dec_data, size);
|
||||||
tox3 = tox_new_log(options, &err2, nullptr);
|
tox3 = tox_new_log(options, &err2, nullptr);
|
||||||
ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %d", err2);
|
ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2);
|
||||||
uint8_t address2[TOX_PUBLIC_KEY_SIZE];
|
uint8_t address2[TOX_PUBLIC_KEY_SIZE];
|
||||||
ret = tox_friend_get_public_key(tox3, 0, address2, nullptr);
|
ret = tox_friend_get_public_key(tox3, 0, address2, nullptr);
|
||||||
ck_assert_msg(ret, "no friends!");
|
ck_assert_msg(ret, "no friends!");
|
||||||
@@ -87,7 +87,7 @@ static void test_save_friend(void)
|
|||||||
uint8_t *encdata2 = (uint8_t *)malloc(size2);
|
uint8_t *encdata2 = (uint8_t *)malloc(size2);
|
||||||
ck_assert(encdata2 != nullptr);
|
ck_assert(encdata2 != nullptr);
|
||||||
ret = tox_pass_key_encrypt(key, data2, size, encdata2, &error1);
|
ret = tox_pass_key_encrypt(key, data2, size, encdata2, &error1);
|
||||||
ck_assert_msg(ret, "failed to key encrypt %d", error1);
|
ck_assert_msg(ret, "failed to key encrypt %u", error1);
|
||||||
ck_assert_msg(tox_is_data_encrypted(encdata2), "magic number the second missing");
|
ck_assert_msg(tox_is_data_encrypted(encdata2), "magic number the second missing");
|
||||||
|
|
||||||
uint8_t *out1 = (uint8_t *)malloc(size);
|
uint8_t *out1 = (uint8_t *)malloc(size);
|
||||||
@@ -95,9 +95,9 @@ static void test_save_friend(void)
|
|||||||
uint8_t *out2 = (uint8_t *)malloc(size);
|
uint8_t *out2 = (uint8_t *)malloc(size);
|
||||||
ck_assert(out2 != nullptr);
|
ck_assert(out2 != nullptr);
|
||||||
ret = tox_pass_decrypt(encdata2, size2, (const uint8_t *)pw, pwlen, out1, &err3);
|
ret = tox_pass_decrypt(encdata2, size2, (const uint8_t *)pw, pwlen, out1, &err3);
|
||||||
ck_assert_msg(ret, "failed to pw decrypt %d", err3);
|
ck_assert_msg(ret, "failed to pw decrypt %u", err3);
|
||||||
ret = tox_pass_key_decrypt(key, encdata2, size2, out2, &err3);
|
ret = tox_pass_key_decrypt(key, encdata2, size2, out2, &err3);
|
||||||
ck_assert_msg(ret, "failed to key decrypt %d", err3);
|
ck_assert_msg(ret, "failed to key decrypt %u", err3);
|
||||||
ck_assert_msg(memcmp(out1, out2, size) == 0, "differing output data");
|
ck_assert_msg(memcmp(out1, out2, size) == 0, "differing output data");
|
||||||
|
|
||||||
// and now with the code in use (I only bothered with manually to debug this, and it seems a waste
|
// and now with the code in use (I only bothered with manually to debug this, and it seems a waste
|
||||||
@@ -134,12 +134,12 @@ static void test_keys(void)
|
|||||||
Tox_Err_Key_Derivation keyerr;
|
Tox_Err_Key_Derivation keyerr;
|
||||||
const uint8_t *key_char = (const uint8_t *)"123qweasdzxc";
|
const uint8_t *key_char = (const uint8_t *)"123qweasdzxc";
|
||||||
Tox_Pass_Key *key = tox_pass_key_derive(key_char, 12, &keyerr);
|
Tox_Pass_Key *key = tox_pass_key_derive(key_char, 12, &keyerr);
|
||||||
ck_assert_msg(key != nullptr, "generic failure 1: %d", keyerr);
|
ck_assert_msg(key != nullptr, "generic failure 1: %u", keyerr);
|
||||||
const uint8_t *string = (const uint8_t *)"No Patrick, mayonnaise is not an instrument."; // 44
|
const uint8_t *string = (const uint8_t *)"No Patrick, mayonnaise is not an instrument."; // 44
|
||||||
|
|
||||||
uint8_t encrypted[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
uint8_t encrypted[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||||
bool ret = tox_pass_key_encrypt(key, string, 44, encrypted, &encerr);
|
bool ret = tox_pass_key_encrypt(key, string, 44, encrypted, &encerr);
|
||||||
ck_assert_msg(ret, "generic failure 2: %d", encerr);
|
ck_assert_msg(ret, "generic failure 2: %u", encerr);
|
||||||
|
|
||||||
// Testing how tox handles encryption of large messages.
|
// Testing how tox handles encryption of large messages.
|
||||||
int size_large = 30 * 1024 * 1024;
|
int size_large = 30 * 1024 * 1024;
|
||||||
@@ -153,13 +153,13 @@ static void test_keys(void)
|
|||||||
ck_assert(rng != nullptr);
|
ck_assert(rng != nullptr);
|
||||||
random_bytes(rng, in_plaintext2a, plaintext_length2a);
|
random_bytes(rng, in_plaintext2a, plaintext_length2a);
|
||||||
ret = tox_pass_encrypt(in_plaintext2a, plaintext_length2a, key_char, 12, encrypted2a, &encerr);
|
ret = tox_pass_encrypt(in_plaintext2a, plaintext_length2a, key_char, 12, encrypted2a, &encerr);
|
||||||
ck_assert_msg(ret, "tox_pass_encrypt failure 2a: %d", encerr);
|
ck_assert_msg(ret, "tox_pass_encrypt failure 2a: %u", encerr);
|
||||||
|
|
||||||
// Decryption of same message.
|
// Decryption of same message.
|
||||||
uint8_t *out_plaintext2a = (uint8_t *)malloc(plaintext_length2a);
|
uint8_t *out_plaintext2a = (uint8_t *)malloc(plaintext_length2a);
|
||||||
ck_assert(out_plaintext2a != nullptr);
|
ck_assert(out_plaintext2a != nullptr);
|
||||||
ret = tox_pass_decrypt(encrypted2a, ciphertext_length2a, key_char, 12, out_plaintext2a, &decerr);
|
ret = tox_pass_decrypt(encrypted2a, ciphertext_length2a, key_char, 12, out_plaintext2a, &decerr);
|
||||||
ck_assert_msg(ret, "tox_pass_decrypt failure 2a: %d", decerr);
|
ck_assert_msg(ret, "tox_pass_decrypt failure 2a: %u", decerr);
|
||||||
ck_assert_msg(memcmp(in_plaintext2a, out_plaintext2a, plaintext_length2a) == 0, "Large message decryption failed");
|
ck_assert_msg(memcmp(in_plaintext2a, out_plaintext2a, plaintext_length2a) == 0, "Large message decryption failed");
|
||||||
free(encrypted2a);
|
free(encrypted2a);
|
||||||
free(in_plaintext2a);
|
free(in_plaintext2a);
|
||||||
@@ -167,28 +167,28 @@ static void test_keys(void)
|
|||||||
|
|
||||||
uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||||
ret = tox_pass_encrypt(string, 44, key_char, 12, encrypted2, &encerr);
|
ret = tox_pass_encrypt(string, 44, key_char, 12, encrypted2, &encerr);
|
||||||
ck_assert_msg(ret, "generic failure 3: %d", encerr);
|
ck_assert_msg(ret, "generic failure 3: %u", encerr);
|
||||||
|
|
||||||
uint8_t out1[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
uint8_t out1[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||||
uint8_t out2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
uint8_t out2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||||
|
|
||||||
ret = tox_pass_key_decrypt(key, encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, out1, &decerr);
|
ret = tox_pass_key_decrypt(key, encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, out1, &decerr);
|
||||||
ck_assert_msg(ret, "generic failure 4: %d", decerr);
|
ck_assert_msg(ret, "generic failure 4: %u", decerr);
|
||||||
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 1 failed");
|
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 1 failed");
|
||||||
|
|
||||||
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out2,
|
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out2,
|
||||||
&decerr);
|
&decerr);
|
||||||
ck_assert_msg(ret, "generic failure 5: %d", decerr);
|
ck_assert_msg(ret, "generic failure 5: %u", decerr);
|
||||||
ck_assert_msg(memcmp(out2, string, 44) == 0, "decryption 2 failed");
|
ck_assert_msg(memcmp(out2, string, 44) == 0, "decryption 2 failed");
|
||||||
|
|
||||||
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, nullptr, 0, out2, &decerr);
|
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, nullptr, 0, out2, &decerr);
|
||||||
ck_assert_msg(!ret, "Decrypt succeeded with wrong pass");
|
ck_assert_msg(!ret, "Decrypt succeeded with wrong pass");
|
||||||
ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %d", decerr);
|
ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %u", decerr);
|
||||||
|
|
||||||
// test that pass_decrypt can decrypt things from pass_key_encrypt
|
// test that pass_decrypt can decrypt things from pass_key_encrypt
|
||||||
ret = tox_pass_decrypt(encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out1,
|
ret = tox_pass_decrypt(encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out1,
|
||||||
&decerr);
|
&decerr);
|
||||||
ck_assert_msg(ret, "generic failure 6: %d", decerr);
|
ck_assert_msg(ret, "generic failure 6: %u", decerr);
|
||||||
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 3 failed");
|
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 3 failed");
|
||||||
|
|
||||||
uint8_t salt[TOX_PASS_SALT_LENGTH];
|
uint8_t salt[TOX_PASS_SALT_LENGTH];
|
||||||
@@ -196,7 +196,7 @@ static void test_keys(void)
|
|||||||
ck_assert_msg(tox_get_salt(encrypted, salt, &salt_err), "couldn't get salt");
|
ck_assert_msg(tox_get_salt(encrypted, salt, &salt_err), "couldn't get salt");
|
||||||
ck_assert_msg(salt_err == TOX_ERR_GET_SALT_OK, "get_salt returned an error");
|
ck_assert_msg(salt_err == TOX_ERR_GET_SALT_OK, "get_salt returned an error");
|
||||||
Tox_Pass_Key *key2 = tox_pass_key_derive_with_salt((const uint8_t *)"123qweasdzxc", 12, salt, &keyerr);
|
Tox_Pass_Key *key2 = tox_pass_key_derive_with_salt((const uint8_t *)"123qweasdzxc", 12, salt, &keyerr);
|
||||||
ck_assert_msg(key2 != nullptr, "generic failure 7: %d", keyerr);
|
ck_assert_msg(key2 != nullptr, "generic failure 7: %u", keyerr);
|
||||||
ck_assert_msg(0 == memcmp(key, key2, TOX_PASS_KEY_LENGTH + TOX_PASS_SALT_LENGTH), "salt comparison failed");
|
ck_assert_msg(0 == memcmp(key, key2, TOX_PASS_KEY_LENGTH + TOX_PASS_SALT_LENGTH), "salt comparison failed");
|
||||||
tox_pass_key_free(key2);
|
tox_pass_key_free(key2);
|
||||||
tox_pass_key_free(key);
|
tox_pass_key_free(key);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ static void save_data_encrypted(void)
|
|||||||
|
|
||||||
ck_assert_msg(tox_pass_encrypt(clear, size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)pphrase,
|
ck_assert_msg(tox_pass_encrypt(clear, size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)pphrase,
|
||||||
strlen(pphrase), cipher,
|
strlen(pphrase), cipher,
|
||||||
&eerr), "Could not encrypt, error code %d.", eerr);
|
&eerr), "Could not encrypt, error code %u.", eerr);
|
||||||
|
|
||||||
size_t written_value = fwrite(cipher, sizeof(*cipher), size, f);
|
size_t written_value = fwrite(cipher, sizeof(*cipher), size, f);
|
||||||
printf("written written_value = %u of %u\n", (unsigned)written_value, (unsigned)size);
|
printf("written written_value = %u of %u\n", (unsigned)written_value, (unsigned)size);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_num
|
|||||||
Tox_Err_File_Control error;
|
Tox_Err_File_Control error;
|
||||||
|
|
||||||
ck_assert_msg(tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
ck_assert_msg(tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
||||||
"tox_file_control failed. %i", error);
|
"tox_file_control failed. %u", error);
|
||||||
++file_accepted;
|
++file_accepted;
|
||||||
|
|
||||||
Tox_Err_File_Seek err_s;
|
Tox_Err_File_Seek err_s;
|
||||||
@@ -189,7 +189,7 @@ static void file_transfer_test(void)
|
|||||||
tox_iterate(tox2, nullptr);
|
tox_iterate(tox2, nullptr);
|
||||||
tox_iterate(tox3, nullptr);
|
tox_iterate(tox3, nullptr);
|
||||||
|
|
||||||
printf("Connections: self (%d, %d, %d), friends (%d, %d)\n",
|
printf("Connections: self (%u, %u, %u), friends (%u, %u)\n",
|
||||||
tox_self_get_connection_status(tox1),
|
tox_self_get_connection_status(tox1),
|
||||||
tox_self_get_connection_status(tox2),
|
tox_self_get_connection_status(tox2),
|
||||||
tox_self_get_connection_status(tox3),
|
tox_self_get_connection_status(tox3),
|
||||||
@@ -252,7 +252,7 @@ static void file_transfer_test(void)
|
|||||||
|
|
||||||
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
||||||
&& sending_pos == size_recv && file_accepted == 1,
|
&& sending_pos == size_recv && file_accepted == 1,
|
||||||
"something went wrong in file transfer %u %u %u %u %u %u %u %lu %lu %lu %lu", sendf_ok, file_recv,
|
"something went wrong in file transfer %u %u %d %d %d %d %d %lu %lu %lu %lu", sendf_ok, file_recv,
|
||||||
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
||||||
(unsigned long)totalf_size, (unsigned long)file_size,
|
(unsigned long)totalf_size, (unsigned long)file_size,
|
||||||
(unsigned long)size_recv, (unsigned long)sending_pos);
|
(unsigned long)size_recv, (unsigned long)sending_pos);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ static void tox_file_receive(const Tox_Event_File_Recv *event, void *userdata)
|
|||||||
Tox_Err_File_Control error;
|
Tox_Err_File_Control error;
|
||||||
|
|
||||||
ck_assert_msg(tox_file_control(state_tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
ck_assert_msg(tox_file_control(state_tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
||||||
"tox_file_control failed. %i", error);
|
"tox_file_control failed. %u", error);
|
||||||
++file_accepted;
|
++file_accepted;
|
||||||
|
|
||||||
Tox_Err_File_Seek err_s;
|
Tox_Err_File_Seek err_s;
|
||||||
@@ -238,7 +238,7 @@ static void file_transfer_test(void)
|
|||||||
iterate_and_dispatch(dispatch2, tox2);
|
iterate_and_dispatch(dispatch2, tox2);
|
||||||
iterate_and_dispatch(dispatch3, tox3);
|
iterate_and_dispatch(dispatch3, tox3);
|
||||||
|
|
||||||
printf("Connections: self (%d, %d, %d), friends (%d, %d)\n",
|
printf("Connections: self (%u, %u, %u), friends (%u, %u)\n",
|
||||||
tox_self_get_connection_status(tox1),
|
tox_self_get_connection_status(tox1),
|
||||||
tox_self_get_connection_status(tox2),
|
tox_self_get_connection_status(tox2),
|
||||||
tox_self_get_connection_status(tox3),
|
tox_self_get_connection_status(tox3),
|
||||||
@@ -285,7 +285,7 @@ static void file_transfer_test(void)
|
|||||||
if (file_sending_done) {
|
if (file_sending_done) {
|
||||||
ck_assert_msg(sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size && sending_pos == size_recv
|
ck_assert_msg(sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size && sending_pos == size_recv
|
||||||
&& file_accepted == 1,
|
&& file_accepted == 1,
|
||||||
"Something went wrong in file transfer %u %u %u %u %u %u %lu %lu %lu",
|
"Something went wrong in file transfer %u %u %d %d %d %d %lu %lu %lu",
|
||||||
sendf_ok, file_recv, totalf_size == file_size, size_recv == file_size, sending_pos == size_recv,
|
sendf_ok, file_recv, totalf_size == file_size, size_recv == file_size, sending_pos == size_recv,
|
||||||
file_accepted == 1, (unsigned long)totalf_size, (unsigned long)size_recv,
|
file_accepted == 1, (unsigned long)totalf_size, (unsigned long)size_recv,
|
||||||
(unsigned long)sending_pos);
|
(unsigned long)sending_pos);
|
||||||
@@ -304,7 +304,7 @@ static void file_transfer_test(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(file_sending_done, "file sending did not complete after %u iterations: sendf_ok:%u file_recv:%u "
|
ck_assert_msg(file_sending_done, "file sending did not complete after %u iterations: sendf_ok:%u file_recv:%u "
|
||||||
"totalf_size==file_size:%u size_recv==file_size:%u sending_pos==size_recv:%u file_accepted:%u "
|
"totalf_size==file_size:%d size_recv==file_size:%d sending_pos==size_recv:%d file_accepted:%d "
|
||||||
"totalf_size:%lu size_recv:%lu sending_pos:%lu",
|
"totalf_size:%lu size_recv:%lu sending_pos:%lu",
|
||||||
(unsigned int)max_iterations, sendf_ok, file_recv,
|
(unsigned int)max_iterations, sendf_ok, file_recv,
|
||||||
totalf_size == file_size, size_recv == file_size, sending_pos == size_recv, file_accepted == 1,
|
totalf_size == file_size, size_recv == file_size, sending_pos == size_recv, file_accepted == 1,
|
||||||
@@ -352,7 +352,7 @@ static void file_transfer_test(void)
|
|||||||
|
|
||||||
ck_assert_msg(sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size
|
ck_assert_msg(sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size
|
||||||
&& sending_pos == size_recv && file_accepted == 1,
|
&& sending_pos == size_recv && file_accepted == 1,
|
||||||
"something went wrong in file transfer %u %u %u %u %u %u %llu %llu %llu", sendf_ok, file_recv,
|
"something went wrong in file transfer %u %u %d %d %d %d %llu %llu %llu", sendf_ok, file_recv,
|
||||||
totalf_size == file_size, size_recv == file_size, sending_pos == size_recv, file_accepted == 1,
|
totalf_size == file_size, size_recv == file_size, sending_pos == size_recv, file_accepted == 1,
|
||||||
(unsigned long long)totalf_size, (unsigned long long)size_recv,
|
(unsigned long long)totalf_size, (unsigned long long)size_recv,
|
||||||
(unsigned long long)sending_pos);
|
(unsigned long long)sending_pos);
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
#include "../toxcore/mono_time.h"
|
#include "../toxcore/mono_time.h"
|
||||||
#include "../toxcore/forwarding.h"
|
#include "../toxcore/forwarding.h"
|
||||||
#include "../toxcore/net_crypto.h"
|
#include "../toxcore/net_crypto.h"
|
||||||
#include "../toxcore/util.h"
|
#include "../toxcore/os_memory.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
@@ -131,12 +132,12 @@ static Forwarding_Subtox *new_forwarding_subtox(const Memory *mem, bool no_udp,
|
|||||||
ck_assert(subtox->tcp_np != nullptr);
|
ck_assert(subtox->tcp_np != nullptr);
|
||||||
|
|
||||||
const TCP_Proxy_Info inf = {{{{0}}}};
|
const TCP_Proxy_Info inf = {{{{0}}}};
|
||||||
subtox->c = new_net_crypto(subtox->log, mem, rng, ns, subtox->mono_time, subtox->dht, &inf, subtox->tcp_np);
|
subtox->c = new_net_crypto(subtox->log, mem, rng, ns, subtox->mono_time, subtox->net, subtox->dht, &inf, subtox->tcp_np);
|
||||||
|
|
||||||
subtox->forwarding = new_forwarding(subtox->log, mem, rng, subtox->mono_time, subtox->dht);
|
subtox->forwarding = new_forwarding(subtox->log, mem, rng, subtox->mono_time, subtox->dht, subtox->net);
|
||||||
ck_assert(subtox->forwarding != nullptr);
|
ck_assert(subtox->forwarding != nullptr);
|
||||||
|
|
||||||
subtox->announce = new_announcements(subtox->log, mem, rng, subtox->mono_time, subtox->forwarding);
|
subtox->announce = new_announcements(subtox->log, mem, rng, subtox->mono_time, subtox->forwarding, subtox->dht, subtox->net);
|
||||||
ck_assert(subtox->announce != nullptr);
|
ck_assert(subtox->announce != nullptr);
|
||||||
|
|
||||||
return subtox;
|
return subtox;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ static void test_friend_request(AutoTox *autotoxes)
|
|||||||
for (uint32_t i = 2; i < FR_TOX_COUNT; ++i) {
|
for (uint32_t i = 2; i < FR_TOX_COUNT; ++i) {
|
||||||
Tox_Err_Friend_Add err;
|
Tox_Err_Friend_Add err;
|
||||||
tox_friend_add(autotoxes[i].tox, address, (const uint8_t *)FR_MESSAGE, sizeof(FR_MESSAGE), &err);
|
tox_friend_add(autotoxes[i].tox, address, (const uint8_t *)FR_MESSAGE, sizeof(FR_MESSAGE), &err);
|
||||||
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "tox %u failed to add friend error code: %d", autotoxes[i].index, err);
|
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "tox %u failed to add friend error code: %u", autotoxes[i].index, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t t = 0; t < 100; ++t) {
|
for (uint32_t t = 0; t < 100; ++t) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ static void accept_friend_request(const Tox_Event_Friend_Request *event, void *u
|
|||||||
Tox_Err_Friend_Add err;
|
Tox_Err_Friend_Add err;
|
||||||
tox_friend_add_norequest(cb_data->tox2, public_key, &err);
|
tox_friend_add_norequest(cb_data->tox2, public_key, &err);
|
||||||
|
|
||||||
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "tox_friend_add_norequest failed: %d", err);
|
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "tox_friend_add_norequest failed: %u", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iterate2_wait(const Tox_Dispatch *dispatch, Callback_Data *cb_data)
|
static void iterate2_wait(const Tox_Dispatch *dispatch, Callback_Data *cb_data)
|
||||||
@@ -108,7 +108,7 @@ static void test_friend_request(const uint8_t *message, uint16_t length)
|
|||||||
Tox_Err_Friend_Add err;
|
Tox_Err_Friend_Add err;
|
||||||
const uint32_t test = tox_friend_add(tox1, address, message, length, &err);
|
const uint32_t test = tox_friend_add(tox1, address, message, length, &err);
|
||||||
|
|
||||||
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "tox_friend_add failed: %d", err);
|
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "tox_friend_add failed: %u", err);
|
||||||
ck_assert_msg(test == 0, "failed to add friend error code: %u", test);
|
ck_assert_msg(test == 0, "failed to add friend error code: %u", test);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ static void print_ip(const Tox *tox, uint32_t groupnumber, uint32_t peer_id)
|
|||||||
Tox_Err_Group_Peer_Query err;
|
Tox_Err_Group_Peer_Query err;
|
||||||
size_t length = tox_group_peer_get_ip_address_size(tox, groupnumber, peer_id, &err);
|
size_t length = tox_group_peer_get_ip_address_size(tox, groupnumber, peer_id, &err);
|
||||||
|
|
||||||
ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address size: error %d", err);
|
ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address size: error %u", err);
|
||||||
|
|
||||||
uint8_t ip_str[TOX_GROUP_PEER_IP_STRING_MAX_LENGTH];
|
uint8_t ip_str[TOX_GROUP_PEER_IP_STRING_MAX_LENGTH];
|
||||||
tox_group_peer_get_ip_address(tox, groupnumber, peer_id, ip_str, &err);
|
tox_group_peer_get_ip_address(tox, groupnumber, peer_id, ip_str, &err);
|
||||||
ip_str[length] = '\0';
|
ip_str[length] = '\0';
|
||||||
|
|
||||||
ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address: error %d", err);
|
ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address: error %u", err);
|
||||||
|
|
||||||
fprintf(stderr, "%s\n", ip_str);
|
fprintf(stderr, "%s\n", ip_str);
|
||||||
}
|
}
|
||||||
@@ -98,10 +98,10 @@ static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void
|
|||||||
ck_assert(connection_status != TOX_CONNECTION_NONE);
|
ck_assert(connection_status != TOX_CONNECTION_NONE);
|
||||||
|
|
||||||
Tox_Group_Role role = tox_group_peer_get_role(autotox->tox, groupnumber, peer_id, &pq_err);
|
Tox_Group_Role role = tox_group_peer_get_role(autotox->tox, groupnumber, peer_id, &pq_err);
|
||||||
ck_assert_msg(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK, "%d", pq_err);
|
ck_assert_msg(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK, "%u", pq_err);
|
||||||
|
|
||||||
Tox_User_Status status = tox_group_peer_get_status(autotox->tox, groupnumber, peer_id, &pq_err);
|
Tox_User_Status status = tox_group_peer_get_status(autotox->tox, groupnumber, peer_id, &pq_err);
|
||||||
ck_assert_msg(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK, "%d", pq_err);
|
ck_assert_msg(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK, "%u", pq_err);
|
||||||
|
|
||||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, groupnumber, peer_id, &pq_err);
|
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, groupnumber, peer_id, &pq_err);
|
||||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||||
@@ -116,26 +116,26 @@ static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void
|
|||||||
|
|
||||||
// make sure we see the correct peer state on join
|
// make sure we see the correct peer state on join
|
||||||
if (!state->is_founder) {
|
if (!state->is_founder) {
|
||||||
ck_assert_msg(role == TOX_GROUP_ROLE_FOUNDER, "wrong role: %d", role);
|
ck_assert_msg(role == TOX_GROUP_ROLE_FOUNDER, "wrong role: %u", role);
|
||||||
|
|
||||||
if (state->peer_joined_count == 0) {
|
if (state->peer_joined_count == 0) {
|
||||||
ck_assert_msg(status == TOX_USER_STATUS_NONE, "wrong status: %d", status);
|
ck_assert_msg(status == TOX_USER_STATUS_NONE, "wrong status: %u", status);
|
||||||
ck_assert_msg(peer_name_len == PEER0_NICK_LEN, "wrong nick: %s", peer_name);
|
ck_assert_msg(peer_name_len == PEER0_NICK_LEN, "wrong nick: %s", peer_name);
|
||||||
ck_assert(memcmp(peer_name, PEER0_NICK, peer_name_len) == 0);
|
ck_assert(memcmp(peer_name, PEER0_NICK, peer_name_len) == 0);
|
||||||
} else {
|
} else {
|
||||||
ck_assert_msg(status == TOX_USER_STATUS_BUSY, "wrong status: %d", status);
|
ck_assert_msg(status == TOX_USER_STATUS_BUSY, "wrong status: %u", status);
|
||||||
ck_assert(peer_name_len == PEER0_NICK2_LEN);
|
ck_assert(peer_name_len == PEER0_NICK2_LEN);
|
||||||
ck_assert(memcmp(peer_name, PEER0_NICK2, peer_name_len) == 0);
|
ck_assert(memcmp(peer_name, PEER0_NICK2, peer_name_len) == 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ck_assert_msg(role == TOX_GROUP_ROLE_USER, "wrong role: %d", role);
|
ck_assert_msg(role == TOX_GROUP_ROLE_USER, "wrong role: %u", role);
|
||||||
ck_assert(peer_name_len == PEER1_NICK_LEN);
|
ck_assert(peer_name_len == PEER1_NICK_LEN);
|
||||||
ck_assert(memcmp(peer_name, PEER1_NICK, peer_name_len) == 0);
|
ck_assert(memcmp(peer_name, PEER1_NICK, peer_name_len) == 0);
|
||||||
|
|
||||||
if (state->peer_joined_count == 0) {
|
if (state->peer_joined_count == 0) {
|
||||||
ck_assert_msg(status == TOX_USER_STATUS_NONE, "wrong status: %d", status);
|
ck_assert_msg(status == TOX_USER_STATUS_NONE, "wrong status: %u", status);
|
||||||
} else {
|
} else {
|
||||||
ck_assert_msg(status == TOX_USER_STATUS_AWAY, "wrong status: %d", status);
|
ck_assert_msg(status == TOX_USER_STATUS_AWAY, "wrong status: %u", status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,11 +196,11 @@ static void group_peer_self_join_handler(const Tox_Event_Group_Self_Join *event,
|
|||||||
|
|
||||||
Tox_Err_Group_State_Query query_err;
|
Tox_Err_Group_State_Query query_err;
|
||||||
tox_group_get_name(autotox->tox, groupnumber, group_name, &query_err);
|
tox_group_get_name(autotox->tox, groupnumber, group_name, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%u", query_err);
|
||||||
ck_assert(memcmp(group_name, GROUP_NAME, GROUP_NAME_LEN) == 0);
|
ck_assert(memcmp(group_name, GROUP_NAME, GROUP_NAME_LEN) == 0);
|
||||||
|
|
||||||
tox_group_get_topic(autotox->tox, groupnumber, topic, &query_err);
|
tox_group_get_topic(autotox->tox, groupnumber, topic, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%u", query_err);
|
||||||
ck_assert(memcmp(topic, TOPIC, TOPIC_LEN) == 0);
|
ck_assert(memcmp(topic, TOPIC, TOPIC_LEN) == 0);
|
||||||
|
|
||||||
uint32_t peer_id = tox_group_self_get_peer_id(autotox->tox, groupnumber, nullptr);
|
uint32_t peer_id = tox_group_self_get_peer_id(autotox->tox, groupnumber, nullptr);
|
||||||
@@ -263,7 +263,7 @@ static void group_peer_status_handler(const Tox_Event_Group_Peer_Status *event,
|
|||||||
Tox_Err_Group_Peer_Query err;
|
Tox_Err_Group_Peer_Query err;
|
||||||
Tox_User_Status cur_status = tox_group_peer_get_status(autotox->tox, groupnumber, peer_id, &err);
|
Tox_User_Status cur_status = tox_group_peer_get_status(autotox->tox, groupnumber, peer_id, &err);
|
||||||
|
|
||||||
ck_assert_msg(cur_status == status, "%d, %d", cur_status, status);
|
ck_assert_msg(cur_status == status, "%u, %u", cur_status, status);
|
||||||
ck_assert(status == TOX_USER_STATUS_BUSY);
|
ck_assert(status == TOX_USER_STATUS_BUSY);
|
||||||
|
|
||||||
state->peer_status = true;
|
state->peer_status = true;
|
||||||
@@ -300,7 +300,7 @@ static void group_announce_test(AutoTox *autotoxes)
|
|||||||
// changes the state (for sync check purposes)
|
// changes the state (for sync check purposes)
|
||||||
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
||||||
tox_group_set_peer_limit(tox0, groupnumber, PEER_LIMIT, &limit_set_err);
|
tox_group_set_peer_limit(tox0, groupnumber, PEER_LIMIT, &limit_set_err);
|
||||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "failed to set peer limit: %d", limit_set_err);
|
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "failed to set peer limit: %u", limit_set_err);
|
||||||
|
|
||||||
Tox_Err_Group_Topic_Set tp_err;
|
Tox_Err_Group_Topic_Set tp_err;
|
||||||
tox_group_set_topic(tox0, groupnumber, (const uint8_t *)TOPIC, TOPIC_LEN, &tp_err);
|
tox_group_set_topic(tox0, groupnumber, (const uint8_t *)TOPIC, TOPIC_LEN, &tp_err);
|
||||||
@@ -359,7 +359,7 @@ static void group_announce_test(AutoTox *autotoxes)
|
|||||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||||
ck_assert(self_status == TOX_USER_STATUS_BUSY);
|
ck_assert(self_status == TOX_USER_STATUS_BUSY);
|
||||||
|
|
||||||
fprintf(stderr, "Peer 0 successfully changed status to %d\n", self_status);
|
fprintf(stderr, "Peer 0 successfully changed status to %u\n", self_status);
|
||||||
|
|
||||||
while (!state1->peer_nick && !state1->peer_status) {
|
while (!state1->peer_nick && !state1->peer_status) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
Tox_Err_Group_New new_err;
|
Tox_Err_Group_New new_err;
|
||||||
uint32_t groupnumber = tox_group_new(tox0, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)"test", 4,
|
uint32_t groupnumber = tox_group_new(tox0, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)"test", 4,
|
||||||
(const uint8_t *)"test", 4, &new_err);
|
(const uint8_t *)"test", 4, &new_err);
|
||||||
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %d", new_err);
|
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %u", new_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|
||||||
@@ -138,12 +138,12 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||||
|
|
||||||
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
||||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", id_err);
|
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%u", id_err);
|
||||||
|
|
||||||
// peer 1 joins public group with no password
|
// peer 1 joins public group with no password
|
||||||
Tox_Err_Group_Join join_err;
|
Tox_Err_Group_Join join_err;
|
||||||
tox_group_join(tox1, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
tox_group_join(tox1, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
|
|
||||||
while (state0->num_peers < 1) {
|
while (state0->num_peers < 1) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -154,13 +154,13 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
// founder sets a password
|
// founder sets a password
|
||||||
Tox_Err_Group_Set_Password pass_set_err;
|
Tox_Err_Group_Set_Password pass_set_err;
|
||||||
tox_group_set_password(tox0, groupnumber, (const uint8_t *)PASSWORD, PASS_LEN, &pass_set_err);
|
tox_group_set_password(tox0, groupnumber, (const uint8_t *)PASSWORD, PASS_LEN, &pass_set_err);
|
||||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "%d", pass_set_err);
|
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "%u", pass_set_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||||
|
|
||||||
// peer 2 attempts to join with no password
|
// peer 2 attempts to join with no password
|
||||||
tox_group_join(tox2, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
tox_group_join(tox2, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
|
|
||||||
while (!state2->password_fail) {
|
while (!state2->password_fail) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -170,7 +170,7 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
// peer 3 attempts to join with invalid password
|
// peer 3 attempts to join with invalid password
|
||||||
tox_group_join(tox3, chat_id, (const uint8_t *)"Test", 4, (const uint8_t *)WRONG_PASS, WRONG_PASS_LEN, &join_err);
|
tox_group_join(tox3, chat_id, (const uint8_t *)"Test", 4, (const uint8_t *)WRONG_PASS, WRONG_PASS_LEN, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
|
|
||||||
while (!state3->password_fail) {
|
while (!state3->password_fail) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -181,13 +181,13 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
// founder sets peer limit to 1
|
// founder sets peer limit to 1
|
||||||
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
||||||
tox_group_set_peer_limit(tox0, groupnumber, 1, &limit_set_err);
|
tox_group_set_peer_limit(tox0, groupnumber, 1, &limit_set_err);
|
||||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "%d", limit_set_err);
|
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "%u", limit_set_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||||
|
|
||||||
// peer 4 attempts to join with correct password
|
// peer 4 attempts to join with correct password
|
||||||
tox_group_join(tox4, chat_id, (const uint8_t *)"Test", 4, (const uint8_t *)PASSWORD, PASS_LEN, &join_err);
|
tox_group_join(tox4, chat_id, (const uint8_t *)"Test", 4, (const uint8_t *)PASSWORD, PASS_LEN, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
|
|
||||||
while (!state4->peer_limit_fail) {
|
while (!state4->peer_limit_fail) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -197,16 +197,16 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
// founder removes password and increases peer limit to 100
|
// founder removes password and increases peer limit to 100
|
||||||
tox_group_set_password(tox0, groupnumber, nullptr, 0, &pass_set_err);
|
tox_group_set_password(tox0, groupnumber, nullptr, 0, &pass_set_err);
|
||||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "%d", pass_set_err);
|
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "%u", pass_set_err);
|
||||||
|
|
||||||
tox_group_set_peer_limit(tox0, groupnumber, 100, &limit_set_err);
|
tox_group_set_peer_limit(tox0, groupnumber, 100, &limit_set_err);
|
||||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "%d", limit_set_err);
|
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "%u", limit_set_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||||
|
|
||||||
// peer 5 attempts to join group
|
// peer 5 attempts to join group
|
||||||
tox_group_join(tox5, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
tox_group_join(tox5, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
|
|
||||||
while (!state5->connected) {
|
while (!state5->connected) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -217,13 +217,13 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
// founder makes group private
|
// founder makes group private
|
||||||
Tox_Err_Group_Set_Privacy_State priv_err;
|
Tox_Err_Group_Set_Privacy_State priv_err;
|
||||||
tox_group_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PRIVATE, &priv_err);
|
tox_group_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PRIVATE, &priv_err);
|
||||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "%d", priv_err);
|
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "%u", priv_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||||
|
|
||||||
// peer 6 attempts to join group via chat ID
|
// peer 6 attempts to join group via chat ID
|
||||||
tox_group_join(tox6, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
tox_group_join(tox6, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
|
|
||||||
// since we don't receive a fail packet in this case we just wait a while and check if we're in the group
|
// since we don't receive a fail packet in this case we just wait a while and check if we're in the group
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 20000);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 20000);
|
||||||
@@ -234,7 +234,7 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
// founder makes group public again
|
// founder makes group public again
|
||||||
tox_group_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PUBLIC, &priv_err);
|
tox_group_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PUBLIC, &priv_err);
|
||||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "%d", priv_err);
|
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "%u", priv_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
for (size_t i = 7; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 7; i < NUM_GROUP_TOXES; ++i) {
|
||||||
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t expected_peer_count = num_new_peers + state0->num_peers + 1;
|
const uint32_t expected_peer_count = num_new_peers + state0->num_peers + 1;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/util.h"
|
#include "../toxcore/util.h"
|
||||||
|
|
||||||
typedef struct State {
|
typedef struct State {
|
||||||
@@ -90,7 +91,7 @@ static void group_invite_handler(const Tox_Event_Group_Invite *event, void *user
|
|||||||
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
|
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
|
||||||
{
|
{
|
||||||
const Tox_Group_Join_Fail fail_type = tox_event_group_join_fail_get_fail_type(event);
|
const Tox_Group_Join_Fail fail_type = tox_event_group_join_fail_get_fail_type(event);
|
||||||
printf("join failed: %d\n", fail_type);
|
printf("join failed: %u\n", fail_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||||
@@ -448,7 +449,7 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
// tox0 ignores tox1
|
// tox0 ignores tox1
|
||||||
Tox_Err_Group_Set_Ignore ig_err;
|
Tox_Err_Group_Set_Ignore ig_err;
|
||||||
tox_group_set_ignore(tox0, group_number, state0->peer_id, true, &ig_err);
|
tox_group_set_ignore(tox0, group_number, state0->peer_id, true, &ig_err);
|
||||||
ck_assert_msg(ig_err == TOX_ERR_GROUP_SET_IGNORE_OK, "%d", ig_err);
|
ck_assert_msg(ig_err == TOX_ERR_GROUP_SET_IGNORE_OK, "%u", ig_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|
||||||
@@ -460,7 +461,7 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
// tox0 unignores tox1
|
// tox0 unignores tox1
|
||||||
tox_group_set_ignore(tox0, group_number, state0->peer_id, false, &ig_err);
|
tox_group_set_ignore(tox0, group_number, state0->peer_id, false, &ig_err);
|
||||||
ck_assert_msg(ig_err == TOX_ERR_GROUP_SET_IGNORE_OK, "%d", ig_err);
|
ck_assert_msg(ig_err == TOX_ERR_GROUP_SET_IGNORE_OK, "%u", ig_err);
|
||||||
|
|
||||||
fprintf(stderr, "Sending private action...\n");
|
fprintf(stderr, "Sending private action...\n");
|
||||||
|
|
||||||
@@ -470,7 +471,7 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
TOX_MESSAGE_TYPE_ACTION, (const uint8_t *)TEST_PRIVATE_MESSAGE,
|
TOX_MESSAGE_TYPE_ACTION, (const uint8_t *)TEST_PRIVATE_MESSAGE,
|
||||||
TEST_PRIVATE_MESSAGE_LEN, &m_err);
|
TEST_PRIVATE_MESSAGE_LEN, &m_err);
|
||||||
|
|
||||||
ck_assert_msg(m_err == TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK, "%d", m_err);
|
ck_assert_msg(m_err == TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK, "%u", m_err);
|
||||||
|
|
||||||
while (!state0->private_message_received) {
|
while (!state0->private_message_received) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -485,11 +486,11 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
Tox_Err_Group_Send_Custom_Packet c_err;
|
Tox_Err_Group_Send_Custom_Packet c_err;
|
||||||
tox_group_send_custom_packet(tox1, group_number, true, (const uint8_t *)TEST_CUSTOM_PACKET, TEST_CUSTOM_PACKET_LEN,
|
tox_group_send_custom_packet(tox1, group_number, true, (const uint8_t *)TEST_CUSTOM_PACKET, TEST_CUSTOM_PACKET_LEN,
|
||||||
&c_err);
|
&c_err);
|
||||||
ck_assert_msg(c_err == TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK, "%d", c_err);
|
ck_assert_msg(c_err == TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK, "%u", c_err);
|
||||||
|
|
||||||
tox_group_send_custom_packet(tox1, group_number, false, (const uint8_t *)TEST_CUSTOM_PACKET, TEST_CUSTOM_PACKET_LEN,
|
tox_group_send_custom_packet(tox1, group_number, false, (const uint8_t *)TEST_CUSTOM_PACKET, TEST_CUSTOM_PACKET_LEN,
|
||||||
&c_err);
|
&c_err);
|
||||||
ck_assert_msg(c_err == TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK, "%d", c_err);
|
ck_assert_msg(c_err == TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK, "%u", c_err);
|
||||||
|
|
||||||
fprintf(stderr, "Sending custom private packets...\n");
|
fprintf(stderr, "Sending custom private packets...\n");
|
||||||
|
|
||||||
@@ -499,13 +500,13 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
(const uint8_t *)TEST_CUSTOM_PRIVATE_PACKET,
|
(const uint8_t *)TEST_CUSTOM_PRIVATE_PACKET,
|
||||||
TEST_CUSTOM_PRIVATE_PACKET_LEN, &cperr);
|
TEST_CUSTOM_PRIVATE_PACKET_LEN, &cperr);
|
||||||
|
|
||||||
ck_assert_msg(cperr == TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_OK, "%d", cperr);
|
ck_assert_msg(cperr == TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_OK, "%u", cperr);
|
||||||
|
|
||||||
tox_group_send_custom_private_packet(tox1, group_number, state1->peer_id, false,
|
tox_group_send_custom_private_packet(tox1, group_number, state1->peer_id, false,
|
||||||
(const uint8_t *)TEST_CUSTOM_PRIVATE_PACKET,
|
(const uint8_t *)TEST_CUSTOM_PRIVATE_PACKET,
|
||||||
TEST_CUSTOM_PRIVATE_PACKET_LEN, &cperr);
|
TEST_CUSTOM_PRIVATE_PACKET_LEN, &cperr);
|
||||||
|
|
||||||
ck_assert_msg(cperr == TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_OK, "%d", cperr);
|
ck_assert_msg(cperr == TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_OK, "%u", cperr);
|
||||||
|
|
||||||
while (state0->custom_packets_received < 2 || state0->custom_private_packets_received < 2) {
|
while (state0->custom_packets_received < 2 || state0->custom_private_packets_received < 2) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -518,7 +519,7 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
tox_group_send_custom_packet(tox1, group_number, false, (const uint8_t *)TEST_CUSTOM_PACKET_LARGE, TEST_CUSTOM_PACKET_LARGE_LEN,
|
tox_group_send_custom_packet(tox1, group_number, false, (const uint8_t *)TEST_CUSTOM_PACKET_LARGE, TEST_CUSTOM_PACKET_LARGE_LEN,
|
||||||
&c_err);
|
&c_err);
|
||||||
ck_assert_msg(c_err == TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK, "%d", c_err);
|
ck_assert_msg(c_err == TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK, "%u", c_err);
|
||||||
|
|
||||||
while (state0->custom_packets_received < 3) {
|
while (state0->custom_packets_received < 3) {
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ static size_t get_state_index_by_nick(const AutoTox *autotoxes, size_t num_peers
|
|||||||
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
|
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
|
||||||
{
|
{
|
||||||
const Tox_Group_Join_Fail fail_type = tox_event_group_join_fail_get_fail_type(event);
|
const Tox_Group_Join_Fail fail_type = tox_event_group_join_fail_get_fail_type(event);
|
||||||
fprintf(stderr, "Failed to join group: %d", fail_type);
|
fprintf(stderr, "Failed to join group: %u", fail_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||||
@@ -268,7 +268,7 @@ static void group_mod_event_handler(const Tox_Event_Group_Moderation *event, voi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(q_err == TOX_ERR_GROUP_PEER_QUERY_OK, "error %d", q_err);
|
ck_assert_msg(q_err == TOX_ERR_GROUP_PEER_QUERY_OK, "error %u", q_err);
|
||||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||||
|
|
||||||
tox_group_peer_get_name(autotox->tox, group_number, target_peer_id, (uint8_t *) peer_name, &q_err);
|
tox_group_peer_get_name(autotox->tox, group_number, target_peer_id, (uint8_t *) peer_name, &q_err);
|
||||||
@@ -279,7 +279,7 @@ static void group_mod_event_handler(const Tox_Event_Group_Moderation *event, voi
|
|||||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||||
ck_assert(role <= TOX_GROUP_ROLE_OBSERVER);
|
ck_assert(role <= TOX_GROUP_ROLE_OBSERVER);
|
||||||
|
|
||||||
fprintf(stderr, "tox%u: got moderator event %d (%s), role = %s\n",
|
fprintf(stderr, "tox%u: got moderator event %u (%s), role = %s\n",
|
||||||
autotox->index, mod_type, tox_group_mod_event_to_string(mod_type),
|
autotox->index, mod_type, tox_group_mod_event_to_string(mod_type),
|
||||||
tox_group_role_to_string(role));
|
tox_group_role_to_string(role));
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ static void group_mod_event_handler(const Tox_Event_Group_Moderation *event, voi
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
ck_assert_msg(0, "Got invalid moderator event %d", mod_type);
|
ck_assert_msg(0, "Got invalid moderator event %u", mod_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ static void voice_state_message_test(AutoTox *autotox, Tox_Group_Voice_State voi
|
|||||||
case TOX_GROUP_ROLE_USER: {
|
case TOX_GROUP_ROLE_USER: {
|
||||||
if (voice_state != TOX_GROUP_VOICE_STATE_ALL) {
|
if (voice_state != TOX_GROUP_VOICE_STATE_ALL) {
|
||||||
ck_assert_msg(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS,
|
ck_assert_msg(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS,
|
||||||
"%d", msg_err);
|
"%u", msg_err);
|
||||||
} else {
|
} else {
|
||||||
ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
}
|
}
|
||||||
@@ -469,14 +469,14 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
GROUP_NAME_LEN, (const uint8_t *)state0->self_name, state0->self_name_length,
|
GROUP_NAME_LEN, (const uint8_t *)state0->self_name, state0->self_name_length,
|
||||||
&err_new);
|
&err_new);
|
||||||
|
|
||||||
ck_assert_msg(err_new == TOX_ERR_GROUP_NEW_OK, "Failed to create group. error: %d\n", err_new);
|
ck_assert_msg(err_new == TOX_ERR_GROUP_NEW_OK, "Failed to create group. error: %u\n", err_new);
|
||||||
|
|
||||||
/* Founder gets chat ID */
|
/* Founder gets chat ID */
|
||||||
Tox_Err_Group_State_Query id_err;
|
Tox_Err_Group_State_Query id_err;
|
||||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||||
tox_group_get_chat_id(tox0, state0->group_number, chat_id, &id_err);
|
tox_group_get_chat_id(tox0, state0->group_number, chat_id, &id_err);
|
||||||
|
|
||||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get chat ID. error: %d", id_err);
|
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get chat ID. error: %u", id_err);
|
||||||
|
|
||||||
fprintf(stderr, "Peers attemping to join DHT group via the chat ID\n");
|
fprintf(stderr, "Peers attemping to join DHT group via the chat ID\n");
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
state->group_number = tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)state->self_name,
|
state->group_number = tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)state->self_name,
|
||||||
state->self_name_length,
|
state->self_name_length,
|
||||||
nullptr, 0, &join_err);
|
nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "Peer %s (%zu) failed to join group. error %d",
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "Peer %s (%zu) failed to join group. error %u",
|
||||||
state->self_name, i, join_err);
|
state->self_name, i, join_err);
|
||||||
|
|
||||||
c_sleep(100);
|
c_sleep(100);
|
||||||
@@ -527,7 +527,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
Tox_Err_Group_Set_Role role_err;
|
Tox_Err_Group_Set_Role role_err;
|
||||||
tox_group_set_role(tox0, state0->group_number, state0->peers[0].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
tox_group_set_role(tox0, state0->group_number, state0->peers[0].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %u", role_err);
|
||||||
|
|
||||||
// manually flag the role setter because they don't get a callback
|
// manually flag the role setter because they don't get a callback
|
||||||
state0->mod_check = true;
|
state0->mod_check = true;
|
||||||
@@ -542,7 +542,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
fprintf(stderr, "Founder setting %s to observer\n", state0->peers[1].name);
|
fprintf(stderr, "Founder setting %s to observer\n", state0->peers[1].name);
|
||||||
|
|
||||||
tox_group_set_role(tox0, state0->group_number, state0->peers[1].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
tox_group_set_role(tox0, state0->group_number, state0->peers[1].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set observer. error: %d", role_err);
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set observer. error: %u", role_err);
|
||||||
|
|
||||||
state0->observer_check = true;
|
state0->observer_check = true;
|
||||||
++state0->observer_event_count;
|
++state0->observer_event_count;
|
||||||
@@ -553,7 +553,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
fprintf(stderr, "Founder setting %s to observer\n", state0->peers[2].name);
|
fprintf(stderr, "Founder setting %s to observer\n", state0->peers[2].name);
|
||||||
|
|
||||||
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set observer. error: %d", role_err);
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set observer. error: %u", role_err);
|
||||||
|
|
||||||
state0->observer_check = true;
|
state0->observer_check = true;
|
||||||
++state0->observer_event_count;
|
++state0->observer_event_count;
|
||||||
@@ -579,7 +579,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
fprintf(stderr, "%s is promoting %s back to user\n", state1->self_name, state0->peers[1].name);
|
fprintf(stderr, "%s is promoting %s back to user\n", state1->self_name, state0->peers[1].name);
|
||||||
|
|
||||||
tox_group_set_role(tox1, state1->group_number, obs_peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
tox_group_set_role(tox1, state1->group_number, obs_peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to promote observer back to user. error: %d",
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to promote observer back to user. error: %u",
|
||||||
role_err);
|
role_err);
|
||||||
|
|
||||||
state1->user_check = true;
|
state1->user_check = true;
|
||||||
@@ -592,7 +592,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
fprintf(stderr, "Founder setting %s to moderator\n", state0->peers[2].name);
|
fprintf(stderr, "Founder setting %s to moderator\n", state0->peers[2].name);
|
||||||
|
|
||||||
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %u", role_err);
|
||||||
|
|
||||||
state0->mod_check = true;
|
state0->mod_check = true;
|
||||||
++state0->mod_event_count;
|
++state0->mod_event_count;
|
||||||
@@ -624,7 +624,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
fprintf(stderr, "Founder is kicking %s\n", state0->peers[0].name);
|
fprintf(stderr, "Founder is kicking %s\n", state0->peers[0].name);
|
||||||
|
|
||||||
tox_group_kick_peer(tox0, state0->group_number, state0->peers[0].peer_id, &k_err);
|
tox_group_kick_peer(tox0, state0->group_number, state0->peers[0].peer_id, &k_err);
|
||||||
ck_assert_msg(k_err == TOX_ERR_GROUP_KICK_PEER_OK, "Failed to kick peer. error: %d", k_err);
|
ck_assert_msg(k_err == TOX_ERR_GROUP_KICK_PEER_OK, "Failed to kick peer. error: %u", k_err);
|
||||||
|
|
||||||
state0->kick_check = true;
|
state0->kick_check = true;
|
||||||
check_mod_event(autotoxes, NUM_GROUP_TOXES, TOX_GROUP_MOD_EVENT_KICK);
|
check_mod_event(autotoxes, NUM_GROUP_TOXES, TOX_GROUP_MOD_EVENT_KICK);
|
||||||
@@ -633,7 +633,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
fprintf(stderr, "Founder is demoting moderator to user\n");
|
fprintf(stderr, "Founder is demoting moderator to user\n");
|
||||||
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to demote peer 3 to User. error: %d", role_err);
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to demote peer 3 to User. error: %u", role_err);
|
||||||
|
|
||||||
state0->user_check = true;
|
state0->user_check = true;
|
||||||
++state0->user_event_count;
|
++state0->user_event_count;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ static void group_topic_lock_handler(const Tox_Event_Group_Topic_Lock *event,
|
|||||||
Tox_Group_Topic_Lock current_topic_lock = tox_group_get_topic_lock(autotox->tox, groupnumber, &err);
|
Tox_Group_Topic_Lock current_topic_lock = tox_group_get_topic_lock(autotox->tox, groupnumber, &err);
|
||||||
|
|
||||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||||
ck_assert_msg(current_topic_lock == topic_lock, "topic locks don't match in callback: %d %d",
|
ck_assert_msg(current_topic_lock == topic_lock, "topic locks don't match in callback: %u %u",
|
||||||
topic_lock, current_topic_lock);
|
topic_lock, current_topic_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ static void group_voice_state_handler(const Tox_Event_Group_Voice_State *event,
|
|||||||
Tox_Group_Voice_State current_voice_state = tox_group_get_voice_state(autotox->tox, groupnumber, &err);
|
Tox_Group_Voice_State current_voice_state = tox_group_get_voice_state(autotox->tox, groupnumber, &err);
|
||||||
|
|
||||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||||
ck_assert_msg(current_voice_state == voice_state, "voice states don't match in callback: %d %d",
|
ck_assert_msg(current_voice_state == voice_state, "voice states don't match in callback: %u %u",
|
||||||
voice_state, current_voice_state);
|
voice_state, current_voice_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,21 +171,21 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
|||||||
Tox_Err_Group_State_Query query_err;
|
Tox_Err_Group_State_Query query_err;
|
||||||
|
|
||||||
Tox_Group_Privacy_State my_priv_state = tox_group_get_privacy_state(tox, groupnumber, &query_err);
|
Tox_Group_Privacy_State my_priv_state = tox_group_get_privacy_state(tox, groupnumber, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get privacy state: %d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get privacy state: %u", query_err);
|
||||||
|
|
||||||
if (my_priv_state != priv_state) {
|
if (my_priv_state != priv_state) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t my_peer_limit = tox_group_get_peer_limit(tox, groupnumber, &query_err);
|
uint32_t my_peer_limit = tox_group_get_peer_limit(tox, groupnumber, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get peer limit: %d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get peer limit: %u", query_err);
|
||||||
|
|
||||||
if (my_peer_limit != peer_limit) {
|
if (my_peer_limit != peer_limit) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t my_pass_len = tox_group_get_password_size(tox, groupnumber, &query_err);
|
size_t my_pass_len = tox_group_get_password_size(tox, groupnumber, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get password size: %d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get password size: %u", query_err);
|
||||||
|
|
||||||
if (my_pass_len != pass_len) {
|
if (my_pass_len != pass_len) {
|
||||||
return -5;
|
return -5;
|
||||||
@@ -197,7 +197,7 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
|||||||
uint8_t my_pass[TOX_GROUP_MAX_PASSWORD_SIZE + 1];
|
uint8_t my_pass[TOX_GROUP_MAX_PASSWORD_SIZE + 1];
|
||||||
tox_group_get_password(tox, groupnumber, my_pass, &query_err);
|
tox_group_get_password(tox, groupnumber, my_pass, &query_err);
|
||||||
my_pass[my_pass_len] = 0;
|
my_pass[my_pass_len] = 0;
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get password: %d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get password: %u", query_err);
|
||||||
|
|
||||||
if (memcmp(my_pass, password, my_pass_len) != 0) {
|
if (memcmp(my_pass, password, my_pass_len) != 0) {
|
||||||
return -6;
|
return -6;
|
||||||
@@ -206,7 +206,7 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
|||||||
|
|
||||||
/* Group name should never change */
|
/* Group name should never change */
|
||||||
size_t my_gname_len = tox_group_get_name_size(tox, groupnumber, &query_err);
|
size_t my_gname_len = tox_group_get_name_size(tox, groupnumber, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get group name size: %d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get group name size: %u", query_err);
|
||||||
|
|
||||||
if (my_gname_len != GROUP_NAME_LEN) {
|
if (my_gname_len != GROUP_NAME_LEN) {
|
||||||
return -7;
|
return -7;
|
||||||
@@ -223,14 +223,14 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tox_Group_Topic_Lock current_topic_lock = tox_group_get_topic_lock(tox, groupnumber, &query_err);
|
Tox_Group_Topic_Lock current_topic_lock = tox_group_get_topic_lock(tox, groupnumber, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get topic lock: %d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get topic lock: %u", query_err);
|
||||||
|
|
||||||
if (current_topic_lock != topic_lock) {
|
if (current_topic_lock != topic_lock) {
|
||||||
return -9;
|
return -9;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tox_Group_Voice_State current_voice_state = tox_group_get_voice_state(tox, groupnumber, &query_err);
|
Tox_Group_Voice_State current_voice_state = tox_group_get_voice_state(tox, groupnumber, &query_err);
|
||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get voice state: %d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get voice state: %u", query_err);
|
||||||
|
|
||||||
if (current_voice_state != voice_state) {
|
if (current_voice_state != voice_state) {
|
||||||
return -10;
|
return -10;
|
||||||
@@ -246,24 +246,24 @@ static void set_group_state(Tox *tox, uint32_t groupnumber, uint32_t peer_limit,
|
|||||||
|
|
||||||
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
||||||
tox_group_set_peer_limit(tox, groupnumber, peer_limit, &limit_set_err);
|
tox_group_set_peer_limit(tox, groupnumber, peer_limit, &limit_set_err);
|
||||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "failed to set peer limit: %d", limit_set_err);
|
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "failed to set peer limit: %u", limit_set_err);
|
||||||
|
|
||||||
Tox_Err_Group_Set_Privacy_State priv_err;
|
Tox_Err_Group_Set_Privacy_State priv_err;
|
||||||
tox_group_set_privacy_state(tox, groupnumber, priv_state, &priv_err);
|
tox_group_set_privacy_state(tox, groupnumber, priv_state, &priv_err);
|
||||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "failed to set privacy state: %d", priv_err);
|
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "failed to set privacy state: %u", priv_err);
|
||||||
|
|
||||||
Tox_Err_Group_Set_Password pass_set_err;
|
Tox_Err_Group_Set_Password pass_set_err;
|
||||||
tox_group_set_password(tox, groupnumber, password, pass_len, &pass_set_err);
|
tox_group_set_password(tox, groupnumber, password, pass_len, &pass_set_err);
|
||||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "failed to set password: %d", pass_set_err);
|
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "failed to set password: %u", pass_set_err);
|
||||||
|
|
||||||
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
||||||
tox_group_set_topic_lock(tox, groupnumber, topic_lock, &lock_set_err);
|
tox_group_set_topic_lock(tox, groupnumber, topic_lock, &lock_set_err);
|
||||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to set topic lock: %d",
|
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to set topic lock: %u",
|
||||||
lock_set_err);
|
lock_set_err);
|
||||||
|
|
||||||
Tox_Err_Group_Set_Voice_State voice_set_err;
|
Tox_Err_Group_Set_Voice_State voice_set_err;
|
||||||
tox_group_set_voice_state(tox, groupnumber, voice_state, &voice_set_err);
|
tox_group_set_voice_state(tox, groupnumber, voice_state, &voice_set_err);
|
||||||
ck_assert_msg(voice_set_err == TOX_ERR_GROUP_SET_VOICE_STATE_OK, "failed to set voice state: %d",
|
ck_assert_msg(voice_set_err == TOX_ERR_GROUP_SET_VOICE_STATE_OK, "failed to set voice state: %u",
|
||||||
voice_set_err);
|
voice_set_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ static void group_state_test(AutoTox *autotoxes)
|
|||||||
uint32_t groupnum = tox_group_new(tox0, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)GROUP_NAME, GROUP_NAME_LEN,
|
uint32_t groupnum = tox_group_new(tox0, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)GROUP_NAME, GROUP_NAME_LEN,
|
||||||
(const uint8_t *)PEER0_NICK, PEER0_NICK_LEN, &new_err);
|
(const uint8_t *)PEER0_NICK, PEER0_NICK_LEN, &new_err);
|
||||||
|
|
||||||
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %d", new_err);
|
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %u", new_err);
|
||||||
|
|
||||||
/* Founder sets default group state before anyone else joins */
|
/* Founder sets default group state before anyone else joins */
|
||||||
set_group_state(tox0, groupnum, PEER_LIMIT_1, TOX_GROUP_PRIVACY_STATE_PUBLIC, TOX_GROUP_VOICE_STATE_ALL,
|
set_group_state(tox0, groupnum, PEER_LIMIT_1, TOX_GROUP_PRIVACY_STATE_PUBLIC, TOX_GROUP_VOICE_STATE_ALL,
|
||||||
@@ -298,7 +298,7 @@ static void group_state_test(AutoTox *autotoxes)
|
|||||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||||
tox_group_get_chat_id(tox0, groupnum, chat_id, &id_err);
|
tox_group_get_chat_id(tox0, groupnum, chat_id, &id_err);
|
||||||
|
|
||||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "tox_group_get_chat_id failed %d", id_err);
|
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "tox_group_get_chat_id failed %u", id_err);
|
||||||
|
|
||||||
/* All other peers join the group using the Chat ID and password */
|
/* All other peers join the group using the Chat ID and password */
|
||||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
||||||
@@ -307,7 +307,7 @@ static void group_state_test(AutoTox *autotoxes)
|
|||||||
Tox_Err_Group_Join join_err;
|
Tox_Err_Group_Join join_err;
|
||||||
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, (const uint8_t *)PASSWORD, PASS_LEN,
|
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, (const uint8_t *)PASSWORD, PASS_LEN,
|
||||||
&join_err);
|
&join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "tox_group_join failed: %d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "tox_group_join failed: %u", join_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Peers attempting to join group\n");
|
fprintf(stderr, "Peers attempting to join group\n");
|
||||||
@@ -344,7 +344,7 @@ static void group_state_test(AutoTox *autotoxes)
|
|||||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||||
Tox_Err_Group_Leave err_exit;
|
Tox_Err_Group_Leave err_exit;
|
||||||
tox_group_leave(autotoxes[i].tox, groupnum, nullptr, 0, &err_exit);
|
tox_group_leave(autotoxes[i].tox, groupnum, nullptr, 0, &err_exit);
|
||||||
ck_assert_msg(err_exit == TOX_ERR_GROUP_LEAVE_OK, "%d", err_exit);
|
ck_assert_msg(err_exit == TOX_ERR_GROUP_LEAVE_OK, "%u", err_exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "All tests passed!\n");
|
fprintf(stderr, "All tests passed!\n");
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
|
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxcore/util.h"
|
#include "../toxcore/util.h"
|
||||||
|
|
||||||
@@ -364,12 +365,12 @@ static void group_sync_test(AutoTox *autotoxes)
|
|||||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||||
|
|
||||||
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
||||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", id_err);
|
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%u", id_err);
|
||||||
|
|
||||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
||||||
Tox_Err_Group_Join join_err;
|
Tox_Err_Group_Join join_err;
|
||||||
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "%u", join_err);
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +382,7 @@ static void group_sync_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
||||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %d",
|
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %u",
|
||||||
lock_set_err);
|
lock_set_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
@@ -393,7 +394,7 @@ static void group_sync_test(AutoTox *autotoxes)
|
|||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|
||||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
||||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %d",
|
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %u",
|
||||||
lock_set_err);
|
lock_set_err);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -407,7 +408,7 @@ static void group_sync_test(AutoTox *autotoxes)
|
|||||||
for (size_t i = 0; i < state0->peers->num_peers; ++i) {
|
for (size_t i = 0; i < state0->peers->num_peers; ++i) {
|
||||||
tox_group_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_MODERATOR,
|
tox_group_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_MODERATOR,
|
||||||
&role_err);
|
&role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %u", role_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "founder enabled topic lock and set all peers to moderator role\n");
|
fprintf(stderr, "founder enabled topic lock and set all peers to moderator role\n");
|
||||||
@@ -425,7 +426,7 @@ static void group_sync_test(AutoTox *autotoxes)
|
|||||||
for (size_t i = 0; i < num_demoted; ++i) {
|
for (size_t i = 0; i < num_demoted; ++i) {
|
||||||
tox_group_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_USER,
|
tox_group_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_USER,
|
||||||
&role_err);
|
&role_err);
|
||||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set user. error: %d", role_err);
|
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set user. error: %u", role_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ static void group_tcp_test(AutoTox *autotoxes)
|
|||||||
Tox_Err_Group_New new_err;
|
Tox_Err_Group_New new_err;
|
||||||
uint32_t groupnumber = tox_group_new(autotoxes[0].tox, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)"test", 4,
|
uint32_t groupnumber = tox_group_new(autotoxes[0].tox, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)"test", 4,
|
||||||
(const uint8_t *)"test", 4, &new_err);
|
(const uint8_t *)"test", 4, &new_err);
|
||||||
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %d", new_err);
|
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %u", new_err);
|
||||||
|
|
||||||
iterate_group(autotoxes, NUM_GROUP_TOXES, GROUP_ITERATION_INTERVAL);
|
iterate_group(autotoxes, NUM_GROUP_TOXES, GROUP_ITERATION_INTERVAL);
|
||||||
|
|
||||||
@@ -164,14 +164,14 @@ static void group_tcp_test(AutoTox *autotoxes)
|
|||||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||||
|
|
||||||
tox_group_get_chat_id(autotoxes[0].tox, groupnumber, chat_id, &id_err);
|
tox_group_get_chat_id(autotoxes[0].tox, groupnumber, chat_id, &id_err);
|
||||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", id_err);
|
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%u", id_err);
|
||||||
|
|
||||||
printf("Tox 0 created new group...\n");
|
printf("Tox 0 created new group...\n");
|
||||||
|
|
||||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
||||||
Tox_Err_Group_Join jerr;
|
Tox_Err_Group_Join jerr;
|
||||||
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"test", 4, nullptr, 0, &jerr);
|
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"test", 4, nullptr, 0, &jerr);
|
||||||
ck_assert_msg(jerr == TOX_ERR_GROUP_JOIN_OK, "%d", jerr);
|
ck_assert_msg(jerr == TOX_ERR_GROUP_JOIN_OK, "%u", jerr);
|
||||||
iterate_group(autotoxes, NUM_GROUP_TOXES, GROUP_ITERATION_INTERVAL * 10);
|
iterate_group(autotoxes, NUM_GROUP_TOXES, GROUP_ITERATION_INTERVAL * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ static void group_tcp_test(AutoTox *autotoxes)
|
|||||||
tox_group_send_private_message(autotoxes[0].tox, groupnumber, state0->peer_id[i],
|
tox_group_send_private_message(autotoxes[0].tox, groupnumber, state0->peer_id[i],
|
||||||
TOX_MESSAGE_TYPE_NORMAL,
|
TOX_MESSAGE_TYPE_NORMAL,
|
||||||
(const uint8_t *)CODEWORD, CODEWORD_LEN, &perr);
|
(const uint8_t *)CODEWORD, CODEWORD_LEN, &perr);
|
||||||
ck_assert_msg(perr == TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK, "%d", perr);
|
ck_assert_msg(perr == TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK, "%u", perr);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!all_peers_got_code(autotoxes))
|
while (!all_peers_got_code(autotoxes))
|
||||||
|
|||||||
@@ -5,14 +5,13 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxcore/group_chats.h"
|
|
||||||
|
|
||||||
#define NUM_GROUP_TOXES 3
|
#define NUM_GROUP_TOXES 3
|
||||||
|
|
||||||
@@ -241,7 +240,7 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
GROUP_NAME_LEN,
|
GROUP_NAME_LEN,
|
||||||
(const uint8_t *)PEER0_NICK, PEER0_NICK_LEN, &new_err);
|
(const uint8_t *)PEER0_NICK, PEER0_NICK_LEN, &new_err);
|
||||||
|
|
||||||
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %d", new_err);
|
ck_assert_msg(new_err == TOX_ERR_GROUP_NEW_OK, "tox_group_new failed: %u", new_err);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|
||||||
@@ -254,7 +253,7 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||||
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
||||||
|
|
||||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "tox_group_get_chat_id failed %d", id_err);
|
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "tox_group_get_chat_id failed %u", id_err);
|
||||||
|
|
||||||
/* All other peers join the group using the Chat ID */
|
/* All other peers join the group using the Chat ID */
|
||||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
||||||
@@ -262,7 +261,7 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
Tox_Err_Group_Join join_err;
|
Tox_Err_Group_Join join_err;
|
||||||
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
tox_group_join(autotoxes[i].tox, chat_id, (const uint8_t *)"Test", 4, nullptr, 0, &join_err);
|
||||||
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "tox_group_join failed: %d", join_err);
|
ck_assert_msg(join_err == TOX_ERR_GROUP_JOIN_OK, "tox_group_join failed: %u", join_err);
|
||||||
|
|
||||||
c_sleep(100);
|
c_sleep(100);
|
||||||
}
|
}
|
||||||
@@ -276,7 +275,7 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
/* Founder disables topic lock */
|
/* Founder disables topic lock */
|
||||||
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
||||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %d",
|
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %u",
|
||||||
lock_set_err);
|
lock_set_err);
|
||||||
|
|
||||||
fprintf(stderr, "Topic lock disabled\n");
|
fprintf(stderr, "Topic lock disabled\n");
|
||||||
@@ -292,7 +291,7 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
/* founder silences the last peer he saw join */
|
/* founder silences the last peer he saw join */
|
||||||
Tox_Err_Group_Set_Role merr;
|
Tox_Err_Group_Set_Role merr;
|
||||||
tox_group_set_role(tox0, groupnumber, state0->peer_id, TOX_GROUP_ROLE_OBSERVER, &merr);
|
tox_group_set_role(tox0, groupnumber, state0->peer_id, TOX_GROUP_ROLE_OBSERVER, &merr);
|
||||||
ck_assert_msg(merr == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set %u to observer role: %d", state0->peer_id, merr);
|
ck_assert_msg(merr == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set %u to observer role: %u", state0->peer_id, merr);
|
||||||
|
|
||||||
fprintf(stderr, "Random peer is set to observer\n");
|
fprintf(stderr, "Random peer is set to observer\n");
|
||||||
|
|
||||||
@@ -305,7 +304,7 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
/* Founder enables topic lock and sets topic back to original */
|
/* Founder enables topic lock and sets topic back to original */
|
||||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
||||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %d",
|
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %u",
|
||||||
lock_set_err);
|
lock_set_err);
|
||||||
|
|
||||||
fprintf(stderr, "Topic lock enabled\n");
|
fprintf(stderr, "Topic lock enabled\n");
|
||||||
@@ -330,7 +329,7 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||||
Tox_Err_Group_Leave err_exit;
|
Tox_Err_Group_Leave err_exit;
|
||||||
tox_group_leave(autotoxes[i].tox, groupnumber, nullptr, 0, &err_exit);
|
tox_group_leave(autotoxes[i].tox, groupnumber, nullptr, 0, &err_exit);
|
||||||
ck_assert_msg(err_exit == TOX_ERR_GROUP_LEAVE_OK, "%d", err_exit);
|
ck_assert_msg(err_exit == TOX_ERR_GROUP_LEAVE_OK, "%u", err_exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "All tests passed!\n");
|
fprintf(stderr, "All tests passed!\n");
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ int main(void)
|
|||||||
// None of the iterations should have a connection.
|
// None of the iterations should have a connection.
|
||||||
const Tox_Connection status = tox_self_get_connection_status(tox);
|
const Tox_Connection status = tox_self_get_connection_status(tox);
|
||||||
ck_assert_msg(status == TOX_CONNECTION_NONE,
|
ck_assert_msg(status == TOX_CONNECTION_NONE,
|
||||||
"unexpectedly got a connection (%d)", status);
|
"unexpectedly got a connection (%u)", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
tox_kill(tox);
|
tox_kill(tox);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ int main(void)
|
|||||||
// None of the iterations should have a connection.
|
// None of the iterations should have a connection.
|
||||||
const Tox_Connection status = tox_self_get_connection_status(tox);
|
const Tox_Connection status = tox_self_get_connection_status(tox);
|
||||||
ck_assert_msg(status == TOX_CONNECTION_NONE,
|
ck_assert_msg(status == TOX_CONNECTION_NONE,
|
||||||
"unexpectedly got a connection (%d)", status);
|
"unexpectedly got a connection (%u)", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
tox_kill(tox);
|
tox_kill(tox);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ int main(void)
|
|||||||
} while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE ||
|
} while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE ||
|
||||||
tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE);
|
tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE);
|
||||||
|
|
||||||
printf(" %d <-> %d\n",
|
printf(" %u <-> %u\n",
|
||||||
tox_self_get_connection_status(tox1),
|
tox_self_get_connection_status(tox1),
|
||||||
tox_self_get_connection_status(tox2));
|
tox_self_get_connection_status(tox2));
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ int main(void)
|
|||||||
Tox_Err_Options_New options_err;
|
Tox_Err_Options_New options_err;
|
||||||
struct Tox_Options *tox_opts = tox_options_new(&options_err);
|
struct Tox_Options *tox_opts = tox_options_new(&options_err);
|
||||||
|
|
||||||
ck_assert_msg(options_err == TOX_ERR_OPTIONS_NEW_OK, "Failed to initialize tox options: %d\n", options_err);
|
ck_assert_msg(options_err == TOX_ERR_OPTIONS_NEW_OK, "Failed to initialize tox options: %u\n", options_err);
|
||||||
|
|
||||||
tox_options_default(tox_opts);
|
tox_options_default(tox_opts);
|
||||||
tox_options_set_udp_enabled(tox_opts, true);
|
tox_options_set_udp_enabled(tox_opts, true);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../toxcore/network.h"
|
#include "../toxcore/network.h"
|
||||||
|
#include "../toxcore/os_memory.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
#ifndef USE_IPV6
|
#ifndef USE_IPV6
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
#include "../testing/misc_tools.h"
|
||||||
#include "../toxcore/mono_time.h"
|
#include "../toxcore/mono_time.h"
|
||||||
|
#include "../toxcore/network.h"
|
||||||
#include "../toxcore/onion.h"
|
#include "../toxcore/onion.h"
|
||||||
#include "../toxcore/onion_announce.h"
|
#include "../toxcore/onion_announce.h"
|
||||||
#include "../toxcore/onion_client.h"
|
#include "../toxcore/onion_client.h"
|
||||||
#include "../toxcore/util.h"
|
#include "../toxcore/os_memory.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
@@ -237,8 +239,10 @@ static void test_basic(void)
|
|||||||
Mono_Time *mono_time2 = mono_time_new(mem, nullptr, nullptr);
|
Mono_Time *mono_time2 = mono_time_new(mem, nullptr, nullptr);
|
||||||
|
|
||||||
IP ip = get_loopback();
|
IP ip = get_loopback();
|
||||||
Onion *onion1 = new_onion(log1, mem, mono_time1, rng, new_dht(log1, mem, rng, ns, mono_time1, new_networking(log1, mem, ns, &ip, 36567), true, false));
|
Networking_Core *net1 = new_networking(log1, mem, ns, &ip, 36567);
|
||||||
Onion *onion2 = new_onion(log2, mem, mono_time2, rng, new_dht(log2, mem, rng, ns, mono_time2, new_networking(log2, mem, ns, &ip, 36568), true, false));
|
Onion *onion1 = new_onion(log1, mem, mono_time1, rng, new_dht(log1, mem, rng, ns, mono_time1, net1, true, false), net1);
|
||||||
|
Networking_Core *net2 = new_networking(log2, mem, ns, &ip, 36568);
|
||||||
|
Onion *onion2 = new_onion(log2, mem, mono_time2, rng, new_dht(log2, mem, rng, ns, mono_time2, net2, true, false), net2);
|
||||||
ck_assert_msg((onion1 != nullptr) && (onion2 != nullptr), "Onion failed initializing.");
|
ck_assert_msg((onion1 != nullptr) && (onion2 != nullptr), "Onion failed initializing.");
|
||||||
networking_registerhandler(onion2->net, NET_PACKET_ANNOUNCE_REQUEST, &handle_test_1, onion2);
|
networking_registerhandler(onion2->net, NET_PACKET_ANNOUNCE_REQUEST, &handle_test_1, onion2);
|
||||||
|
|
||||||
@@ -281,8 +285,8 @@ static void test_basic(void)
|
|||||||
do_onion(mono_time2, onion2);
|
do_onion(mono_time2, onion2);
|
||||||
} while (handled_test_2 == 0);
|
} while (handled_test_2 == 0);
|
||||||
|
|
||||||
Onion_Announce *onion1_a = new_onion_announce(log1, mem, rng, mono_time1, onion1->dht);
|
Onion_Announce *onion1_a = new_onion_announce(log1, mem, rng, mono_time1, onion1->dht, onion1->net);
|
||||||
Onion_Announce *onion2_a = new_onion_announce(log2, mem, rng, mono_time2, onion2->dht);
|
Onion_Announce *onion2_a = new_onion_announce(log2, mem, rng, mono_time2, onion2->dht, onion2->net);
|
||||||
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_3, onion1);
|
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_3, onion1);
|
||||||
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_3_old, onion1);
|
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_3_old, onion1);
|
||||||
ck_assert_msg((onion1_a != nullptr) && (onion2_a != nullptr), "Onion_Announce failed initializing.");
|
ck_assert_msg((onion1_a != nullptr) && (onion2_a != nullptr), "Onion_Announce failed initializing.");
|
||||||
@@ -334,7 +338,8 @@ static void test_basic(void)
|
|||||||
|
|
||||||
Mono_Time *mono_time3 = mono_time_new(mem, nullptr, nullptr);
|
Mono_Time *mono_time3 = mono_time_new(mem, nullptr, nullptr);
|
||||||
|
|
||||||
Onion *onion3 = new_onion(log3, mem, mono_time3, rng, new_dht(log3, mem, rng, ns, mono_time3, new_networking(log3, mem, ns, &ip, 36569), true, false));
|
Networking_Core *net3 = new_networking(log3, mem, ns, &ip, 36569);
|
||||||
|
Onion *onion3 = new_onion(log3, mem, mono_time3, rng, new_dht(log3, mem, rng, ns, mono_time3, net3, true, false), net3);
|
||||||
ck_assert_msg((onion3 != nullptr), "Onion failed initializing.");
|
ck_assert_msg((onion3 != nullptr), "Onion failed initializing.");
|
||||||
|
|
||||||
random_nonce(rng, nonce);
|
random_nonce(rng, nonce);
|
||||||
@@ -359,7 +364,7 @@ static void test_basic(void)
|
|||||||
{
|
{
|
||||||
Onion *onion = onion3;
|
Onion *onion = onion3;
|
||||||
|
|
||||||
Networking_Core *net = dht_get_net(onion->dht);
|
Networking_Core *net = onion->net;
|
||||||
DHT *dht = onion->dht;
|
DHT *dht = onion->dht;
|
||||||
kill_onion(onion);
|
kill_onion(onion);
|
||||||
kill_dht(dht);
|
kill_dht(dht);
|
||||||
@@ -371,7 +376,7 @@ static void test_basic(void)
|
|||||||
{
|
{
|
||||||
Onion *onion = onion2;
|
Onion *onion = onion2;
|
||||||
|
|
||||||
Networking_Core *net = dht_get_net(onion->dht);
|
Networking_Core *net = onion->net;
|
||||||
DHT *dht = onion->dht;
|
DHT *dht = onion->dht;
|
||||||
kill_onion(onion);
|
kill_onion(onion);
|
||||||
kill_dht(dht);
|
kill_dht(dht);
|
||||||
@@ -383,7 +388,7 @@ static void test_basic(void)
|
|||||||
{
|
{
|
||||||
Onion *onion = onion1;
|
Onion *onion = onion1;
|
||||||
|
|
||||||
Networking_Core *net = dht_get_net(onion->dht);
|
Networking_Core *net = onion->net;
|
||||||
DHT *dht = onion->dht;
|
DHT *dht = onion->dht;
|
||||||
kill_onion(onion);
|
kill_onion(onion);
|
||||||
kill_dht(dht);
|
kill_dht(dht);
|
||||||
@@ -396,6 +401,7 @@ static void test_basic(void)
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
Logger *log;
|
Logger *log;
|
||||||
Mono_Time *mono_time;
|
Mono_Time *mono_time;
|
||||||
|
Net_Crypto *nc;
|
||||||
Net_Profile *tcp_np;
|
Net_Profile *tcp_np;
|
||||||
Onion *onion;
|
Onion *onion;
|
||||||
Onion_Announce *onion_a;
|
Onion_Announce *onion_a;
|
||||||
@@ -449,7 +455,7 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
on->onion = new_onion(on->log, mem, on->mono_time, rng, dht);
|
on->onion = new_onion(on->log, mem, on->mono_time, rng, dht, net);
|
||||||
|
|
||||||
if (!on->onion) {
|
if (!on->onion) {
|
||||||
kill_dht(dht);
|
kill_dht(dht);
|
||||||
@@ -460,7 +466,7 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
on->onion_a = new_onion_announce(on->log, mem, rng, on->mono_time, dht);
|
on->onion_a = new_onion_announce(on->log, mem, rng, on->mono_time, dht, net);
|
||||||
|
|
||||||
if (!on->onion_a) {
|
if (!on->onion_a) {
|
||||||
kill_onion(on->onion);
|
kill_onion(on->onion);
|
||||||
@@ -486,7 +492,8 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
TCP_Proxy_Info inf = {{{{0}}}};
|
TCP_Proxy_Info inf = {{{{0}}}};
|
||||||
on->onion_c = new_onion_client(on->log, mem, rng, on->mono_time, new_net_crypto(on->log, mem, rng, ns, on->mono_time, dht, &inf, on->tcp_np));
|
on->nc = new_net_crypto(on->log, mem, rng, ns, on->mono_time, net, dht, &inf, on->tcp_np);
|
||||||
|
on->onion_c = new_onion_client(on->log, mem, rng, on->mono_time, on->nc, dht, net);
|
||||||
|
|
||||||
if (!on->onion_c) {
|
if (!on->onion_c) {
|
||||||
netprof_kill(mem, on->tcp_np);
|
netprof_kill(mem, on->tcp_np);
|
||||||
@@ -514,9 +521,9 @@ static void do_onions(Onions *on)
|
|||||||
|
|
||||||
static void kill_onions(const Memory *mem, Onions *on)
|
static void kill_onions(const Memory *mem, Onions *on)
|
||||||
{
|
{
|
||||||
Networking_Core *net = dht_get_net(on->onion->dht);
|
Networking_Core *net = on->onion->net;
|
||||||
DHT *dht = on->onion->dht;
|
DHT *dht = on->onion->dht;
|
||||||
Net_Crypto *c = onion_get_net_crypto(on->onion_c);
|
Net_Crypto *c = on->nc;
|
||||||
kill_onion_client(on->onion_c);
|
kill_onion_client(on->onion_c);
|
||||||
kill_onion_announce(on->onion_a);
|
kill_onion_announce(on->onion_a);
|
||||||
kill_onion(on->onion);
|
kill_onion(on->onion);
|
||||||
@@ -640,9 +647,9 @@ static void test_announce(void)
|
|||||||
|
|
||||||
printf("adding friend\n");
|
printf("adding friend\n");
|
||||||
int frnum_f = onion_addfriend(onions[NUM_FIRST]->onion_c,
|
int frnum_f = onion_addfriend(onions[NUM_FIRST]->onion_c,
|
||||||
nc_get_self_public_key(onion_get_net_crypto(onions[NUM_LAST]->onion_c)));
|
nc_get_self_public_key(onions[NUM_LAST]->nc));
|
||||||
int frnum = onion_addfriend(onions[NUM_LAST]->onion_c,
|
int frnum = onion_addfriend(onions[NUM_LAST]->onion_c,
|
||||||
nc_get_self_public_key(onion_get_net_crypto(onions[NUM_FIRST]->onion_c)));
|
nc_get_self_public_key(onions[NUM_FIRST]->nc));
|
||||||
|
|
||||||
onion_dht_pk_callback(onions[NUM_FIRST]->onion_c, frnum_f, &dht_pk_callback, onions[NUM_FIRST], NUM_FIRST);
|
onion_dht_pk_callback(onions[NUM_FIRST]->onion_c, frnum_f, &dht_pk_callback, onions[NUM_FIRST], NUM_FIRST);
|
||||||
onion_dht_pk_callback(onions[NUM_LAST]->onion_c, frnum, &dht_pk_callback, onions[NUM_LAST], NUM_LAST);
|
onion_dht_pk_callback(onions[NUM_LAST]->onion_c, frnum, &dht_pk_callback, onions[NUM_LAST], NUM_LAST);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static void net_crypto_overflow_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(err == TOX_ERR_FRIEND_SEND_MESSAGE_OK,
|
ck_assert_msg(err == TOX_ERR_FRIEND_SEND_MESSAGE_OK,
|
||||||
"tox%u failed to send message number %u: %d", tox_index, i, err);
|
"tox%u failed to send message number %u: %u", tox_index, i, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ static void net_crypto_overflow_test(AutoTox *autotoxes)
|
|||||||
// As soon as we get the first error, we expect the same error (SENDQ)
|
// As soon as we get the first error, we expect the same error (SENDQ)
|
||||||
// every time we try to send.
|
// every time we try to send.
|
||||||
ck_assert_msg(err == TOX_ERR_FRIEND_SEND_MESSAGE_SENDQ,
|
ck_assert_msg(err == TOX_ERR_FRIEND_SEND_MESSAGE_SENDQ,
|
||||||
"expected SENDQ error on message %u, but got %d", i, err);
|
"expected SENDQ error on message %u, but got %u", i, err);
|
||||||
} else {
|
} else {
|
||||||
ck_assert_msg(err == TOX_ERR_FRIEND_SEND_MESSAGE_OK,
|
ck_assert_msg(err == TOX_ERR_FRIEND_SEND_MESSAGE_OK,
|
||||||
"failed to send message number %u: %d", i, err);
|
"failed to send message number %u: %u", i, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)
|
|||||||
tox_self_get_connection_status(tox2) != TOX_CONNECTION_NONE &&
|
tox_self_get_connection_status(tox2) != TOX_CONNECTION_NONE &&
|
||||||
tox_self_get_connection_status(tox3) != TOX_CONNECTION_NONE &&
|
tox_self_get_connection_status(tox3) != TOX_CONNECTION_NONE &&
|
||||||
tox_self_get_connection_status(tox4) != TOX_CONNECTION_NONE) {
|
tox_self_get_connection_status(tox4) != TOX_CONNECTION_NONE) {
|
||||||
printf("%d %d %d %d\n",
|
printf("%u %u %u %u\n",
|
||||||
tox_self_get_connection_status(tox1),
|
tox_self_get_connection_status(tox1),
|
||||||
tox_self_get_connection_status(tox2),
|
tox_self_get_connection_status(tox2),
|
||||||
tox_self_get_connection_status(tox3),
|
tox_self_get_connection_status(tox3),
|
||||||
@@ -37,7 +37,7 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)
|
|||||||
tox_iterate(tox4, nullptr);
|
tox_iterate(tox4, nullptr);
|
||||||
|
|
||||||
if (i % 10 == 0) {
|
if (i % 10 == 0) {
|
||||||
printf("%d %d %d %d\n",
|
printf("%u %u %u %u\n",
|
||||||
tox_self_get_connection_status(tox1),
|
tox_self_get_connection_status(tox1),
|
||||||
tox_self_get_connection_status(tox2),
|
tox_self_get_connection_status(tox2),
|
||||||
tox_self_get_connection_status(tox3),
|
tox_self_get_connection_status(tox3),
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
#include "../testing/misc_tools.h"
|
||||||
#include "../toxcore/friend_connection.h"
|
#include "../toxcore/friend_connection.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxcore/util.h"
|
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
#define TOX_COUNT 2
|
#define TOX_COUNT 2
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ static void test_save_compatibility(const char *save_path)
|
|||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
Tox_Err_New err;
|
Tox_Err_New err;
|
||||||
Tox *tox = tox_new_log(options, &err, &index);
|
Tox *tox = tox_new_log(options, &err, &index);
|
||||||
ck_assert_msg(tox, "failed to create tox, error number: %d", err);
|
ck_assert_msg(tox, "failed to create tox, error number: %u", err);
|
||||||
|
|
||||||
tox_options_free(options);
|
tox_options_free(options);
|
||||||
free(save_data);
|
free(save_data);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "../testing/misc_tools.h"
|
#include "../testing/misc_tools.h"
|
||||||
#include "../toxcore/ccompat.h"
|
#include "../toxcore/ccompat.h"
|
||||||
#include "../toxcore/crypto_core.h"
|
#include "../toxcore/crypto_core.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ static void tox_connection_status(const Tox_Event_Self_Connection_Status *event,
|
|||||||
ck_abort_msg("Tox went offline");
|
ck_abort_msg("Tox went offline");
|
||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(connection_status != TOX_CONNECTION_NONE, "wrong status %d", connection_status);
|
ck_assert_msg(connection_status != TOX_CONNECTION_NONE, "wrong status %u", connection_status);
|
||||||
|
|
||||||
connected_t1 = connection_status;
|
connected_t1 = connection_status;
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ static void test_few_clients(void)
|
|||||||
tox_options_set_tcp_port(opts1, TCP_RELAY_PORT);
|
tox_options_set_tcp_port(opts1, TCP_RELAY_PORT);
|
||||||
Tox_Err_New t_n_error;
|
Tox_Err_New t_n_error;
|
||||||
Tox *tox1 = tox_new_log(opts1, &t_n_error, &index[0]);
|
Tox *tox1 = tox_new_log(opts1, &t_n_error, &index[0]);
|
||||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %u", t_n_error);
|
||||||
tox_options_free(opts1);
|
tox_options_free(opts1);
|
||||||
tox_events_init(tox1);
|
tox_events_init(tox1);
|
||||||
Tox_Dispatch *dispatch1 = tox_dispatch_new(nullptr);
|
Tox_Dispatch *dispatch1 = tox_dispatch_new(nullptr);
|
||||||
@@ -164,7 +164,7 @@ static void test_few_clients(void)
|
|||||||
tox_options_set_udp_enabled(opts2, false);
|
tox_options_set_udp_enabled(opts2, false);
|
||||||
tox_options_set_local_discovery_enabled(opts2, false);
|
tox_options_set_local_discovery_enabled(opts2, false);
|
||||||
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
|
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
|
||||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %u", t_n_error);
|
||||||
tox_events_init(tox2);
|
tox_events_init(tox2);
|
||||||
Tox_Dispatch *dispatch2 = tox_dispatch_new(nullptr);
|
Tox_Dispatch *dispatch2 = tox_dispatch_new(nullptr);
|
||||||
ck_assert(dispatch2 != nullptr);
|
ck_assert(dispatch2 != nullptr);
|
||||||
@@ -173,7 +173,7 @@ static void test_few_clients(void)
|
|||||||
tox_options_set_ipv6_enabled(opts3, USE_IPV6);
|
tox_options_set_ipv6_enabled(opts3, USE_IPV6);
|
||||||
tox_options_set_local_discovery_enabled(opts3, false);
|
tox_options_set_local_discovery_enabled(opts3, false);
|
||||||
Tox *tox3 = tox_new_log(opts3, &t_n_error, &index[2]);
|
Tox *tox3 = tox_new_log(opts3, &t_n_error, &index[2]);
|
||||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %u", t_n_error);
|
||||||
|
|
||||||
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
|
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ static void send_message_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
Tox_Err_Friend_Send_Message errm;
|
Tox_Err_Friend_Send_Message errm;
|
||||||
tox_friend_send_message(autotoxes[0].tox, 0, TOX_MESSAGE_TYPE_NORMAL, msgs, msgs_len, &errm);
|
tox_friend_send_message(autotoxes[0].tox, 0, TOX_MESSAGE_TYPE_NORMAL, msgs, msgs_len, &errm);
|
||||||
ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG, "tox_max_message_length() is too small? error=%d", errm);
|
ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG, "tox_max_message_length() is too small? error=%u", errm);
|
||||||
|
|
||||||
tox_friend_send_message(autotoxes[0].tox, 0, TOX_MESSAGE_TYPE_NORMAL, msgs, tox_max_message_length(), &errm);
|
tox_friend_send_message(autotoxes[0].tox, 0, TOX_MESSAGE_TYPE_NORMAL, msgs, tox_max_message_length(), &errm);
|
||||||
ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_OK, "tox_max_message_length() is too big? error=%d", errm);
|
ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_OK, "tox_max_message_length() is too big? error=%u", errm);
|
||||||
|
|
||||||
free(msgs);
|
free(msgs);
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ static void test_set_name(void)
|
|||||||
tox_events_callback_friend_name(dispatch2, nickchange_callback);
|
tox_events_callback_friend_name(dispatch2, nickchange_callback);
|
||||||
Tox_Err_Set_Info err_n;
|
Tox_Err_Set_Info err_n;
|
||||||
bool ret = tox_self_set_name(tox1, (const uint8_t *)NICKNAME, sizeof(NICKNAME), &err_n);
|
bool ret = tox_self_set_name(tox1, (const uint8_t *)NICKNAME, sizeof(NICKNAME), &err_n);
|
||||||
ck_assert_msg(ret && err_n == TOX_ERR_SET_INFO_OK, "tox_self_set_name failed because %d\n", err_n);
|
ck_assert_msg(ret && err_n == TOX_ERR_SET_INFO_OK, "tox_self_set_name failed because %u\n", err_n);
|
||||||
|
|
||||||
bool nickname_updated = false;
|
bool nickname_updated = false;
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ static void test_set_status_message(void)
|
|||||||
Tox_Err_Set_Info err_n;
|
Tox_Err_Set_Info err_n;
|
||||||
bool ret = tox_self_set_status_message(tox1, (const uint8_t *)STATUS_MESSAGE, sizeof(STATUS_MESSAGE),
|
bool ret = tox_self_set_status_message(tox1, (const uint8_t *)STATUS_MESSAGE, sizeof(STATUS_MESSAGE),
|
||||||
&err_n);
|
&err_n);
|
||||||
ck_assert_msg(ret && err_n == TOX_ERR_SET_INFO_OK, "tox_self_set_status_message failed because %d\n", err_n);
|
ck_assert_msg(ret && err_n == TOX_ERR_SET_INFO_OK, "tox_self_set_status_message failed because %u\n", err_n);
|
||||||
|
|
||||||
bool status_updated = false;
|
bool status_updated = false;
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ int main(void)
|
|||||||
|
|
||||||
const Tox_Connection status = tox_self_get_connection_status(tox_tcp);
|
const Tox_Connection status = tox_self_get_connection_status(tox_tcp);
|
||||||
ck_assert_msg(status == TOX_CONNECTION_TCP,
|
ck_assert_msg(status == TOX_CONNECTION_TCP,
|
||||||
"expected TCP connection, but got %d", status);
|
"expected TCP connection, but got %u", status);
|
||||||
printf("Connection (TCP): %d\n", status);
|
printf("Connection (TCP): %u\n", status);
|
||||||
|
|
||||||
tox_kill(tox_tcp);
|
tox_kill(tox_tcp);
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
#include "../testing/misc_tools.h"
|
||||||
#include "../toxcore/crypto_core.h"
|
#include "../toxcore/crypto_core.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxcore/util.h"
|
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ static void test_many_clients_tcp(void)
|
|||||||
uint8_t dpk[TOX_PUBLIC_KEY_SIZE];
|
uint8_t dpk[TOX_PUBLIC_KEY_SIZE];
|
||||||
tox_self_get_dht_id(toxes[0], dpk);
|
tox_self_get_dht_id(toxes[0], dpk);
|
||||||
Tox_Err_Bootstrap error;
|
Tox_Err_Bootstrap error;
|
||||||
ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, tcp_relay_port, dpk, &error), "add relay error, %u, %d", i,
|
ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, tcp_relay_port, dpk, &error), "add relay error, %u, %u", i,
|
||||||
error);
|
error);
|
||||||
uint16_t first_port = tox_self_get_udp_port(toxes[0], nullptr);
|
uint16_t first_port = tox_self_get_udp_port(toxes[0], nullptr);
|
||||||
ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, first_port, dpk, nullptr), "Bootstrap error");
|
ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, first_port, dpk, nullptr), "Bootstrap error");
|
||||||
@@ -128,7 +127,7 @@ loop_top:
|
|||||||
goto loop_top;
|
goto loop_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend error code: %i", test);
|
ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend error code: %u", test);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -233,7 +232,7 @@ loop_top:
|
|||||||
goto loop_top;
|
goto loop_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend error code: %i", test);
|
ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend error code: %u", test);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t last_count = 0;
|
uint16_t last_count = 0;
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
#include "../testing/misc_tools.h"
|
||||||
#include "../toxcore/crypto_core.h"
|
#include "../toxcore/crypto_core.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxcore/util.h"
|
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ loop_top:
|
|||||||
|
|
||||||
tox_bootstrap(toxes[pairs[i].tox2], "localhost", dht_port, dht_key, nullptr);
|
tox_bootstrap(toxes[pairs[i].tox2], "localhost", dht_port, dht_key, nullptr);
|
||||||
|
|
||||||
ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "failed to add friend error code: %i", test);
|
ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "failed to add friend error code: %u", test);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) {
|
for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
Toxav_Err_Call_Control cc_err; \
|
Toxav_Err_Call_Control cc_err; \
|
||||||
bool ok = toxav_call_control(a, b, c, &cc_err); \
|
bool ok = toxav_call_control(a, b, c, &cc_err); \
|
||||||
if (!ok) { \
|
if (!ok) { \
|
||||||
printf("toxav_call_control returned error %d\n", cc_err); \
|
printf("toxav_call_control returned error %u\n", cc_err); \
|
||||||
} \
|
} \
|
||||||
ck_assert(ok); \
|
ck_assert(ok); \
|
||||||
ck_assert(cc_err == TOXAV_ERR_CALL_CONTROL_OK); \
|
ck_assert(cc_err == TOXAV_ERR_CALL_CONTROL_OK); \
|
||||||
@@ -115,7 +115,7 @@ static void regular_call_flow(
|
|||||||
Toxav_Err_Call call_err;
|
Toxav_Err_Call call_err;
|
||||||
toxav_call(alice_av, 0, a_br, v_br, &call_err);
|
toxav_call(alice_av, 0, a_br, v_br, &call_err);
|
||||||
|
|
||||||
ck_assert_msg(call_err == TOXAV_ERR_CALL_OK, "toxav_call failed: %d\n", call_err);
|
ck_assert_msg(call_err == TOXAV_ERR_CALL_OK, "toxav_call failed: %u\n", call_err);
|
||||||
|
|
||||||
const time_t start_time = time(nullptr);
|
const time_t start_time = time(nullptr);
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ static void regular_call_flow(
|
|||||||
Toxav_Err_Answer answer_err;
|
Toxav_Err_Answer answer_err;
|
||||||
toxav_answer(bob_av, 0, a_br, v_br, &answer_err);
|
toxav_answer(bob_av, 0, a_br, v_br, &answer_err);
|
||||||
|
|
||||||
ck_assert_msg(answer_err == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %d\n", answer_err);
|
ck_assert_msg(answer_err == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %u\n", answer_err);
|
||||||
|
|
||||||
bob_cc->incoming = false;
|
bob_cc->incoming = false;
|
||||||
} else { /* TODO(mannol): rtp */
|
} else { /* TODO(mannol): rtp */
|
||||||
@@ -133,7 +133,7 @@ static void regular_call_flow(
|
|||||||
Toxav_Err_Call_Control cc_err;
|
Toxav_Err_Call_Control cc_err;
|
||||||
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &cc_err);
|
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &cc_err);
|
||||||
|
|
||||||
ck_assert_msg(cc_err == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %d\n", cc_err);
|
ck_assert_msg(cc_err == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %u\n", cc_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call rc;
|
Toxav_Err_Call rc;
|
||||||
toxav_call(alice_av, 0, 48, 0, &rc);
|
toxav_call(alice_av, 0, 48, 0, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -265,7 +265,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call_Control rc;
|
Toxav_Err_Call_Control rc;
|
||||||
toxav_call_control(bob_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
toxav_call_control(bob_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -285,7 +285,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call rc;
|
Toxav_Err_Call rc;
|
||||||
toxav_call(alice_av, 0, 48, 0, &rc);
|
toxav_call(alice_av, 0, 48, 0, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -297,7 +297,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call_Control rc;
|
Toxav_Err_Call_Control rc;
|
||||||
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Alice will not receive end state */
|
/* Alice will not receive end state */
|
||||||
@@ -319,7 +319,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call rc;
|
Toxav_Err_Call rc;
|
||||||
toxav_call(alice_av, 0, 48, 1000, &rc);
|
toxav_call(alice_av, 0, 48, 1000, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -338,7 +338,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Answer rc;
|
Toxav_Err_Answer rc;
|
||||||
toxav_answer(bob_av, 0, 48, 4000, &rc);
|
toxav_answer(bob_av, 0, 48, 4000, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_tox(bootstrap, alice, bob);
|
iterate_tox(bootstrap, alice, bob);
|
||||||
@@ -380,7 +380,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call_Control rc;
|
Toxav_Err_Call_Control rc;
|
||||||
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_tox(bootstrap, alice, bob);
|
iterate_tox(bootstrap, alice, bob);
|
||||||
@@ -400,7 +400,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call rc;
|
Toxav_Err_Call rc;
|
||||||
toxav_call(alice_av, 0, 48, 0, &rc);
|
toxav_call(alice_av, 0, 48, 0, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -411,7 +411,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Answer rc;
|
Toxav_Err_Answer rc;
|
||||||
toxav_answer(bob_av, 0, 48, 0, &rc);
|
toxav_answer(bob_av, 0, 48, 0, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_tox(bootstrap, alice, bob);
|
iterate_tox(bootstrap, alice, bob);
|
||||||
@@ -439,7 +439,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call_Control rc;
|
Toxav_Err_Call_Control rc;
|
||||||
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_tox(bootstrap, alice, bob);
|
iterate_tox(bootstrap, alice, bob);
|
||||||
@@ -459,7 +459,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call rc;
|
Toxav_Err_Call rc;
|
||||||
toxav_call(alice_av, 0, 48, 0, &rc);
|
toxav_call(alice_av, 0, 48, 0, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_OK, "toxav_call failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -470,7 +470,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Answer rc;
|
Toxav_Err_Answer rc;
|
||||||
toxav_answer(bob_av, 0, 48, 0, &rc);
|
toxav_answer(bob_av, 0, 48, 0, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_ANSWER_OK, "toxav_answer failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_tox(bootstrap, alice, bob);
|
iterate_tox(bootstrap, alice, bob);
|
||||||
@@ -488,7 +488,7 @@ static void test_av_flows(void)
|
|||||||
Toxav_Err_Call_Control rc;
|
Toxav_Err_Call_Control rc;
|
||||||
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
toxav_call_control(alice_av, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
||||||
|
|
||||||
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %d\n", rc);
|
ck_assert_msg(rc == TOXAV_ERR_CALL_CONTROL_OK, "toxav_call_control failed: %u\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_tox(bootstrap, alice, bob);
|
iterate_tox(bootstrap, alice, bob);
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ static void test_av_three_calls(void)
|
|||||||
toxav_call(alice_av, tds[i].friend_number, 48, 3000, &rc);
|
toxav_call(alice_av, tds[i].friend_number, 48, 3000, &rc);
|
||||||
|
|
||||||
if (rc != TOXAV_ERR_CALL_OK) {
|
if (rc != TOXAV_ERR_CALL_OK) {
|
||||||
printf("toxav_call failed: %d\n", rc);
|
printf("toxav_call failed: %u\n", rc);
|
||||||
ck_assert(0);
|
ck_assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ static void test_av_three_calls(void)
|
|||||||
toxav_answer(bobs_av[i], 0, 8, 500, &rc);
|
toxav_answer(bobs_av[i], 0, 8, 500, &rc);
|
||||||
|
|
||||||
if (rc != TOXAV_ERR_ANSWER_OK) {
|
if (rc != TOXAV_ERR_ANSWER_OK) {
|
||||||
printf("toxav_answer failed: %d\n", rc);
|
printf("toxav_answer failed: %u\n", rc);
|
||||||
ck_assert(0);
|
ck_assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +334,7 @@ static void test_av_three_calls(void)
|
|||||||
toxav_call_control(alice_av, i, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
toxav_call_control(alice_av, i, TOXAV_CALL_CONTROL_CANCEL, &rc);
|
||||||
|
|
||||||
if (rc != TOXAV_ERR_CALL_CONTROL_OK) {
|
if (rc != TOXAV_ERR_CALL_CONTROL_OK) {
|
||||||
printf("toxav_call_control failed: %d %p %p\n", rc, (void *)alice_av, (void *)&bobs_av[i]);
|
printf("toxav_call_control failed: %u %p %p\n", rc, (void *)alice_av, (void *)&bobs_av[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
external/toxcore/c-toxcore/other/DHT_bootstrap.c
vendored
19
external/toxcore/c-toxcore/other/DHT_bootstrap.c
vendored
@@ -26,6 +26,8 @@
|
|||||||
#include "../toxcore/network.h"
|
#include "../toxcore/network.h"
|
||||||
#include "../toxcore/onion.h"
|
#include "../toxcore/onion.h"
|
||||||
#include "../toxcore/onion_announce.h"
|
#include "../toxcore/onion_announce.h"
|
||||||
|
#include "../toxcore/os_memory.h"
|
||||||
|
#include "../toxcore/os_random.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
|
|
||||||
#define TCP_RELAY_ENABLED
|
#define TCP_RELAY_ENABLED
|
||||||
@@ -157,14 +159,15 @@ int main(int argc, char *argv[])
|
|||||||
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||||
const uint16_t start_port = PORT;
|
const uint16_t start_port = PORT;
|
||||||
const uint16_t end_port = start_port + (TOX_PORTRANGE_TO - TOX_PORTRANGE_FROM);
|
const uint16_t end_port = start_port + (TOX_PORTRANGE_TO - TOX_PORTRANGE_FROM);
|
||||||
DHT *dht = new_dht(logger, mem, rng, ns, mono_time, new_networking_ex(logger, mem, ns, &ip, start_port, end_port, nullptr), true, true);
|
Networking_Core *net = new_networking_ex(logger, mem, ns, &ip, start_port, end_port, nullptr);
|
||||||
Onion *onion = new_onion(logger, mem, mono_time, rng, dht);
|
DHT *dht = new_dht(logger, mem, rng, ns, mono_time, net, true, true);
|
||||||
Forwarding *forwarding = new_forwarding(logger, mem, rng, mono_time, dht);
|
Onion *onion = new_onion(logger, mem, mono_time, rng, dht, net);
|
||||||
|
Forwarding *forwarding = new_forwarding(logger, mem, rng, mono_time, dht, net);
|
||||||
GC_Announces_List *gc_announces_list = new_gca_list(mem);
|
GC_Announces_List *gc_announces_list = new_gca_list(mem);
|
||||||
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht);
|
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht, net);
|
||||||
|
|
||||||
#ifdef DHT_NODE_EXTRA_PACKETS
|
#ifdef DHT_NODE_EXTRA_PACKETS
|
||||||
bootstrap_set_callbacks(dht_get_net(dht), (uint32_t)DAEMON_VERSION_NUMBER, (const uint8_t *) motd_str, strlen(motd_str) + 1);
|
bootstrap_set_callbacks(net, (uint32_t)DAEMON_VERSION_NUMBER, (const uint8_t *) motd_str, strlen(motd_str) + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (onion == nullptr || forwarding == nullptr || onion_a == nullptr) {
|
if (onion == nullptr || forwarding == nullptr || onion_a == nullptr) {
|
||||||
@@ -214,7 +217,7 @@ int main(int argc, char *argv[])
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Port: %u\n", net_ntohs(net_port(dht_get_net(dht))));
|
printf("Port: %u\n", net_ntohs(net_port(net)));
|
||||||
|
|
||||||
if (argc > argvoffset + 3) {
|
if (argc > argvoffset + 3) {
|
||||||
printf("Trying to bootstrap into the network...\n");
|
printf("Trying to bootstrap into the network...\n");
|
||||||
@@ -258,7 +261,7 @@ int main(int argc, char *argv[])
|
|||||||
do_dht(dht);
|
do_dht(dht);
|
||||||
|
|
||||||
if (mono_time_is_timeout(mono_time, last_lan_discovery, is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL)) {
|
if (mono_time_is_timeout(mono_time, last_lan_discovery, is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL)) {
|
||||||
lan_discovery_send(dht_get_net(dht), broadcast, dht_get_self_public_key(dht), net_htons(PORT));
|
lan_discovery_send(net, broadcast, dht_get_self_public_key(dht), net_htons(PORT));
|
||||||
last_lan_discovery = mono_time_get(mono_time);
|
last_lan_discovery = mono_time_get(mono_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +270,7 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef TCP_RELAY_ENABLED
|
#ifdef TCP_RELAY_ENABLED
|
||||||
do_tcp_server(tcp_s, mono_time);
|
do_tcp_server(tcp_s, mono_time);
|
||||||
#endif
|
#endif
|
||||||
networking_poll(dht_get_net(dht), nullptr);
|
networking_poll(net, nullptr);
|
||||||
|
|
||||||
c_sleep(1);
|
c_sleep(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,15 +25,18 @@ run() {
|
|||||||
-Wno-missing-braces \
|
-Wno-missing-braces \
|
||||||
-Wno-missing-field-initializers \
|
-Wno-missing-field-initializers \
|
||||||
-Wno-missing-noreturn \
|
-Wno-missing-noreturn \
|
||||||
|
-Wno-nullability-completeness \
|
||||||
|
-Wno-nullability-extension \
|
||||||
|
-Wno-nullable-to-nonnull-conversion \
|
||||||
-Wno-old-style-cast \
|
-Wno-old-style-cast \
|
||||||
-Wno-padded \
|
-Wno-padded \
|
||||||
|
-Wno-source-uses-openmp \
|
||||||
-Wno-switch-default \
|
-Wno-switch-default \
|
||||||
-Wno-tautological-pointer-compare \
|
-Wno-tautological-pointer-compare \
|
||||||
-Wno-unreachable-code-return \
|
-Wno-unreachable-code-return \
|
||||||
-Wno-unsafe-buffer-usage \
|
-Wno-unsafe-buffer-usage \
|
||||||
-Wno-unused-parameter \
|
-Wno-unused-parameter \
|
||||||
-Wno-used-but-marked-unused \
|
-Wno-used-but-marked-unused
|
||||||
-Wno-source-uses-openmp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
. other/analysis/variants.sh
|
. other/analysis/variants.sh
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ ERRORS="*"
|
|||||||
# Still good to occasionally look at.
|
# Still good to occasionally look at.
|
||||||
ERRORS="$ERRORS,-google-readability-casting"
|
ERRORS="$ERRORS,-google-readability-casting"
|
||||||
|
|
||||||
|
# TODO(iphydf): Fix these.
|
||||||
|
CHECKS="$CHECKS,-clang-analyzer-nullability.NullableDereferenced"
|
||||||
|
CHECKS="$CHECKS,-clang-analyzer-nullability.NullablePassedToNonnull"
|
||||||
|
CHECKS="$CHECKS,-clang-analyzer-nullability.NullPassedToNonnull"
|
||||||
|
|
||||||
# Need to investigate or disable and document these.
|
# Need to investigate or disable and document these.
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,20 @@ CPPCHECK+=("--check-level=exhaustive")
|
|||||||
CPPCHECK+=("--inline-suppr")
|
CPPCHECK+=("--inline-suppr")
|
||||||
CPPCHECK+=("--library=other/docker/cppcheck/toxcore.cfg")
|
CPPCHECK+=("--library=other/docker/cppcheck/toxcore.cfg")
|
||||||
CPPCHECK+=("--error-exitcode=1")
|
CPPCHECK+=("--error-exitcode=1")
|
||||||
|
# Some files don't match all our suppressions below.
|
||||||
|
CPPCHECK+=("--suppress=unmatchedSuppression")
|
||||||
# We don't cast function pointers, which cppcheck suggests here.
|
# We don't cast function pointers, which cppcheck suggests here.
|
||||||
CPPCHECK+=("--suppress=constParameterCallback")
|
CPPCHECK+=("--suppress=constParameterCallback")
|
||||||
|
# This disagrees with clang's warnings.
|
||||||
|
CPPCHECK+=("--suppress=invalidPrintfArgType_uint")
|
||||||
# False positives in switch statements.
|
# False positives in switch statements.
|
||||||
CPPCHECK+=("--suppress=knownConditionTrueFalse")
|
CPPCHECK+=("--suppress=knownConditionTrueFalse")
|
||||||
# Cppcheck does not need standard library headers to get proper results.
|
# Cppcheck does not need standard library headers to get proper results.
|
||||||
CPPCHECK+=("--suppress=missingIncludeSystem")
|
CPPCHECK+=("--suppress=missingIncludeSystem")
|
||||||
# TODO(iphydf): Maybe fix?
|
# TODO(iphydf): Maybe fix?
|
||||||
CPPCHECK+=("--suppress=signConversion")
|
CPPCHECK+=("--suppress=signConversion")
|
||||||
|
# We have suppressions in the code for the misra extension.
|
||||||
|
CPPCHECK+=("--suppress=unmatchedSuppression")
|
||||||
|
|
||||||
# We use this for VLAs.
|
# We use this for VLAs.
|
||||||
CPPCHECK_CXX+=("--suppress=allocaCalled")
|
CPPCHECK_CXX+=("--suppress=allocaCalled")
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ cc_binary(
|
|||||||
"//c-toxcore/toxcore:network",
|
"//c-toxcore/toxcore:network",
|
||||||
"//c-toxcore/toxcore:onion",
|
"//c-toxcore/toxcore:onion",
|
||||||
"//c-toxcore/toxcore:onion_announce",
|
"//c-toxcore/toxcore:onion_announce",
|
||||||
|
"//c-toxcore/toxcore:os_random",
|
||||||
"//c-toxcore/toxcore:tox",
|
"//c-toxcore/toxcore:tox",
|
||||||
"@libconfig",
|
"@libconfig",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
###########################################################
|
###########################################################
|
||||||
# Builder image: we compile the code here (static build)
|
# Builder image: we compile the code here (static build)
|
||||||
FROM alpine:3.19.0 AS build
|
FROM alpine:3.21.0 AS build
|
||||||
|
|
||||||
RUN ["apk", "--no-cache", "add",\
|
RUN ["apk", "--no-cache", "add",\
|
||||||
"clang",\
|
"clang",\
|
||||||
@@ -26,33 +26,32 @@ COPY other/bootstrap_node_packets.[ch] other/
|
|||||||
COPY other/DHT_bootstrap.c other/
|
COPY other/DHT_bootstrap.c other/
|
||||||
COPY other/pkgconfig other/pkgconfig
|
COPY other/pkgconfig other/pkgconfig
|
||||||
COPY other/rpm other/rpm
|
COPY other/rpm other/rpm
|
||||||
COPY testing/misc_tools.[ch] testing/
|
COPY testing testing
|
||||||
COPY toxcore toxcore
|
COPY toxcore toxcore
|
||||||
COPY toxencryptsave toxencryptsave
|
COPY toxencryptsave toxencryptsave
|
||||||
COPY third_party third_party
|
COPY third_party third_party
|
||||||
COPY CMakeLists.txt so.version ./
|
COPY CMakeLists.txt so.version ./
|
||||||
COPY other/bootstrap_daemon/CMakeLists.txt other/bootstrap_daemon/CMakeLists.txt
|
COPY other/bootstrap_daemon/CMakeLists.txt other/bootstrap_daemon/CMakeLists.txt
|
||||||
COPY testing/CMakeLists.txt testing/CMakeLists.txt
|
|
||||||
|
|
||||||
RUN CC=clang cmake -B_build -H. \
|
RUN CC=clang cmake -B_build -H. \
|
||||||
-GNinja \
|
-GNinja \
|
||||||
-DCMAKE_C_FLAGS="-DTCP_SERVER_USE_EPOLL -fsanitize=alignment,return,returns-nonnull-attribute,vla-bound,unreachable,float-cast-overflow,null -fsanitize-trap=all -fstack-protector-all" \
|
-DCMAKE_C_FLAGS="-DTCP_SERVER_USE_EPOLL -fsanitize=alignment,return,returns-nonnull-attribute,vla-bound,unreachable,float-cast-overflow,null -fsanitize-trap=all -fstack-protector-all" \
|
||||||
-DCMAKE_UNITY_BUILD=ON \
|
-DCMAKE_UNITY_BUILD=ON \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DFULLY_STATIC=ON \
|
-DFULLY_STATIC=ON \
|
||||||
-DMIN_LOGGER_LEVEL=DEBUG \
|
-DMIN_LOGGER_LEVEL=TRACE \
|
||||||
-DBUILD_TOXAV=OFF \
|
-DBUILD_TOXAV=OFF \
|
||||||
-DBOOTSTRAP_DAEMON=ON && \
|
-DBOOTSTRAP_DAEMON=ON \
|
||||||
cmake --build _build --target install
|
&& cmake --build _build --target install
|
||||||
|
|
||||||
# Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't
|
# Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't
|
||||||
# mess with your binaries.
|
# mess with your binaries.
|
||||||
COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/
|
COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/
|
||||||
ARG CHECK=sha256sum
|
ARG CHECK=sha256sum
|
||||||
RUN SHA256="$("$CHECK" /usr/local/bin/tox-bootstrapd)" && \
|
RUN SHA256="$("$CHECK" /usr/local/bin/tox-bootstrapd)" \
|
||||||
("$CHECK" -c other/bootstrap_daemon/docker/tox-bootstrapd.sha256 || \
|
&& ("$CHECK" -c other/bootstrap_daemon/docker/tox-bootstrapd.sha256 || \
|
||||||
(echo "::error file=other/bootstrap_daemon/docker/tox-bootstrapd.sha256,line=1::$SHA256" && \
|
(echo "::error file=other/bootstrap_daemon/docker/tox-bootstrapd.sha256,line=1::$SHA256" \
|
||||||
false))
|
&& false))
|
||||||
|
|
||||||
# Remove all the example bootstrap nodes from the config file.
|
# Remove all the example bootstrap nodes from the config file.
|
||||||
COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/
|
COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/
|
||||||
@@ -69,12 +68,14 @@ FROM debian:bookworm-slim
|
|||||||
|
|
||||||
COPY --from=build /usr/local/bin/tox-bootstrapd /usr/local/bin/
|
COPY --from=build /usr/local/bin/tox-bootstrapd /usr/local/bin/
|
||||||
COPY --from=build /src/c-toxcore/other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
COPY --from=build /src/c-toxcore/other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||||
RUN useradd --home-dir /var/lib/tox-bootstrapd --create-home \
|
RUN useradd \
|
||||||
--system --shell /sbin/nologin \
|
--home-dir /var/lib/tox-bootstrapd \
|
||||||
--comment "Account to run the Tox DHT bootstrap daemon" \
|
--create-home \
|
||||||
--user-group tox-bootstrapd && \
|
--system --shell /sbin/nologin \
|
||||||
chmod 644 /etc/tox-bootstrapd.conf && \
|
--comment "Account to run the Tox DHT bootstrap daemon" \
|
||||||
chmod 700 /var/lib/tox-bootstrapd
|
--user-group tox-bootstrapd \
|
||||||
|
&& chmod 644 /etc/tox-bootstrapd.conf \
|
||||||
|
&& chmod 700 /var/lib/tox-bootstrapd
|
||||||
|
|
||||||
WORKDIR /var/lib/tox-bootstrapd
|
WORKDIR /var/lib/tox-bootstrapd
|
||||||
|
|
||||||
|
|||||||
22
external/toxcore/c-toxcore/other/bootstrap_daemon/docker/Dockerfile.dockerignore
vendored
Normal file
22
external/toxcore/c-toxcore/other/bootstrap_daemon/docker/Dockerfile.dockerignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Very selectively add files to the image, because we may have random stuff
|
||||||
|
# lying around. In particular, we don't need to rebuild the docker image when
|
||||||
|
# toxav changes or the Dockerfile changes down from the build.
|
||||||
|
**/*
|
||||||
|
!cmake/*
|
||||||
|
!other/bootstrap_daemon/bash-completion/*
|
||||||
|
!other/bootstrap_daemon/docker/get-nodes.py
|
||||||
|
!other/bootstrap_daemon/docker/tox-bootstrapd.sha256
|
||||||
|
!other/bootstrap_daemon/src/*
|
||||||
|
!other/bootstrap_daemon/tox-bootstrapd.conf
|
||||||
|
!other/bootstrap_node_packets.[ch]
|
||||||
|
!other/DHT_bootstrap.c
|
||||||
|
!other/pkgconfig/*
|
||||||
|
!other/rpm/*
|
||||||
|
!testing/misc_tools.[ch]
|
||||||
|
!toxcore/**/*
|
||||||
|
!toxencryptsave/**/*
|
||||||
|
!third_party/cmp/cmp.[ch]
|
||||||
|
!CMakeLists.txt
|
||||||
|
!so.version
|
||||||
|
!other/bootstrap_daemon/CMakeLists.txt
|
||||||
|
!testing/CMakeLists.txt
|
||||||
12
external/toxcore/c-toxcore/other/bootstrap_daemon/docker/build.sh
vendored
Executable file
12
external/toxcore/c-toxcore/other/bootstrap_daemon/docker/build.sh
vendored
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
|
||||||
|
GIT_ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
cd "$GIT_ROOT"
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
-t toxchat/bootstrap-node \
|
||||||
|
-f other/bootstrap_daemon/docker/Dockerfile \
|
||||||
|
--build-arg CHECK=true \
|
||||||
|
.
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "command_line_arguments.h"
|
#include "command_line_arguments.h"
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h" // IWYU pragma: keep
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include "../../../toxcore/ccompat.h"
|
#include "../../../toxcore/ccompat.h"
|
||||||
@@ -26,7 +26,7 @@ static void print_help(void)
|
|||||||
// 2 space indent
|
// 2 space indent
|
||||||
// Make sure all lines fit into 80 columns
|
// Make sure all lines fit into 80 columns
|
||||||
// Make sure options are listed in alphabetical order
|
// Make sure options are listed in alphabetical order
|
||||||
log_write(LOG_LEVEL_INFO,
|
LOG_WRITE(LOG_LEVEL_INFO,
|
||||||
"Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n"
|
"Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
@@ -43,6 +43,7 @@ static void print_help(void)
|
|||||||
" Default option when no --log-backend is\n"
|
" Default option when no --log-backend is\n"
|
||||||
" specified.\n"
|
" specified.\n"
|
||||||
" stdout Writes log messages to stdout/stderr.\n"
|
" stdout Writes log messages to stdout/stderr.\n"
|
||||||
|
" --trace Enable verbose network trace logging in toxcore.\n"
|
||||||
" --version Print version information.\n");
|
" --version Print version information.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ Cli_Status handle_command_line_arguments(
|
|||||||
bool *run_in_foreground)
|
bool *run_in_foreground)
|
||||||
{
|
{
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n");
|
||||||
print_help();
|
print_help();
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@@ -64,6 +65,7 @@ Cli_Status handle_command_line_arguments(
|
|||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"log-backend", required_argument, nullptr, 'l'}, // optional, defaults to syslog
|
{"log-backend", required_argument, nullptr, 'l'}, // optional, defaults to syslog
|
||||||
{"version", no_argument, nullptr, 'v'},
|
{"version", no_argument, nullptr, 'v'},
|
||||||
|
{"trace", no_argument, nullptr, 't'},
|
||||||
{nullptr, 0, nullptr, 0 }
|
{nullptr, 0, nullptr, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ Cli_Status handle_command_line_arguments(
|
|||||||
*log_backend = LOG_BACKEND_STDOUT;
|
*log_backend = LOG_BACKEND_STDOUT;
|
||||||
log_backend_set = true;
|
log_backend_set = true;
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg);
|
||||||
print_help();
|
print_help();
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@@ -107,16 +109,21 @@ Cli_Status handle_command_line_arguments(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
log_write(LOG_LEVEL_INFO, "Version: %lu\n", DAEMON_VERSION_NUMBER);
|
LOG_WRITE(LOG_LEVEL_INFO, "Version: %lu\n", DAEMON_VERSION_NUMBER);
|
||||||
return CLI_STATUS_DONE;
|
return CLI_STATUS_DONE;
|
||||||
|
|
||||||
|
case 't':
|
||||||
|
LOG_WRITE(LOG_LEVEL_INFO, "Enabling trace logging in toxcore.\n");
|
||||||
|
log_enable_trace(true);
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: Unrecognized option %s\n\n", argv[optind - 1]);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Error: Unrecognized option %s\n\n", argv[optind - 1]);
|
||||||
print_help();
|
print_help();
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: No argument provided for option %s\n\n", argv[optind - 1]);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Error: No argument provided for option %s\n\n", argv[optind - 1]);
|
||||||
print_help();
|
print_help();
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@@ -127,7 +134,7 @@ Cli_Status handle_command_line_arguments(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!cfg_file_path_set) {
|
if (!cfg_file_path_set) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: The required --config option wasn't specified\n\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Error: The required --config option wasn't specified\n\n");
|
||||||
print_help();
|
print_help();
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
config_setting_t *ports_array = config_lookup(cfg, NAME_TCP_RELAY_PORTS);
|
config_setting_t *ports_array = config_lookup(cfg, NAME_TCP_RELAY_PORTS);
|
||||||
|
|
||||||
if (ports_array == nullptr) {
|
if (ports_array == nullptr) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file.\n", NAME_TCP_RELAY_PORTS);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file.\n", NAME_TCP_RELAY_PORTS);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s':\n", NAME_TCP_RELAY_PORTS);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s':\n", NAME_TCP_RELAY_PORTS);
|
||||||
|
|
||||||
const uint16_t default_ports[] = {DEFAULT_TCP_RELAY_PORTS};
|
const uint16_t default_ports[] = {DEFAULT_TCP_RELAY_PORTS};
|
||||||
|
|
||||||
@@ -53,13 +53,13 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
const size_t default_ports_count = sizeof(default_ports) / sizeof(*default_ports);
|
const size_t default_ports_count = sizeof(default_ports) / sizeof(*default_ports);
|
||||||
|
|
||||||
for (size_t i = 0; i < default_ports_count; ++i) {
|
for (size_t i = 0; i < default_ports_count; ++i) {
|
||||||
log_write(LOG_LEVEL_INFO, "Port #%zu: %u\n", i, default_ports[i]);
|
LOG_WRITE(LOG_LEVEL_INFO, "Port #%zu: %u\n", i, default_ports[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar procedure to the one of reading config file below
|
// Similar procedure to the one of reading config file below
|
||||||
*tcp_relay_ports = (uint16_t *)malloc(default_ports_count * sizeof(uint16_t));
|
*tcp_relay_ports = (uint16_t *)malloc(default_ports_count * sizeof(uint16_t));
|
||||||
if (*tcp_relay_ports == nullptr) {
|
if (*tcp_relay_ports == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
|
|
||||||
if ((*tcp_relay_ports)[*tcp_relay_port_count] < MIN_ALLOWED_PORT
|
if ((*tcp_relay_ports)[*tcp_relay_port_count] < MIN_ALLOWED_PORT
|
||||||
|| (*tcp_relay_ports)[*tcp_relay_port_count] > MAX_ALLOWED_PORT) {
|
|| (*tcp_relay_ports)[*tcp_relay_port_count] > MAX_ALLOWED_PORT) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Port #%zu: Invalid port: %u, should be in [%d, %d]. Skipping.\n", i,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Port #%zu: Invalid port: %u, should be in [%d, %d]. Skipping.\n", i,
|
||||||
(*tcp_relay_ports)[*tcp_relay_port_count], MIN_ALLOWED_PORT, MAX_ALLOWED_PORT);
|
(*tcp_relay_ports)[*tcp_relay_port_count], MIN_ALLOWED_PORT, MAX_ALLOWED_PORT);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config_setting_is_array(ports_array) == CONFIG_FALSE) {
|
if (config_setting_is_array(ports_array) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_ERROR, "'%s' setting should be an array. Array syntax: 'setting = [value1, value2, ...]'.\n",
|
LOG_WRITE(LOG_LEVEL_ERROR, "'%s' setting should be an array. Array syntax: 'setting = [value1, value2, ...]'.\n",
|
||||||
NAME_TCP_RELAY_PORTS);
|
NAME_TCP_RELAY_PORTS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -95,13 +95,13 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
const int config_port_count = config_setting_length(ports_array);
|
const int config_port_count = config_setting_length(ports_array);
|
||||||
|
|
||||||
if (config_port_count == 0) {
|
if (config_port_count == 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "'%s' is empty.\n", NAME_TCP_RELAY_PORTS);
|
LOG_WRITE(LOG_LEVEL_ERROR, "'%s' is empty.\n", NAME_TCP_RELAY_PORTS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*tcp_relay_ports = (uint16_t *)malloc(config_port_count * sizeof(uint16_t));
|
*tcp_relay_ports = (uint16_t *)malloc(config_port_count * sizeof(uint16_t));
|
||||||
if (*tcp_relay_ports == nullptr) {
|
if (*tcp_relay_ports == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,12 +110,12 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
|
|
||||||
if (elem == nullptr) {
|
if (elem == nullptr) {
|
||||||
// It's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be
|
// It's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be
|
||||||
log_write(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_setting_is_number(elem) == CONFIG_FALSE) {
|
if (config_setting_is_number(elem) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Port #%d: Not a number. Skipping.\n", i);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Port #%d: Not a number. Skipping.\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
|
|
||||||
if ((*tcp_relay_ports)[*tcp_relay_port_count] < MIN_ALLOWED_PORT
|
if ((*tcp_relay_ports)[*tcp_relay_port_count] < MIN_ALLOWED_PORT
|
||||||
|| (*tcp_relay_ports)[*tcp_relay_port_count] > MAX_ALLOWED_PORT) {
|
|| (*tcp_relay_ports)[*tcp_relay_port_count] > MAX_ALLOWED_PORT) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Port #%d: Invalid port: %u, should be in [%d, %d]. Skipping.\n", i,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Port #%d: Invalid port: %u, should be in [%d, %d]. Skipping.\n", i,
|
||||||
(*tcp_relay_ports)[*tcp_relay_port_count], MIN_ALLOWED_PORT, MAX_ALLOWED_PORT);
|
(*tcp_relay_ports)[*tcp_relay_port_count], MIN_ALLOWED_PORT, MAX_ALLOWED_PORT);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -169,15 +169,15 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
|
|||||||
|
|
||||||
// Read the file. If there is an error, report it and exit.
|
// Read the file. If there is an error, report it and exit.
|
||||||
if (config_read_file(&cfg, cfg_file_path) == CONFIG_FALSE) {
|
if (config_read_file(&cfg, cfg_file_path) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_ERROR, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
|
LOG_WRITE(LOG_LEVEL_ERROR, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get port
|
// Get port
|
||||||
if (config_lookup_int(&cfg, NAME_PORT, port) == CONFIG_FALSE) {
|
if (config_lookup_int(&cfg, NAME_PORT, port) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_PORT);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_PORT);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %d\n", NAME_PORT, DEFAULT_PORT);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %d\n", NAME_PORT, DEFAULT_PORT);
|
||||||
*port = DEFAULT_PORT;
|
*port = DEFAULT_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,15 +185,15 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
|
|||||||
const char *tmp_pid_file;
|
const char *tmp_pid_file;
|
||||||
|
|
||||||
if (config_lookup_string(&cfg, NAME_PID_FILE_PATH, &tmp_pid_file) == CONFIG_FALSE) {
|
if (config_lookup_string(&cfg, NAME_PID_FILE_PATH, &tmp_pid_file) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_PID_FILE_PATH);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_PID_FILE_PATH);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_PID_FILE_PATH, DEFAULT_PID_FILE_PATH);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_PID_FILE_PATH, DEFAULT_PID_FILE_PATH);
|
||||||
tmp_pid_file = DEFAULT_PID_FILE_PATH;
|
tmp_pid_file = DEFAULT_PID_FILE_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t pid_file_path_len = strlen(tmp_pid_file) + 1;
|
const size_t pid_file_path_len = strlen(tmp_pid_file) + 1;
|
||||||
*pid_file_path = (char *)malloc(pid_file_path_len);
|
*pid_file_path = (char *)malloc(pid_file_path_len);
|
||||||
if (*pid_file_path == nullptr) {
|
if (*pid_file_path == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
memcpy(*pid_file_path, tmp_pid_file, pid_file_path_len);
|
memcpy(*pid_file_path, tmp_pid_file, pid_file_path_len);
|
||||||
@@ -202,15 +202,15 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
|
|||||||
const char *tmp_keys_file;
|
const char *tmp_keys_file;
|
||||||
|
|
||||||
if (config_lookup_string(&cfg, NAME_KEYS_FILE_PATH, &tmp_keys_file) == CONFIG_FALSE) {
|
if (config_lookup_string(&cfg, NAME_KEYS_FILE_PATH, &tmp_keys_file) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_KEYS_FILE_PATH);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_KEYS_FILE_PATH);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_KEYS_FILE_PATH, DEFAULT_KEYS_FILE_PATH);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_KEYS_FILE_PATH, DEFAULT_KEYS_FILE_PATH);
|
||||||
tmp_keys_file = DEFAULT_KEYS_FILE_PATH;
|
tmp_keys_file = DEFAULT_KEYS_FILE_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t keys_file_path_len = strlen(tmp_keys_file) + 1;
|
const size_t keys_file_path_len = strlen(tmp_keys_file) + 1;
|
||||||
*keys_file_path = (char *)malloc(keys_file_path_len);
|
*keys_file_path = (char *)malloc(keys_file_path_len);
|
||||||
if (*keys_file_path == nullptr) {
|
if (*keys_file_path == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
||||||
free(*pid_file_path);
|
free(*pid_file_path);
|
||||||
*pid_file_path = nullptr;
|
*pid_file_path = nullptr;
|
||||||
return false;
|
return false;
|
||||||
@@ -219,31 +219,31 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
|
|||||||
|
|
||||||
// Get IPv6 option
|
// Get IPv6 option
|
||||||
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_IPV6, enable_ipv6) == CONFIG_FALSE) {
|
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_IPV6, enable_ipv6) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_IPV6);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_IPV6);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_IPV6, DEFAULT_ENABLE_IPV6 ? "true" : "false");
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_IPV6, DEFAULT_ENABLE_IPV6 ? "true" : "false");
|
||||||
*enable_ipv6 = DEFAULT_ENABLE_IPV6;
|
*enable_ipv6 = DEFAULT_ENABLE_IPV6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get IPv4 fallback option
|
// Get IPv4 fallback option
|
||||||
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_IPV4_FALLBACK, enable_ipv4_fallback) == CONFIG_FALSE) {
|
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_IPV4_FALLBACK, enable_ipv4_fallback) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_IPV4_FALLBACK);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_IPV4_FALLBACK);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_IPV4_FALLBACK,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_IPV4_FALLBACK,
|
||||||
DEFAULT_ENABLE_IPV4_FALLBACK ? "true" : "false");
|
DEFAULT_ENABLE_IPV4_FALLBACK ? "true" : "false");
|
||||||
*enable_ipv4_fallback = DEFAULT_ENABLE_IPV4_FALLBACK;
|
*enable_ipv4_fallback = DEFAULT_ENABLE_IPV4_FALLBACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get LAN discovery option
|
// Get LAN discovery option
|
||||||
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_LAN_DISCOVERY, enable_lan_discovery) == CONFIG_FALSE) {
|
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_LAN_DISCOVERY, enable_lan_discovery) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_LAN_DISCOVERY);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_LAN_DISCOVERY);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_LAN_DISCOVERY,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_LAN_DISCOVERY,
|
||||||
DEFAULT_ENABLE_LAN_DISCOVERY ? "true" : "false");
|
DEFAULT_ENABLE_LAN_DISCOVERY ? "true" : "false");
|
||||||
*enable_lan_discovery = DEFAULT_ENABLE_LAN_DISCOVERY;
|
*enable_lan_discovery = DEFAULT_ENABLE_LAN_DISCOVERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get TCP relay option
|
// Get TCP relay option
|
||||||
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_TCP_RELAY, enable_tcp_relay) == CONFIG_FALSE) {
|
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_TCP_RELAY, enable_tcp_relay) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_TCP_RELAY);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_TCP_RELAY);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_TCP_RELAY,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_TCP_RELAY,
|
||||||
DEFAULT_ENABLE_TCP_RELAY ? "true" : "false");
|
DEFAULT_ENABLE_TCP_RELAY ? "true" : "false");
|
||||||
*enable_tcp_relay = DEFAULT_ENABLE_TCP_RELAY;
|
*enable_tcp_relay = DEFAULT_ENABLE_TCP_RELAY;
|
||||||
}
|
}
|
||||||
@@ -256,8 +256,8 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
|
|||||||
|
|
||||||
// Get MOTD option
|
// Get MOTD option
|
||||||
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_MOTD, enable_motd) == CONFIG_FALSE) {
|
if (tox_config_lookup_bool(&cfg, NAME_ENABLE_MOTD, enable_motd) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_MOTD);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_MOTD);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_MOTD,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_MOTD,
|
||||||
DEFAULT_ENABLE_MOTD ? "true" : "false");
|
DEFAULT_ENABLE_MOTD ? "true" : "false");
|
||||||
*enable_motd = DEFAULT_ENABLE_MOTD;
|
*enable_motd = DEFAULT_ENABLE_MOTD;
|
||||||
}
|
}
|
||||||
@@ -267,8 +267,8 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
|
|||||||
const char *tmp_motd;
|
const char *tmp_motd;
|
||||||
|
|
||||||
if (config_lookup_string(&cfg, NAME_MOTD, &tmp_motd) == CONFIG_FALSE) {
|
if (config_lookup_string(&cfg, NAME_MOTD, &tmp_motd) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_MOTD);
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_MOTD);
|
||||||
log_write(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_MOTD, DEFAULT_MOTD);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_MOTD, DEFAULT_MOTD);
|
||||||
tmp_motd = DEFAULT_MOTD;
|
tmp_motd = DEFAULT_MOTD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,33 +280,33 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
|
|||||||
|
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
|
|
||||||
log_write(LOG_LEVEL_INFO, "Successfully read:\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "Successfully read:\n");
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_PID_FILE_PATH, *pid_file_path);
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_PID_FILE_PATH, *pid_file_path);
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_KEYS_FILE_PATH, *keys_file_path);
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_KEYS_FILE_PATH, *keys_file_path);
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %d\n", NAME_PORT, *port);
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %d\n", NAME_PORT, *port);
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_IPV6, *enable_ipv6 ? "true" : "false");
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_IPV6, *enable_ipv6 ? "true" : "false");
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_IPV4_FALLBACK, *enable_ipv4_fallback ? "true" : "false");
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_IPV4_FALLBACK, *enable_ipv4_fallback ? "true" : "false");
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_LAN_DISCOVERY, *enable_lan_discovery ? "true" : "false");
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_LAN_DISCOVERY, *enable_lan_discovery ? "true" : "false");
|
||||||
|
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_TCP_RELAY, *enable_tcp_relay ? "true" : "false");
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_TCP_RELAY, *enable_tcp_relay ? "true" : "false");
|
||||||
|
|
||||||
// Show info about tcp ports only if tcp relay is enabled
|
// Show info about tcp ports only if tcp relay is enabled
|
||||||
if (*enable_tcp_relay) {
|
if (*enable_tcp_relay) {
|
||||||
if (*tcp_relay_port_count == 0) {
|
if (*tcp_relay_port_count == 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "No TCP ports could be read.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "No TCP ports could be read.\n");
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_INFO, "Read %d TCP ports:\n", *tcp_relay_port_count);
|
LOG_WRITE(LOG_LEVEL_INFO, "Read %d TCP ports:\n", *tcp_relay_port_count);
|
||||||
|
|
||||||
for (int i = 0; i < *tcp_relay_port_count; ++i) {
|
for (int i = 0; i < *tcp_relay_port_count; ++i) {
|
||||||
log_write(LOG_LEVEL_INFO, "Port #%d: %u\n", i, (*tcp_relay_ports)[i]);
|
LOG_WRITE(LOG_LEVEL_INFO, "Port #%d: %u\n", i, (*tcp_relay_ports)[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_MOTD, *enable_motd ? "true" : "false");
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_MOTD, *enable_motd ? "true" : "false");
|
||||||
|
|
||||||
if (*enable_motd) {
|
if (*enable_motd) {
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_MOTD, *motd);
|
LOG_WRITE(LOG_LEVEL_INFO, "'%s': %s\n", NAME_MOTD, *motd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -330,7 +330,7 @@ static uint8_t *bootstrap_hex_string_to_bin(const char *hex_string)
|
|||||||
const size_t len = strlen(hex_string) / 2;
|
const size_t len = strlen(hex_string) / 2;
|
||||||
uint8_t *ret = (uint8_t *)malloc(len);
|
uint8_t *ret = (uint8_t *)malloc(len);
|
||||||
if (ret == nullptr) {
|
if (ret == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Allocation failure.\n");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ bool bootstrap_from_config(const char *cfg_file_path, DHT *dht, bool enable_ipv6
|
|||||||
config_init(&cfg);
|
config_init(&cfg);
|
||||||
|
|
||||||
if (config_read_file(&cfg, cfg_file_path) == CONFIG_FALSE) {
|
if (config_read_file(&cfg, cfg_file_path) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_ERROR, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
|
LOG_WRITE(LOG_LEVEL_ERROR, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -366,14 +366,14 @@ bool bootstrap_from_config(const char *cfg_file_path, DHT *dht, bool enable_ipv6
|
|||||||
config_setting_t *node_list = config_lookup(&cfg, NAME_BOOTSTRAP_NODES);
|
config_setting_t *node_list = config_lookup(&cfg, NAME_BOOTSTRAP_NODES);
|
||||||
|
|
||||||
if (node_list == nullptr) {
|
if (node_list == nullptr) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n",
|
LOG_WRITE(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n",
|
||||||
NAME_BOOTSTRAP_NODES);
|
NAME_BOOTSTRAP_NODES);
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_setting_length(node_list) == 0) {
|
if (config_setting_length(node_list) == 0) {
|
||||||
log_write(LOG_LEVEL_WARNING, "No bootstrap nodes found. Skipping bootstrapping.\n");
|
LOG_WRITE(LOG_LEVEL_WARNING, "No bootstrap nodes found. Skipping bootstrapping.\n");
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -402,30 +402,30 @@ bool bootstrap_from_config(const char *cfg_file_path, DHT *dht, bool enable_ipv6
|
|||||||
|
|
||||||
// Check that all settings are present
|
// Check that all settings are present
|
||||||
if (config_setting_lookup_string(node, NAME_PUBLIC_KEY, &bs_public_key) == CONFIG_FALSE) {
|
if (config_setting_lookup_string(node, NAME_PUBLIC_KEY, &bs_public_key) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i,
|
||||||
NAME_PUBLIC_KEY);
|
NAME_PUBLIC_KEY);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_setting_lookup_int(node, NAME_PORT, &bs_port) == CONFIG_FALSE) {
|
if (config_setting_lookup_int(node, NAME_PORT, &bs_port) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_PORT);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_PORT);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_setting_lookup_string(node, NAME_ADDRESS, &bs_address) == CONFIG_FALSE) {
|
if (config_setting_lookup_string(node, NAME_ADDRESS, &bs_address) == CONFIG_FALSE) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_ADDRESS);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_ADDRESS);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process settings
|
// Process settings
|
||||||
if (strlen(bs_public_key) != CRYPTO_PUBLIC_KEY_SIZE * 2) {
|
if (strlen(bs_public_key) != CRYPTO_PUBLIC_KEY_SIZE * 2) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_PUBLIC_KEY,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_PUBLIC_KEY,
|
||||||
bs_public_key);
|
bs_public_key);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs_port < MIN_ALLOWED_PORT || bs_port > MAX_ALLOWED_PORT) {
|
if (bs_port < MIN_ALLOWED_PORT || bs_port > MAX_ALLOWED_PORT) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %d, should be in [%d, %d]. Skipping the node.\n", i,
|
LOG_WRITE(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %d, should be in [%d, %d]. Skipping the node.\n", i,
|
||||||
NAME_PORT,
|
NAME_PORT,
|
||||||
bs_port, MIN_ALLOWED_PORT, MAX_ALLOWED_PORT);
|
bs_port, MIN_ALLOWED_PORT, MAX_ALLOWED_PORT);
|
||||||
goto next;
|
goto next;
|
||||||
@@ -437,11 +437,11 @@ bool bootstrap_from_config(const char *cfg_file_path, DHT *dht, bool enable_ipv6
|
|||||||
free(bs_public_key_bin);
|
free(bs_public_key_bin);
|
||||||
|
|
||||||
if (!address_resolved) {
|
if (!address_resolved) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_ADDRESS, bs_address);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_ADDRESS, bs_address);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_write(LOG_LEVEL_INFO, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key);
|
LOG_WRITE(LOG_LEVEL_INFO, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key);
|
||||||
|
|
||||||
next:
|
next:
|
||||||
// config_setting_lookup_string() allocates string inside and doesn't allow us to free it directly
|
// config_setting_lookup_string() allocates string inside and doesn't allow us to free it directly
|
||||||
|
|||||||
@@ -15,6 +15,12 @@
|
|||||||
|
|
||||||
#define INVALID_BACKEND ((LOG_BACKEND)-1u)
|
#define INVALID_BACKEND ((LOG_BACKEND)-1u)
|
||||||
static LOG_BACKEND current_backend = INVALID_BACKEND;
|
static LOG_BACKEND current_backend = INVALID_BACKEND;
|
||||||
|
static bool log_toxcore_trace = false;
|
||||||
|
|
||||||
|
void log_enable_trace(bool enable)
|
||||||
|
{
|
||||||
|
log_toxcore_trace = enable;
|
||||||
|
}
|
||||||
|
|
||||||
bool log_open(LOG_BACKEND backend)
|
bool log_open(LOG_BACKEND backend)
|
||||||
{
|
{
|
||||||
@@ -58,22 +64,27 @@ bool log_close(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool log_write(LOG_LEVEL level, const char *format, ...)
|
bool log_write(LOG_LEVEL level, const char *category, const char *file, int line, const char *format, ...)
|
||||||
{
|
{
|
||||||
if (current_backend == INVALID_BACKEND) {
|
if (current_backend == INVALID_BACKEND) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (level == LOG_LEVEL_TRACE && !log_toxcore_trace) {
|
||||||
|
// By default, no trace logging.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
||||||
switch (current_backend) {
|
switch (current_backend) {
|
||||||
case LOG_BACKEND_STDOUT:
|
case LOG_BACKEND_STDOUT:
|
||||||
log_backend_stdout_write(level, format, args);
|
log_backend_stdout_write(level, category, file, line, format, args);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOG_BACKEND_SYSLOG:
|
case LOG_BACKEND_SYSLOG:
|
||||||
log_backend_syslog_write(level, format, args);
|
log_backend_syslog_write(level, category, file, line, format, args);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,18 @@ typedef enum LOG_BACKEND {
|
|||||||
} LOG_BACKEND;
|
} LOG_BACKEND;
|
||||||
|
|
||||||
typedef enum LOG_LEVEL {
|
typedef enum LOG_LEVEL {
|
||||||
|
LOG_LEVEL_TRACE,
|
||||||
LOG_LEVEL_INFO,
|
LOG_LEVEL_INFO,
|
||||||
LOG_LEVEL_WARNING,
|
LOG_LEVEL_WARNING,
|
||||||
LOG_LEVEL_ERROR
|
LOG_LEVEL_ERROR
|
||||||
} LOG_LEVEL;
|
} LOG_LEVEL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables logging of trace messages from toxcore.
|
||||||
|
* @param enable true to enable, false to disable.
|
||||||
|
*/
|
||||||
|
void log_enable_trace(bool enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes logger.
|
* Initializes logger.
|
||||||
* @param backend Specifies which backend to use.
|
* @param backend Specifies which backend to use.
|
||||||
@@ -45,6 +52,13 @@ bool log_close(void);
|
|||||||
* @param ... Zero or more arguments, similar to printf function.
|
* @param ... Zero or more arguments, similar to printf function.
|
||||||
* @return true on success, false if log is closed.
|
* @return true on success, false if log is closed.
|
||||||
*/
|
*/
|
||||||
bool log_write(LOG_LEVEL level, const char *format, ...) GNU_PRINTF(2, 3);
|
bool log_write(LOG_LEVEL level, const char *category, const char *file, int line, const char *format, ...) GNU_PRINTF(5, 6);
|
||||||
|
|
||||||
|
enum {
|
||||||
|
LOG_PATH_PREFIX = sizeof(__FILE__) - sizeof("log.h")
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LOG_WRITEC(level, category, ...) log_write(level, category, &__FILE__[LOG_PATH_PREFIX], __LINE__, __VA_ARGS__)
|
||||||
|
#define LOG_WRITE(level, ...) LOG_WRITEC(level, "tox.bootstrap", __VA_ARGS__)
|
||||||
|
|
||||||
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_H
|
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_H
|
||||||
|
|||||||
@@ -11,12 +11,15 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../../../toxcore/ccompat.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static FILE *log_backend_stdout_level(LOG_LEVEL level)
|
static FILE *log_backend_stdout_level(LOG_LEVEL level)
|
||||||
{
|
{
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
case LOG_LEVEL_TRACE: // intentional fallthrough
|
||||||
case LOG_LEVEL_INFO:
|
case LOG_LEVEL_INFO:
|
||||||
return stdout;
|
return stdout;
|
||||||
|
|
||||||
@@ -28,8 +31,36 @@ static FILE *log_backend_stdout_level(LOG_LEVEL level)
|
|||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_backend_stdout_write(LOG_LEVEL level, const char *format, va_list args)
|
static const char *log_level_string(LOG_LEVEL level)
|
||||||
{
|
{
|
||||||
vfprintf(log_backend_stdout_level(level), format, args);
|
switch (level) {
|
||||||
fflush(log_backend_stdout_level(level));
|
case LOG_LEVEL_TRACE:
|
||||||
|
return "Debug";
|
||||||
|
|
||||||
|
case LOG_LEVEL_INFO:
|
||||||
|
return "Info";
|
||||||
|
|
||||||
|
case LOG_LEVEL_WARNING:
|
||||||
|
return "Warning";
|
||||||
|
|
||||||
|
case LOG_LEVEL_ERROR:
|
||||||
|
return "Critical"; // Qt-compatible.
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Debug"; // Just in case. Shouldn't happen.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output bootstrap node log messages in the standard Tox log format:
|
||||||
|
// [15:02:46.433 UTC] (tox.bootstrap) config.c:444 : Info: Successfully added bootstrap node ...
|
||||||
|
void log_backend_stdout_write(LOG_LEVEL level, const char *category, const char *file, int line, const char *format, va_list args)
|
||||||
|
{
|
||||||
|
struct timeval tv = {0};
|
||||||
|
gettimeofday(&tv, nullptr);
|
||||||
|
|
||||||
|
FILE *stream = log_backend_stdout_level(level);
|
||||||
|
fprintf(stream, "[%02d:%02d:%02d.%03d UTC] (%s) %s:%d : %s: ",
|
||||||
|
(int)(tv.tv_sec / 3600 % 24), (int)(tv.tv_sec / 60 % 60), (int)(tv.tv_sec % 60), (int)(tv.tv_usec / 1000),
|
||||||
|
category, file, line, log_level_string(level));
|
||||||
|
vfprintf(stream, format, args);
|
||||||
|
fflush(stream);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,6 @@
|
|||||||
#include "../../../toxcore/attributes.h"
|
#include "../../../toxcore/attributes.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
void log_backend_stdout_write(LOG_LEVEL level, const char *format, va_list args) GNU_PRINTF(2, 0);
|
void log_backend_stdout_write(LOG_LEVEL level, const char *category, const char *file, int line, const char *format, va_list args) GNU_PRINTF(5, 0);
|
||||||
|
|
||||||
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_STDOUT_H
|
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_STDOUT_H
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ void log_backend_syslog_close(void)
|
|||||||
static int log_backend_syslog_level(LOG_LEVEL level)
|
static int log_backend_syslog_level(LOG_LEVEL level)
|
||||||
{
|
{
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
case LOG_LEVEL_TRACE:
|
||||||
|
return LOG_DEBUG;
|
||||||
|
|
||||||
case LOG_LEVEL_INFO:
|
case LOG_LEVEL_INFO:
|
||||||
return LOG_INFO;
|
return LOG_INFO;
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ static int log_backend_syslog_level(LOG_LEVEL level)
|
|||||||
return LOG_INFO;
|
return LOG_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args)
|
void log_backend_syslog_write(LOG_LEVEL level, const char *category, const char *file, int line, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
va_list args2;
|
va_list args2;
|
||||||
|
|
||||||
@@ -66,6 +69,6 @@ void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args)
|
|||||||
}
|
}
|
||||||
vsnprintf(buf, size + 1, format, args);
|
vsnprintf(buf, size + 1, format, args);
|
||||||
|
|
||||||
syslog(log_backend_syslog_level(level), "%s", buf);
|
syslog(log_backend_syslog_level(level), "(%s) %s", category, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,6 @@
|
|||||||
|
|
||||||
void log_backend_syslog_open(void);
|
void log_backend_syslog_open(void);
|
||||||
void log_backend_syslog_close(void);
|
void log_backend_syslog_close(void);
|
||||||
void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args) GNU_PRINTF(2, 0);
|
void log_backend_syslog_write(LOG_LEVEL level, const char *category, const char *file, int line, const char *format, va_list args) GNU_PRINTF(5, 0);
|
||||||
|
|
||||||
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_SYSLOG_H
|
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_SYSLOG_H
|
||||||
|
|||||||
@@ -36,11 +36,12 @@
|
|||||||
#include "../../../toxcore/group_announce.h"
|
#include "../../../toxcore/group_announce.h"
|
||||||
#include "../../../toxcore/group_onion_announce.h"
|
#include "../../../toxcore/group_onion_announce.h"
|
||||||
#include "../../../toxcore/logger.h"
|
#include "../../../toxcore/logger.h"
|
||||||
#include "../../../toxcore/mem.h"
|
|
||||||
#include "../../../toxcore/mono_time.h"
|
#include "../../../toxcore/mono_time.h"
|
||||||
#include "../../../toxcore/network.h"
|
#include "../../../toxcore/network.h"
|
||||||
#include "../../../toxcore/onion.h"
|
#include "../../../toxcore/onion.h"
|
||||||
#include "../../../toxcore/onion_announce.h"
|
#include "../../../toxcore/onion_announce.h"
|
||||||
|
#include "../../../toxcore/os_memory.h"
|
||||||
|
#include "../../../toxcore/os_random.h"
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
#include "../../bootstrap_node_packets.h"
|
#include "../../bootstrap_node_packets.h"
|
||||||
@@ -116,7 +117,7 @@ static void print_public_key(const uint8_t *public_key)
|
|||||||
index += snprintf(buffer + index, sizeof(buffer) - index, "%02X", public_key[i]);
|
index += snprintf(buffer + index, sizeof(buffer) - index, "%02X", public_key[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_write(LOG_LEVEL_INFO, "Public Key: %s\n", buffer);
|
LOG_WRITE(LOG_LEVEL_INFO, "Public Key: %s\n", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Demonizes the process, appending PID to the PID file and closing file descriptors based on log backend
|
// Demonizes the process, appending PID to the PID file and closing file descriptors based on log backend
|
||||||
@@ -128,7 +129,7 @@ static Cli_Status daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
|||||||
FILE *pid_file = fopen(pid_file_path, "r");
|
FILE *pid_file = fopen(pid_file_path, "r");
|
||||||
|
|
||||||
if (pid_file != nullptr) {
|
if (pid_file != nullptr) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Another instance of the daemon is already running, PID file %s exists.\n", pid_file_path);
|
LOG_WRITE(LOG_LEVEL_WARNING, "Another instance of the daemon is already running, PID file %s exists.\n", pid_file_path);
|
||||||
fclose(pid_file);
|
fclose(pid_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ static Cli_Status daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
|||||||
pid_file = fopen(pid_file_path, "a+");
|
pid_file = fopen(pid_file_path, "a+");
|
||||||
|
|
||||||
if (pid_file == nullptr) {
|
if (pid_file == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path);
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,26 +147,26 @@ static Cli_Status daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
|||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
fprintf(pid_file, "%d", pid);
|
fprintf(pid_file, "%d", pid);
|
||||||
fclose(pid_file);
|
fclose(pid_file);
|
||||||
log_write(LOG_LEVEL_INFO, "Forked successfully: PID: %d.\n", pid);
|
LOG_WRITE(LOG_LEVEL_INFO, "Forked successfully: PID: %d.\n", pid);
|
||||||
return CLI_STATUS_DONE;
|
return CLI_STATUS_DONE;
|
||||||
} else {
|
} else {
|
||||||
fclose(pid_file);
|
fclose(pid_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Forking failed. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Forking failed. Exiting.\n");
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new SID for the child process
|
// Create a new SID for the child process
|
||||||
if (setsid() < 0) {
|
if (setsid() < 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "SID creation failure. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "SID creation failure. Exiting.\n");
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the current working directory
|
// Change the current working directory
|
||||||
if ((chdir("/")) < 0) {
|
if ((chdir("/")) < 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n");
|
||||||
return CLI_STATUS_ERROR;
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +186,8 @@ static LOG_LEVEL logger_level_to_log_level(Logger_Level level)
|
|||||||
{
|
{
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LOGGER_LEVEL_TRACE:
|
case LOGGER_LEVEL_TRACE:
|
||||||
|
return LOG_LEVEL_TRACE;
|
||||||
|
|
||||||
case LOGGER_LEVEL_DEBUG:
|
case LOGGER_LEVEL_DEBUG:
|
||||||
case LOGGER_LEVEL_INFO:
|
case LOGGER_LEVEL_INFO:
|
||||||
return LOG_LEVEL_INFO;
|
return LOG_LEVEL_INFO;
|
||||||
@@ -203,7 +206,11 @@ static LOG_LEVEL logger_level_to_log_level(Logger_Level level)
|
|||||||
static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, uint32_t line,
|
static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, uint32_t line,
|
||||||
const char *func, const char *message, void *userdata)
|
const char *func, const char *message, void *userdata)
|
||||||
{
|
{
|
||||||
log_write(logger_level_to_log_level(level), "%s:%u(%s) %s\n", file, line, func, message);
|
const char *category = "tox.core";
|
||||||
|
if (level == LOGGER_LEVEL_TRACE) {
|
||||||
|
category = "tox.trace";
|
||||||
|
}
|
||||||
|
log_write(logger_level_to_log_level(level), category, file, line, "%s\n", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile sig_atomic_t caught_signal = 0;
|
static volatile sig_atomic_t caught_signal = 0;
|
||||||
@@ -235,7 +242,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
log_open(log_backend);
|
log_open(log_backend);
|
||||||
|
|
||||||
log_write(LOG_LEVEL_INFO, "Running \"%s\" version %lu.\n", DAEMON_NAME, DAEMON_VERSION_NUMBER);
|
LOG_WRITE(LOG_LEVEL_INFO, "Running \"%s\" version %lu.\n", DAEMON_NAME, DAEMON_VERSION_NUMBER);
|
||||||
|
|
||||||
char *pid_file_path = nullptr;
|
char *pid_file_path = nullptr;
|
||||||
char *keys_file_path = nullptr;
|
char *keys_file_path = nullptr;
|
||||||
@@ -251,14 +258,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (get_general_config(cfg_file_path, &pid_file_path, &keys_file_path, &start_port, &enable_ipv6, &enable_ipv4_fallback,
|
if (get_general_config(cfg_file_path, &pid_file_path, &keys_file_path, &start_port, &enable_ipv6, &enable_ipv4_fallback,
|
||||||
&enable_lan_discovery, &enable_tcp_relay, &tcp_relay_ports, &tcp_relay_port_count, &enable_motd, &motd)) {
|
&enable_lan_discovery, &enable_tcp_relay, &tcp_relay_ports, &tcp_relay_port_count, &enable_motd, &motd)) {
|
||||||
log_write(LOG_LEVEL_INFO, "General config read successfully\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "General config read successfully\n");
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't read config file: %s. Exiting.\n", cfg_file_path);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't read config file: %s. Exiting.\n", cfg_file_path);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_port < MIN_ALLOWED_PORT || start_port > MAX_ALLOWED_PORT) {
|
if (start_port < MIN_ALLOWED_PORT || start_port > MAX_ALLOWED_PORT) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Invalid port: %d, should be in [%d, %d]. Exiting.\n", start_port, MIN_ALLOWED_PORT,
|
LOG_WRITE(LOG_LEVEL_ERROR, "Invalid port: %d, should be in [%d, %d]. Exiting.\n", start_port, MIN_ALLOWED_PORT,
|
||||||
MAX_ALLOWED_PORT);
|
MAX_ALLOWED_PORT);
|
||||||
free(motd);
|
free(motd);
|
||||||
free(tcp_relay_ports);
|
free(tcp_relay_ports);
|
||||||
@@ -283,28 +290,26 @@ int main(int argc, char *argv[])
|
|||||||
IP ip;
|
IP ip;
|
||||||
ip_init(&ip, enable_ipv6);
|
ip_init(&ip, enable_ipv6);
|
||||||
|
|
||||||
const Memory *mem = os_memory();
|
const Tox_Memory *mem = os_memory();
|
||||||
const Random *rng = os_random();
|
const Tox_Random *rng = os_random();
|
||||||
const Network *ns = os_network();
|
const Network *ns = os_network();
|
||||||
|
|
||||||
Logger *logger = logger_new(mem);
|
Logger *logger = logger_new(mem);
|
||||||
|
|
||||||
if (MIN_LOGGER_LEVEL <= LOGGER_LEVEL_DEBUG) {
|
logger_callback_log(logger, toxcore_logger_callback, nullptr, nullptr);
|
||||||
logger_callback_log(logger, toxcore_logger_callback, nullptr, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint16_t end_port = start_port + (TOX_PORTRANGE_TO - TOX_PORTRANGE_FROM);
|
const uint16_t end_port = start_port + (TOX_PORTRANGE_TO - TOX_PORTRANGE_FROM);
|
||||||
Networking_Core *net = new_networking_ex(logger, mem, ns, &ip, start_port, end_port, nullptr);
|
Networking_Core *net = new_networking_ex(logger, mem, ns, &ip, start_port, end_port, nullptr);
|
||||||
|
|
||||||
if (net == nullptr) {
|
if (net == nullptr) {
|
||||||
if (enable_ipv6 && enable_ipv4_fallback) {
|
if (enable_ipv6 && enable_ipv4_fallback) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Couldn't initialize IPv6 networking. Falling back to using IPv4.\n");
|
LOG_WRITE(LOG_LEVEL_WARNING, "Couldn't initialize IPv6 networking. Falling back to using IPv4.\n");
|
||||||
enable_ipv6 = false;
|
enable_ipv6 = false;
|
||||||
ip_init(&ip, enable_ipv6);
|
ip_init(&ip, enable_ipv6);
|
||||||
net = new_networking_ex(logger, mem, ns, &ip, start_port, end_port, nullptr);
|
net = new_networking_ex(logger, mem, ns, &ip, start_port, end_port, nullptr);
|
||||||
|
|
||||||
if (net == nullptr) {
|
if (net == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't fallback to IPv4. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't fallback to IPv4. Exiting.\n");
|
||||||
logger_kill(logger);
|
logger_kill(logger);
|
||||||
free(motd);
|
free(motd);
|
||||||
free(tcp_relay_ports);
|
free(tcp_relay_ports);
|
||||||
@@ -312,7 +317,7 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize networking. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize networking. Exiting.\n");
|
||||||
logger_kill(logger);
|
logger_kill(logger);
|
||||||
free(motd);
|
free(motd);
|
||||||
free(tcp_relay_ports);
|
free(tcp_relay_ports);
|
||||||
@@ -324,7 +329,7 @@ int main(int argc, char *argv[])
|
|||||||
Mono_Time *const mono_time = mono_time_new(mem, nullptr, nullptr);
|
Mono_Time *const mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||||
|
|
||||||
if (mono_time == nullptr) {
|
if (mono_time == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize monotonic timer. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize monotonic timer. Exiting.\n");
|
||||||
kill_networking(net);
|
kill_networking(net);
|
||||||
logger_kill(logger);
|
logger_kill(logger);
|
||||||
free(motd);
|
free(motd);
|
||||||
@@ -338,7 +343,7 @@ int main(int argc, char *argv[])
|
|||||||
DHT *const dht = new_dht(logger, mem, rng, ns, mono_time, net, true, enable_lan_discovery);
|
DHT *const dht = new_dht(logger, mem, rng, ns, mono_time, net, true, enable_lan_discovery);
|
||||||
|
|
||||||
if (dht == nullptr) {
|
if (dht == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n");
|
||||||
mono_time_free(mem, mono_time);
|
mono_time_free(mem, mono_time);
|
||||||
kill_networking(net);
|
kill_networking(net);
|
||||||
logger_kill(logger);
|
logger_kill(logger);
|
||||||
@@ -348,10 +353,10 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Forwarding *forwarding = new_forwarding(logger, mem, rng, mono_time, dht);
|
Forwarding *forwarding = new_forwarding(logger, mem, rng, mono_time, dht, net);
|
||||||
|
|
||||||
if (forwarding == nullptr) {
|
if (forwarding == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize forwarding. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize forwarding. Exiting.\n");
|
||||||
kill_dht(dht);
|
kill_dht(dht);
|
||||||
mono_time_free(mem, mono_time);
|
mono_time_free(mem, mono_time);
|
||||||
kill_networking(net);
|
kill_networking(net);
|
||||||
@@ -362,10 +367,10 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Announcements *announce = new_announcements(logger, mem, rng, mono_time, forwarding);
|
Announcements *announce = new_announcements(logger, mem, rng, mono_time, forwarding, dht, net);
|
||||||
|
|
||||||
if (announce == nullptr) {
|
if (announce == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize DHT announcements. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize DHT announcements. Exiting.\n");
|
||||||
kill_forwarding(forwarding);
|
kill_forwarding(forwarding);
|
||||||
kill_dht(dht);
|
kill_dht(dht);
|
||||||
mono_time_free(mem, mono_time);
|
mono_time_free(mem, mono_time);
|
||||||
@@ -380,7 +385,7 @@ int main(int argc, char *argv[])
|
|||||||
GC_Announces_List *group_announce = new_gca_list(mem);
|
GC_Announces_List *group_announce = new_gca_list(mem);
|
||||||
|
|
||||||
if (group_announce == nullptr) {
|
if (group_announce == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize group announces. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize group announces. Exiting.\n");
|
||||||
kill_announcements(announce);
|
kill_announcements(announce);
|
||||||
kill_forwarding(forwarding);
|
kill_forwarding(forwarding);
|
||||||
kill_dht(dht);
|
kill_dht(dht);
|
||||||
@@ -393,10 +398,10 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Onion *onion = new_onion(logger, mem, mono_time, rng, dht);
|
Onion *onion = new_onion(logger, mem, mono_time, rng, dht, net);
|
||||||
|
|
||||||
if (onion == nullptr) {
|
if (onion == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox Onion. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize Tox Onion. Exiting.\n");
|
||||||
kill_gca(group_announce);
|
kill_gca(group_announce);
|
||||||
kill_announcements(announce);
|
kill_announcements(announce);
|
||||||
kill_forwarding(forwarding);
|
kill_forwarding(forwarding);
|
||||||
@@ -410,10 +415,10 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht);
|
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht, net);
|
||||||
|
|
||||||
if (onion_a == nullptr) {
|
if (onion_a == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox Onion Announce. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize Tox Onion Announce. Exiting.\n");
|
||||||
kill_gca(group_announce);
|
kill_gca(group_announce);
|
||||||
kill_onion(onion);
|
kill_onion(onion);
|
||||||
kill_announcements(announce);
|
kill_announcements(announce);
|
||||||
@@ -431,11 +436,11 @@ int main(int argc, char *argv[])
|
|||||||
gca_onion_init(group_announce, onion_a);
|
gca_onion_init(group_announce, onion_a);
|
||||||
|
|
||||||
if (enable_motd) {
|
if (enable_motd) {
|
||||||
if (bootstrap_set_callbacks(dht_get_net(dht), DAEMON_VERSION_NUMBER, (uint8_t *)motd, strlen(motd) + 1) == 0) {
|
if (bootstrap_set_callbacks(net, DAEMON_VERSION_NUMBER, (uint8_t *)motd, strlen(motd) + 1) == 0) {
|
||||||
log_write(LOG_LEVEL_INFO, "Set MOTD successfully.\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "Set MOTD successfully.\n");
|
||||||
free(motd);
|
free(motd);
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't set MOTD: %s. Exiting.\n", motd);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't set MOTD: %s. Exiting.\n", motd);
|
||||||
kill_onion_announce(onion_a);
|
kill_onion_announce(onion_a);
|
||||||
kill_gca(group_announce);
|
kill_gca(group_announce);
|
||||||
kill_onion(onion);
|
kill_onion(onion);
|
||||||
@@ -453,10 +458,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (manage_keys(dht, keys_file_path)) {
|
if (manage_keys(dht, keys_file_path)) {
|
||||||
log_write(LOG_LEVEL_INFO, "Keys are managed successfully.\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "Keys are managed successfully.\n");
|
||||||
free(keys_file_path);
|
free(keys_file_path);
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't read/write: %s. Exiting.\n", keys_file_path);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't read/write: %s. Exiting.\n", keys_file_path);
|
||||||
kill_onion_announce(onion_a);
|
kill_onion_announce(onion_a);
|
||||||
kill_gca(group_announce);
|
kill_gca(group_announce);
|
||||||
kill_onion(onion);
|
kill_onion(onion);
|
||||||
@@ -475,7 +480,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (enable_tcp_relay) {
|
if (enable_tcp_relay) {
|
||||||
if (tcp_relay_port_count == 0) {
|
if (tcp_relay_port_count == 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "No TCP relay ports read. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "No TCP relay ports read. Exiting.\n");
|
||||||
kill_onion_announce(onion_a);
|
kill_onion_announce(onion_a);
|
||||||
kill_gca(group_announce);
|
kill_gca(group_announce);
|
||||||
kill_announcements(announce);
|
kill_announcements(announce);
|
||||||
@@ -496,7 +501,7 @@ int main(int argc, char *argv[])
|
|||||||
free(tcp_relay_ports);
|
free(tcp_relay_ports);
|
||||||
|
|
||||||
if (tcp_server != nullptr) {
|
if (tcp_server != nullptr) {
|
||||||
log_write(LOG_LEVEL_INFO, "Initialized Tox TCP server successfully.\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "Initialized Tox TCP server successfully.\n");
|
||||||
|
|
||||||
struct rlimit limit;
|
struct rlimit limit;
|
||||||
|
|
||||||
@@ -515,14 +520,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_NOFILE, &limit) == 0 && limit.rlim_cur < rlim_min) {
|
if (getrlimit(RLIMIT_NOFILE, &limit) == 0 && limit.rlim_cur < rlim_min) {
|
||||||
log_write(LOG_LEVEL_WARNING,
|
LOG_WRITE(LOG_LEVEL_WARNING,
|
||||||
"Current limit on the number of files this process can open (%ju) is rather low for the proper functioning of the TCP server. "
|
"Current limit on the number of files this process can open (%ju) is rather low for the proper functioning of the TCP server. "
|
||||||
"Consider raising the limit to at least %ju or the recommended %ju. "
|
"Consider raising the limit to at least %ju or the recommended %ju. "
|
||||||
"Continuing using the current limit (%ju).\n",
|
"Continuing using the current limit (%ju).\n",
|
||||||
(uintmax_t)limit.rlim_cur, (uintmax_t)rlim_min, (uintmax_t)rlim_suggested, (uintmax_t)limit.rlim_cur);
|
(uintmax_t)limit.rlim_cur, (uintmax_t)rlim_min, (uintmax_t)rlim_suggested, (uintmax_t)limit.rlim_cur);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox TCP server. Exiting.\n");
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't initialize Tox TCP server. Exiting.\n");
|
||||||
kill_onion_announce(onion_a);
|
kill_onion_announce(onion_a);
|
||||||
kill_gca(group_announce);
|
kill_gca(group_announce);
|
||||||
kill_onion(onion);
|
kill_onion(onion);
|
||||||
@@ -537,9 +542,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bootstrap_from_config(cfg_file_path, dht, enable_ipv6)) {
|
if (bootstrap_from_config(cfg_file_path, dht, enable_ipv6)) {
|
||||||
log_write(LOG_LEVEL_INFO, "List of bootstrap nodes read successfully.\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "List of bootstrap nodes read successfully.\n");
|
||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't read list of bootstrap nodes in %s. Exiting.\n", cfg_file_path);
|
LOG_WRITE(LOG_LEVEL_ERROR, "Couldn't read list of bootstrap nodes in %s. Exiting.\n", cfg_file_path);
|
||||||
kill_tcp_server(tcp_server);
|
kill_tcp_server(tcp_server);
|
||||||
kill_onion_announce(onion_a);
|
kill_onion_announce(onion_a);
|
||||||
kill_gca(group_announce);
|
kill_gca(group_announce);
|
||||||
@@ -564,7 +569,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (enable_lan_discovery) {
|
if (enable_lan_discovery) {
|
||||||
broadcast = lan_discovery_init(mem, ns);
|
broadcast = lan_discovery_init(mem, ns);
|
||||||
log_write(LOG_LEVEL_INFO, "Initialized LAN discovery successfully.\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "Initialized LAN discovery successfully.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
@@ -578,11 +583,11 @@ int main(int argc, char *argv[])
|
|||||||
sigfillset(&sa.sa_mask);
|
sigfillset(&sa.sa_mask);
|
||||||
|
|
||||||
if (sigaction(SIGINT, &sa, nullptr) != 0) {
|
if (sigaction(SIGINT, &sa, nullptr) != 0) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Couldn't set signal handler for SIGINT. Continuing without the signal handler set.\n");
|
LOG_WRITE(LOG_LEVEL_WARNING, "Couldn't set signal handler for SIGINT. Continuing without the signal handler set.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sigaction(SIGTERM, &sa, nullptr) != 0) {
|
if (sigaction(SIGTERM, &sa, nullptr) != 0) {
|
||||||
log_write(LOG_LEVEL_WARNING, "Couldn't set signal handler for SIGTERM. Continuing without the signal handler set.\n");
|
LOG_WRITE(LOG_LEVEL_WARNING, "Couldn't set signal handler for SIGTERM. Continuing without the signal handler set.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (caught_signal == 0) {
|
while (caught_signal == 0) {
|
||||||
@@ -591,7 +596,7 @@ int main(int argc, char *argv[])
|
|||||||
do_dht(dht);
|
do_dht(dht);
|
||||||
|
|
||||||
if (enable_lan_discovery && mono_time_is_timeout(mono_time, last_lan_discovery, LAN_DISCOVERY_INTERVAL)) {
|
if (enable_lan_discovery && mono_time_is_timeout(mono_time, last_lan_discovery, LAN_DISCOVERY_INTERVAL)) {
|
||||||
lan_discovery_send(dht_get_net(dht), broadcast, dht_get_self_public_key(dht), net_htons_port);
|
lan_discovery_send(net, broadcast, dht_get_self_public_key(dht), net_htons_port);
|
||||||
last_lan_discovery = mono_time_get(mono_time);
|
last_lan_discovery = mono_time_get(mono_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,10 +606,10 @@ int main(int argc, char *argv[])
|
|||||||
do_tcp_server(tcp_server, mono_time);
|
do_tcp_server(tcp_server, mono_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
networking_poll(dht_get_net(dht), nullptr);
|
networking_poll(net, nullptr);
|
||||||
|
|
||||||
if (waiting_for_dht_connection && dht_isconnected(dht)) {
|
if (waiting_for_dht_connection && dht_isconnected(dht)) {
|
||||||
log_write(LOG_LEVEL_INFO, "Connected to another bootstrap node successfully.\n");
|
LOG_WRITE(LOG_LEVEL_INFO, "Connected to another bootstrap node successfully.\n");
|
||||||
waiting_for_dht_connection = false;
|
waiting_for_dht_connection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,15 +618,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
switch (caught_signal) {
|
switch (caught_signal) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
log_write(LOG_LEVEL_INFO, "Received SIGINT (%d) signal. Exiting.\n", SIGINT);
|
LOG_WRITE(LOG_LEVEL_INFO, "Received SIGINT (%d) signal. Exiting.\n", SIGINT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
log_write(LOG_LEVEL_INFO, "Received SIGTERM (%d) signal. Exiting.\n", SIGTERM);
|
LOG_WRITE(LOG_LEVEL_INFO, "Received SIGTERM (%d) signal. Exiting.\n", SIGTERM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_write(LOG_LEVEL_INFO, "Received (%ld) signal. Exiting.\n", (long)caught_signal);
|
LOG_WRITE(LOG_LEVEL_INFO, "Received (%ld) signal. Exiting.\n", (long)caught_signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
lan_discovery_kill(broadcast);
|
lan_discovery_kill(broadcast);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Stage 1 - Compile websockify.
|
# Stage 1 - Compile websockify.
|
||||||
FROM toxchat/bootstrap-node:latest AS tox
|
FROM toxchat/bootstrap-node:latest AS tox
|
||||||
FROM golang:1.17-alpine AS websockify
|
FROM golang:1.23-alpine3.21 AS websockify
|
||||||
|
|
||||||
COPY websockify /work/websockify
|
COPY websockify /work/websockify
|
||||||
RUN cd /work/websockify && go mod download github.com/gorilla/websocket && go install
|
RUN cd /work/websockify && go mod download github.com/gorilla/websocket && go install
|
||||||
@@ -25,5 +25,7 @@ USER tox
|
|||||||
#RUN /usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf --log-backend stdout \
|
#RUN /usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf --log-backend stdout \
|
||||||
# && sleep 1
|
# && sleep 1
|
||||||
|
|
||||||
|
COPY tox-bootstrapd.conf /etc/
|
||||||
|
|
||||||
WORKDIR /web
|
WORKDIR /web
|
||||||
CMD ["/entrypoint.sh"]
|
CMD ["/entrypoint.sh"]
|
||||||
|
|||||||
12
external/toxcore/c-toxcore/other/bootstrap_daemon/websocket/build.sh
vendored
Executable file
12
external/toxcore/c-toxcore/other/bootstrap_daemon/websocket/build.sh
vendored
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
|
||||||
|
GIT_ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
# Build bootstrap daemon first.
|
||||||
|
"$GIT_ROOT/other/bootstrap_daemon/docker/build.sh"
|
||||||
|
|
||||||
|
# Build websocket server.
|
||||||
|
cd "$GIT_ROOT/other/bootstrap_daemon/websocket"
|
||||||
|
docker build -t toxchat/bootstrap-node:latest-websocket .
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf --log-backend stdout
|
/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf --log-backend stdout --trace
|
||||||
/usr/local/bin/websockify -l "0.0.0.0:$PORT" -t 127.0.0.1:33445
|
/usr/local/bin/websockify -l "0.0.0.0:$PORT" -t 127.0.0.1:33445
|
||||||
|
|||||||
21
external/toxcore/c-toxcore/other/bootstrap_daemon/websocket/tox-bootstrapd.conf
vendored
Normal file
21
external/toxcore/c-toxcore/other/bootstrap_daemon/websocket/tox-bootstrapd.conf
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Tox WebSocket bootstrap daemon configuration file.
|
||||||
|
|
||||||
|
port = 33445
|
||||||
|
|
||||||
|
keys_file_path = "/var/lib/tox-bootstrapd/keys"
|
||||||
|
|
||||||
|
pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"
|
||||||
|
|
||||||
|
enable_ipv6 = false
|
||||||
|
enable_ipv4_fallback = true
|
||||||
|
enable_lan_discovery = false
|
||||||
|
|
||||||
|
enable_tcp_relay = true
|
||||||
|
tcp_relay_ports = [443, 3389, 33445]
|
||||||
|
|
||||||
|
enable_motd = true
|
||||||
|
|
||||||
|
motd = "tox-bootstrapd"
|
||||||
|
|
||||||
|
# No bootstrap nodes for now, since none of them support WebSocket.
|
||||||
|
bootstrap_nodes = ()
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=autotools
|
BUILD=autotools
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=clang-tidy
|
BUILD=clang-tidy
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=compcert
|
BUILD=compcert
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ set -eux
|
|||||||
read -a ci_env <<<"$(bash <(curl -s https://codecov.io/env))"
|
read -a ci_env <<<"$(bash <(curl -s https://codecov.io/env))"
|
||||||
|
|
||||||
BUILD=coverage
|
BUILD=coverage
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|
||||||
docker run "${ci_env[@]}" -e CI=true --name toxcore-coverage --rm -t toxchat/c-toxcore:coverage /usr/local/bin/codecov
|
docker run "${ci_env[@]}" -e CI=true --name toxcore-coverage --rm -t toxchat/c-toxcore:coverage /usr/local/bin/codecov
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=cppcheck
|
BUILD=cppcheck
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM toxchat/c-toxcore:sources AS sources
|
FROM toxchat/c-toxcore:sources AS sources
|
||||||
FROM ghcr.io/goblint/analyzer:latest
|
FROM ghcr.io/goblint/analyzer:2.5.0
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
|
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=goblint
|
BUILD=goblint
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=infer
|
BUILD=infer
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=misra
|
BUILD=misra
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ PROJECT_COMMIT_ID="$(git rev-parse HEAD)"
|
|||||||
PROJECT_COMMIT_ID_SHORT="$(git rev-parse --short HEAD)"
|
PROJECT_COMMIT_ID_SHORT="$(git rev-parse --short HEAD)"
|
||||||
|
|
||||||
BUILD=rpm
|
BUILD=rpm
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" . \
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" . \
|
||||||
--build-arg="PROJECT_VERSION=$PROJECT_VERSION" \
|
--build-arg="PROJECT_VERSION=$PROJECT_VERSION" \
|
||||||
--build-arg="PROJECT_COMMIT_ID=$PROJECT_COMMIT_ID" \
|
--build-arg="PROJECT_COMMIT_ID=$PROJECT_COMMIT_ID" \
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=slimcc
|
BUILD=slimcc
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
BUILD=sparse
|
BUILD=sparse
|
||||||
other/docker/sources/build
|
other/docker/sources/build.sh
|
||||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user