Squashed 'external/toxcore/c-toxcore/' changes from d9b8fa6098d..81b1e4f6348

81b1e4f6348 chore: Release v0.2.21-rc.1
9303e2e49a1 chore: Update the pkgsrc versions in the update-versions tool
71ec4b3b1e9 chore: Update the version-sync script to work in a post-tox.api.h world
66da842f753 chore: Add version update script compatible with ci-tools.
199878f7660 chore: Use new bazel script for circle ci.
8278e9cda46 chore: Add release issue template and workflow.
a9bb3a1c4d1 chore: Fix alpine-s390x build.
6e0a641272e chore: Add a source tarball deploy workflow.
4adebe4d8b1 chore: Don't upload ios/macos variants in deploy workflows.
18f1d858ccb chore: Move one of the 3 freebsd builds to post-submit.
432ab60c002 feat: Add a Makefile for the single file deploy build.
a86c0011fd5 chore: Add deploy job for single C file library.
2e7495e8f2a docs: Update changelog format to use the new clog-compatible way.
a682da99e84 chore: Export wasmExports from the wasm binary.
12f34cdff27 chore: Add wasm to the nightly binary deploys.
1451029613f chore: Add strict-abi support for macOS/iOS.
c53c30e09d9 chore: Add time option to manual fuzz trigger.
2ccecdc2a1a chore: Add remaining fuzz tests to cflite.
4626c2e230e test: Add a Net_Crypto fuzz test.
b4a0e617c48 refactor: Use IP string length from ip_ntoa instead of strlen.
b85b91f22f6 cleanup: rename getnodes/sendnodes to nodes request/response This change alignes the naming to be closer to the spec and make it less ambiguous. This change also changes the naming of some private/experimental marked APIs. - tox_callback_dht_nodes_response() - tox_dht_nodes_request() - Tox_Event_Dht_Get_Nodes_Response
f1991aaa029 perf: Use stack allocation for strerror rendering.
3984211ccbf cleanup: remove kicked peers from saved peers list
26a991ed2be fix: ip to string function not accepting tcp families
712861f2e6d cleanup: Make websockify output qtox-compatible logging.
01932ea2f73 chore: Add opus and vpx to the toxcore wasm build.
d29c42ef631 refactor: don't fully discard received DHT nodes. This is mostly forward thinking, where we might introduce other ip families, in addition to ipv4, ipv6, tcp_ipv4 etc.
21e2325934f chore: Fix xcframework tarball creation.
b10c8b766ba chore: Fix xcframework checksum creation.
93787a9322e chore: Add ios/macos framework build.
9f723f891d3 fix: run do_gca also in bootstrap nodes
496cc703556 chore: Support arm64 iphone simulator.
aa0e2a8e928 chore: Add support for more iOS architectures.
13ad8e81cbf chore: Add binary deploy workflows.
c8344726378 refactor: Move tox_log_level out into its own file.
8799bea76c3 cleanup: Mark events/dispatch headers as experimental.
d4164edb548 refactor: Remove tox_types.h; use `struct` tags instead.
d408c982090 refactor: Move `Tox_Options` to `tox_options.h`.
5ab42d41209 chore: Move most cirrus jobs to circleci.
463eeae1144 cleanup: Avoid clashing with global define `DEBUG`.
92cc1e91747 refactor: Make Tox_Options own the passed proxy host and savedata.
f276b397226 test: Add some more asserts for I/O and alloc to succeed.
edb4dfc4869 fix: Don't crash on malloc failures in bin_unpack.
be457d5d0b2 cleanup: Use tox memory for bin_unpack and net_strerror.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 81b1e4f6348124784088591c4fe9ab41e273031d
This commit is contained in:
Green Sky 2025-03-12 19:16:50 +01:00
parent 3b6bb15e86
commit 3105cc20ef
130 changed files with 3604 additions and 1776 deletions

View File

@ -1,12 +0,0 @@
#!/bin/sh
set -eux
git submodule update --init --recursive
/src/workspace/tools/inject-repo c-toxcore
# TODO(iphydf): Re-enable fuzz-test when https://github.com/tweag/rules_nixpkgs/issues/442 is fixed.
cd /src/workspace && bazel test -k \
--build_tag_filters=-haskell,-fuzz-test \
--test_tag_filters=-haskell,-fuzz-test \
-- \
"$@"

View File

@ -6,11 +6,13 @@ workflows:
circleci:
jobs:
- bazel-asan
- bazel-dbg
- bazel-opt
- bazel-debug
- bazel-msan
- bazel-release
- clang-analyze
- cpplint
- static-analysis
- cimple
- cimplefmt
- generate-events
@ -18,31 +20,45 @@ jobs:
bazel-asan:
working_directory: /tmp/cirrus-ci-build
docker:
- image: toxchat/toktok-stack:latest-asan
- image: toxchat/toktok-stack:latest
steps:
- checkout
- run: .circleci/bazel-test
- run: bash <(curl -s https://raw.githubusercontent.com/TokTok/ci-tools/refs/heads/master/tools/circleci-bazel-test)
--build_tag_filters=-haskell,-fuzz-test
--test_tag_filters=-haskell,-fuzz-test
//c-toxcore/...
bazel-dbg:
bazel-debug:
working_directory: /tmp/cirrus-ci-build
docker:
- image: toxchat/toktok-stack:latest-debug
- image: toxchat/toktok-stack:latest
steps:
- checkout
- run: .circleci/bazel-test
- run: bash <(curl -s https://raw.githubusercontent.com/TokTok/ci-tools/refs/heads/master/tools/circleci-bazel-test)
--build_tag_filters=-haskell
--test_tag_filters=-haskell
//c-toxcore/...
bazel-opt:
bazel-msan:
working_directory: /tmp/cirrus-ci-build
docker:
- image: toxchat/toktok-stack:latest-release
- image: toxchat/toktok-stack:latest
steps:
- checkout
- run: .circleci/bazel-test
- run: bash <(curl -s https://raw.githubusercontent.com/TokTok/ci-tools/refs/heads/master/tools/circleci-bazel-test)
//c-toxcore/auto_tests:lossless_packet_test
bazel-release:
working_directory: /tmp/cirrus-ci-build
docker:
- image: toxchat/toktok-stack:latest
steps:
- checkout
- run: bash <(curl -s https://raw.githubusercontent.com/TokTok/ci-tools/refs/heads/master/tools/circleci-bazel-test)
//c-toxcore/...
static-analysis:
@ -106,6 +122,23 @@ jobs:
- run: git submodule update --init --recursive
- run: other/analysis/run-cpplint
cimple:
working_directory: /tmp/cirrus-ci-build
docker:
- image: toxchat/toktok-stack:latest-release
steps:
- checkout
- run: git submodule update --init --recursive
- run: /src/workspace/tools/inject-repo c-toxcore
- run: cd /src/workspace &&
bazel test
-k
--build_tag_filters=haskell
--test_tag_filters=haskell
--
//c-toxcore/...
cimplefmt:
working_directory: ~/work
machine: { image: ubuntu-2204:current }

View File

@ -1,76 +1,8 @@
---
bazel-opt_task:
timeout_in: 10m
container:
image: toxchat/toktok-stack:latest-release
cpu: 8
memory: 2G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && tools/retry 5 bazel
test -k
--build_tag_filters=-haskell
--test_tag_filters=-haskell
--
//c-toxcore/...
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.
bazel-dbg_task:
timeout_in: 10m
container:
image: toxchat/toktok-stack:latest-debug
cpu: 8
memory: 2G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && tools/retry 5 bazel
test -k
--build_tag_filters=-haskell
--test_tag_filters=-haskell
--
//c-toxcore/...
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.
bazel-msan_task:
timeout_in: 10m
container:
image: toxchat/toktok-stack:latest-msan
cpu: 4
memory: 2G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && tools/retry 5 bazel
test -k
--
//c-toxcore/auto_tests:lossless_packet_test
cimple_task:
timeout_in: 5m
container:
image: toxchat/toktok-stack:latest-release
cpu: 2
memory: 4G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && bazel
test -k
--build_tag_filters=haskell
--test_tag_filters=haskell
--
//c-toxcore/...
freebsd_task:
timeout_in: 5m
freebsd_instance:
image_family: freebsd-14-1
image_family: freebsd-14-2
configure_script:
- PAGER=cat ASSUME_ALWAYS_YES=YES pkg install
cmake
@ -87,7 +19,7 @@ freebsd_task:
test_all_script:
- |
# TODO(iphydf): Investigate FreeBSD failures on these tests.
sed -Ei -e '/\(dht_getnodes_api\)/s/^/#/' auto_tests/CMakeLists.txt
sed -Ei -e '/\(dht_nodes_response_api\)/s/^/#/' auto_tests/CMakeLists.txt
cmake . \
-DMIN_LOGGER_LEVEL=TRACE \
-DMUST_BUILD_TOXAV=ON \

3
.clog.toml Normal file
View File

@ -0,0 +1,3 @@
[clog]
repository = "https://github.com/TokTok/c-toxcore"
changelog = "CHANGELOG.md"

View File

@ -3,19 +3,23 @@
# We want to use the latest tools always
FROM gcr.io/oss-fuzz-base/base-builder:latest
RUN apt-get update && \
apt-get -y install --no-install-suggests --no-install-recommends \
cmake libtool autoconf automake pkg-config \
RUN apt-get update \
&& apt-get -y install --no-install-suggests --no-install-recommends \
cmake \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Static builds of dependencies
# libsodium
RUN git clone --depth 1 --branch 1.0.18 https://github.com/jedisct1/libsodium libsodium
WORKDIR $SRC/libsodium
RUN ./autogen.sh && ./configure --enable-shared=no && make install
WORKDIR $SRC
RUN tar zxf <(curl -L https://github.com/jedisct1/libsodium/releases/download/1.0.20-RELEASE/libsodium-1.0.20.tar.gz) \
&& cd libsodium-* \
&& ./configure --enable-shared=no \
&& make install \
&& cd ..
# Copy your project's source code.
COPY . $SRC/c-toxcore

View File

@ -1,6 +1,16 @@
#!/bin/bash -eu
FUZZ_TARGETS="bootstrap_fuzz_test toxsave_fuzz_test"
FUZZ_TARGETS=(
DHT_fuzz_test
bootstrap_fuzz_test
# e2e_fuzz_test
forwarding_fuzz_test
group_announce_fuzz_test
group_moderation_fuzz_test
net_crypto_fuzz_test
tox_events_fuzz_test
toxsave_fuzz_test
)
# out of tree build
cd "$WORK"
@ -12,11 +22,10 @@ cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LIB_FUZZING_ENGINE" \
-DBUILD_TOXAV=OFF -DENABLE_SHARED=NO -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
cmake --build ./ --target "$TARGET"

24
.github/ISSUE_TEMPLATE/release.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: 🚀 Release
description: Build and deploy a new release
title: Release tracking issue
labels: [chore]
type: Task
body:
- type: textarea
id: release-notes
attributes:
label: Release notes
description: Write something nice about the new release.
placeholder: "Here's our latest awesome release!"
validations:
required: true
- type: dropdown
id: production
attributes:
label: Release type
description: Whether this is a production release or a release candidate.
options:
- Release candidate
- Production release
validations:
required: true

View File

@ -1,65 +0,0 @@
#!/bin/bash
set -eu
# Set up environment
NDK=$ANDROID_NDK_HOME
ABI=${1:-"armeabi-v7a"}
case $ABI in
armeabi-v7a)
TARGET=armv7a-linux-androideabi
NDK_API=21
;;
arm64-v8a)
TARGET=aarch64-linux-android
NDK_API=21
;;
x86)
TARGET=i686-linux-android
NDK_API=21
;;
x86_64)
TARGET=x86_64-linux-android
NDK_API=21
;;
*)
exit 1
;;
esac
rm -rf _android_prefix
mkdir -p _android_prefix
PREFIX=$PWD/_android_prefix
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
SYSROOT=$TOOLCHAIN/sysroot
export CC="$TOOLCHAIN/bin/$TARGET$NDK_API"-clang
export LDFLAGS=-static-libstdc++
export PKG_CONFIG_PATH="$PREFIX"/lib/pkgconfig
# Build libsodium
if [ ! -d libsodium ]; then
git clone --branch=1.0.18 https://github.com/jedisct1/libsodium.git
fi
cd libsodium
git clean -ffdx
autoreconf -fi
./configure --prefix="$PREFIX" --host="$TARGET" --with-sysroot="$SYSROOT" --disable-shared --disable-pie
make -j"$(nproc)" install
cd ..
# Build c-toxcore
rm -rf _build
mkdir -p _build
cd _build
cmake .. \
-DBUILD_TOXAV=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="$ABI" \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_PREFIX_PATH="$PREFIX"
cmake --build .

View File

@ -9,7 +9,6 @@ brew update
brew install \
libconfig \
libsodium \
libvpx \
opus

View File

@ -69,6 +69,8 @@ add_cxx_flag -Wno-c99-extensions
add_cxx_flag -Wno-old-style-cast
# GTest does this.
add_cxx_flag -Wno-global-constructors
# Needed for some fuzzers.
add_cxx_flag -Wno-exit-time-destructors
# Downgrade to warning so we still see it.
add_flag -Wno-error=unreachable-code

View File

@ -1,11 +1,20 @@
# Derived from: https://google.github.io/clusterfuzzlite/running-clusterfuzzlite/github-actions/
name: ClusterFuzzLite batch fuzzing
on:
schedule:
- cron: '0 6,8 * * *' # Run twice a day at low activity times
workflow_dispatch: # Manual trigger for testing
inputs:
fuzz-seconds:
description: 'Number of seconds to fuzz (total, not per test)'
required: false
type: number
default: 3600
permissions: read-all
jobs:
BatchFuzzing:
runs-on: ubuntu-latest
@ -27,7 +36,8 @@ jobs:
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 3600 # 60min
# 1 hour on schedule, configurable on manual trigger.
fuzz-seconds: ${{ github.event.inputs.fuzz-seconds || 3600 }}
mode: 'batch'
sanitizer: ${{ matrix.sanitizer }}
# Optional but recommended: For storing certain artifacts from fuzzing.

View File

@ -7,6 +7,7 @@ on:
workflow_dispatch: # Manual trigger for testing
permissions: read-all
jobs:
Pruning:
runs-on: ubuntu-latest
@ -26,6 +27,7 @@ jobs:
storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/TokTok/toktok-fuzzer.git
storage-repo-branch: master # Optional. Defaults to "main"
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
Coverage:
runs-on: ubuntu-latest
steps:
@ -47,4 +49,3 @@ jobs:
storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/TokTok/toktok-fuzzer.git
storage-repo-branch: master # Optional. Defaults to "main"
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".

36
.github/workflows/cflite_pr.yml vendored Normal file
View File

@ -0,0 +1,36 @@
# Derived from: https://google.github.io/clusterfuzzlite/running-clusterfuzzlite/github-actions/
name: ClusterFuzzLite pull request fuzzing
on:
pull_request:
types: [opened, synchronize]
jobs:
Fuzzing:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer:
- address
- undefined
- memory
steps:
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
sanitizer: ${{ matrix.sanitizer }}
- name: Run Fuzzers (${{ matrix.sanitizer }})
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 300 # 5 mins (total time, not per test)
mode: 'code-change'
sanitizer: ${{ matrix.sanitizer }}
# Optional but recommended: For storing certain artifacts from fuzzing.
# See later section on "Git repo for storage".
storage-repo: https://github.com/TokTok/toktok-fuzzer.git
storage-repo-branch: master # Optional. Defaults to "main"

View File

@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, freebsd, misra, modules, pkgsrc, rpm, slimcc, sparse, tcc, tokstyle]
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, modules, pkgsrc, rpm, slimcc, sparse, tcc, tokstyle]
runs-on: ubuntu-22.04
steps:
- name: Set up Docker Buildx
@ -60,17 +60,6 @@ jobs:
- name: Build, test, and upload coverage
run: other/docker/coverage/run
build-android:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- run: .github/scripts/cmake-android armeabi-v7a
- run: .github/scripts/cmake-android arm64-v8a
- run: .github/scripts/cmake-android x86
- run: .github/scripts/cmake-android x86_64
build-macos:
runs-on: macos-latest
steps:
@ -132,7 +121,7 @@ jobs:
run: |
# TODO(iphydf): Investigate NetBSD failures on these tests.
sed -Ei -e '/\((TCP|dht_getnodes_api)\)/s/^/#/' auto_tests/CMakeLists.txt
sed -Ei -e '/\((TCP|dht_nodes_response_api)\)/s/^/#/' auto_tests/CMakeLists.txt
cmake . \
-DMIN_LOGGER_LEVEL=TRACE \
-DMUST_BUILD_TOXAV=ON \
@ -171,7 +160,7 @@ jobs:
run: |
# TODO(iphydf): Investigate FreeBSD failures on these tests.
sed -Ei -e '/\(dht_getnodes_api\)/s/^/#/' auto_tests/CMakeLists.txt
sed -Ei -e '/\(dht_nodes_response_api\)/s/^/#/' auto_tests/CMakeLists.txt
cmake . \
-DMIN_LOGGER_LEVEL=TRACE \
-DMUST_BUILD_TOXAV=ON \

358
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,358 @@
name: deploy
on:
# Allow manual trigger.
workflow_dispatch:
pull_request:
branches: ["master"]
push:
branches: ["master"]
tags: ["v*"]
# Cancel old PR builds when pushing new commits.
concurrency:
group: deploy-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
################################################################################################
# Preparation jobs
################################################################################################
prepare:
name: Prepare
uses: TokTok/ci-tools/.github/workflows/deploy-prepare.yml@master
################################################################################################
# Build and deploy jobs (PR and push)
################################################################################################
build-linux:
name: Linux
needs: [prepare]
strategy:
matrix:
arch: [aarch64, x86_64]
runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install build tools
run: sudo apt-get install -y --no-install-recommends ninja-build yasm
- name: Cache dependencies
uses: actions/cache@v4
with:
path: deps-prefix-linux-${{ matrix.arch }}
key: ${{ github.job }}-${{ matrix.arch }}-deps
- name: Run build
run: other/deploy/linux.sh "${{ matrix.arch }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: toxcore-linux-${{ matrix.arch }}
path: toxcore-linux-${{ matrix.arch }}
if-no-files-found: error
- name: Get tag name for release file name
if: contains(github.ref, 'refs/tags/v')
id: get_version
run: |
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
echo "release_tarball=toxcore-$VERSION-linux-${{ matrix.arch }}.tar.gz" >>$GITHUB_OUTPUT
- name: Create tarball for release upload
if: contains(github.ref, 'refs/tags/v')
run: |
tar zcf "${{ steps.get_version.outputs.release_tarball }}" toxcore-linux-${{ matrix.arch }}
sha256sum "${{ steps.get_version.outputs.release_tarball }}" >"${{ steps.get_version.outputs.release_tarball }}.sha256"
- name: Upload to versioned release
if: contains(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
draft: true
artifacts: "${{ steps.get_version.outputs.release_tarball }},${{ steps.get_version.outputs.release_tarball }}.sha256"
- name: Create tarball for nightly upload
run: |
tar zcf toxcore-nightly-linux-${{ matrix.arch }}.tar.gz toxcore-linux-${{ matrix.arch }}
sha256sum toxcore-nightly-linux-${{ matrix.arch }}.tar.gz >toxcore-nightly-linux-${{ matrix.arch }}.tar.gz.sha256
- name: Upload to nightly release
uses: ncipollo/release-action@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
allowUpdates: true
tag: nightly
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
prerelease: true
replacesArtifacts: true
artifacts: "toxcore-nightly-linux-${{ matrix.arch }}.tar.gz,toxcore-nightly-linux-${{ matrix.arch }}.tar.gz.sha256"
build-macos:
name: macOS
needs: [prepare]
strategy:
matrix:
arch: [arm64, x86_64]
runs-on: ${{ matrix.arch == 'arm64' && 'macos-14' || 'macos-13' }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache dependencies
uses: actions/cache@v4
with:
path: deps-prefix-macos-${{ matrix.arch }}
key: ${{ github.job }}-${{ matrix.arch }}-deps
- name: Run build
run: other/deploy/macos.sh "${{ matrix.arch }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: toxcore-macos-${{ matrix.arch }}
path: toxcore-macos-${{ matrix.arch }}
if-no-files-found: error
build-ios:
name: iOS
needs: [prepare]
strategy:
matrix:
target: [ios-arm64, ios-armv7, ios-armv7s, iphonesimulator-arm64, iphonesimulator-x86_64]
runs-on: 'macos-14'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache dependencies
uses: actions/cache@v4
with:
path: deps-prefix-${{ matrix.target }}
key: ${{ github.job }}-${{ matrix.target }}-deps
- name: Run build
run: other/deploy/ios.sh "${{ matrix.target }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: toxcore-${{ matrix.target }}
path: toxcore-${{ matrix.target }}
if-no-files-found: error
build-xcode-framework:
name: Xcode Framework
needs: [build-ios, build-macos]
runs-on: 'macos-14'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download artifact for ios
uses: actions/download-artifact@v4
with:
pattern: toxcore-ios-*
- name: Download artifact for iphonesimulator
uses: actions/download-artifact@v4
with:
pattern: toxcore-iphonesimulator-*
- name: Download artifact for macos
uses: actions/download-artifact@v4
with:
pattern: toxcore-macos-*
- name: Run build
run: |
mv toxcore-* other/deploy/apple/
other/deploy/apple/make-framework.sh
tar -C other/deploy/apple -zcf toxcore-xcframework.tar.gz Tox.xcframework
shasum -a 256 toxcore-xcframework.tar.gz >toxcore-xcframework.tar.gz.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: toxcore-xcframework
path: other/deploy/apple/Tox.xcframework
if-no-files-found: error
- name: Get tag name for release file name
if: contains(github.ref, 'refs/tags/v')
id: get_version
run: |
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
echo "release_tarball=toxcore-$VERSION-xcframework.tar.gz" >>$GITHUB_OUTPUT
- name: Create tarball for release upload
if: contains(github.ref, 'refs/tags/v')
run: |
cp toxcore-xcframework.tar.gz "${{ steps.get_version.outputs.release_tarball }}"
cp toxcore-xcframework.tar.gz.sha256 "${{ steps.get_version.outputs.release_tarball }}.sha256"
- name: Upload to versioned release
if: contains(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
draft: true
artifacts: "${{ steps.get_version.outputs.release_tarball }},${{ steps.get_version.outputs.release_tarball }}.sha256"
- name: Create tarball for nightly upload
run: |
cp toxcore-xcframework.tar.gz toxcore-nightly-xcframework.tar.gz
cp toxcore-xcframework.tar.gz.sha256 toxcore-nightly-xcframework.tar.gz.sha256
- name: Upload to nightly release
uses: ncipollo/release-action@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
allowUpdates: true
tag: nightly
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
prerelease: true
replacesArtifacts: true
artifacts: "toxcore-nightly-xcframework.tar.gz,toxcore-nightly-xcframework.tar.gz.sha256"
build-android:
name: Android
needs: [prepare]
strategy:
matrix:
arch: [armeabi-v7a, arm64-v8a, x86, x86_64]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache dependencies
uses: actions/cache@v4
with:
path: deps-prefix-android-${{ matrix.arch }}
key: ${{ github.job }}-${{ matrix.arch }}-deps
- name: Run build
run: other/deploy/android.sh "${{ matrix.arch }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: toxcore-android-${{ matrix.arch }}
path: toxcore-android-${{ matrix.arch }}
if-no-files-found: error
- name: Get tag name for release file name
if: contains(github.ref, 'refs/tags/v')
id: get_version
run: |
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
echo "release_tarball=toxcore-$VERSION-android-${{ matrix.arch }}.tar.gz" >>$GITHUB_OUTPUT
- name: Create tarball for release upload
if: contains(github.ref, 'refs/tags/v')
run: |
tar zcf "${{ steps.get_version.outputs.release_tarball }}" toxcore-android-${{ matrix.arch }}
sha256sum "${{ steps.get_version.outputs.release_tarball }}" >"${{ steps.get_version.outputs.release_tarball }}.sha256"
- name: Upload to versioned release
if: contains(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
draft: true
artifacts: "${{ steps.get_version.outputs.release_tarball }},${{ steps.get_version.outputs.release_tarball }}.sha256"
- name: Create tarball for nightly upload
run: |
tar zcf toxcore-nightly-android-${{ matrix.arch }}.tar.gz toxcore-android-${{ matrix.arch }}
sha256sum toxcore-nightly-android-${{ matrix.arch }}.tar.gz >toxcore-nightly-android-${{ matrix.arch }}.tar.gz.sha256
- name: Upload to nightly release
uses: ncipollo/release-action@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
allowUpdates: true
tag: nightly
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
prerelease: true
replacesArtifacts: true
artifacts: "toxcore-nightly-android-${{ matrix.arch }}.tar.gz,toxcore-nightly-android-${{ matrix.arch }}.tar.gz.sha256"
build-wasm:
name: WebAssembly
needs: [prepare]
runs-on: ubuntu-24.04
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
file: other/docker/wasm/wasm.Dockerfile
push: ${{ github.event_name == 'push' }}
tags: toxchat/c-toxcore:wasm
cache-from: type=registry,ref=toxchat/c-toxcore:wasm
cache-to: type=inline
outputs: type=docker
- name: Extract wasm build
run: docker run --rm --entrypoint tar toxchat/c-toxcore:wasm -C /wasm/bin -c libtoxcore.js libtoxcore.wasm >toxcore-wasm.tar
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: toxcore-wasm.tar
path: toxcore-wasm.tar
if-no-files-found: error
- name: Compress tarball
run: gzip toxcore-wasm.tar
- name: Get tag name for release file name
if: contains(github.ref, 'refs/tags/v')
id: get_version
run: |
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
echo "release_tarball=toxcore-$VERSION-wasm.tar.gz" >>$GITHUB_OUTPUT
- name: Create tarball for release upload
if: contains(github.ref, 'refs/tags/v')
run: |
cp toxcore-wasm.tar.gz "${{ steps.get_version.outputs.release_tarball }}"
- name: Upload to versioned release
if: contains(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
draft: true
artifacts: "${{ steps.get_version.outputs.release_tarball }}"
- name: Create tarball for nightly upload
run: |
cp toxcore-wasm.tar.gz toxcore-nightly-wasm.tar.gz
- name: Upload to nightly release
uses: ncipollo/release-action@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
allowUpdates: true
tag: nightly
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
prerelease: true
replacesArtifacts: true
artifacts: "toxcore-nightly-wasm.tar.gz"
build-single-file:
name: Single file
needs: [prepare]
uses: TokTok/ci-tools/.github/workflows/deploy-artifact.yml@master
with:
project-name: toxcore
artifact-source: toxcore-{av,core}.c
artifact-versioned: toxcore-$VERSION-{av,core}.c
build: single-file
run: |
other/deploy/single-file/make_single_file -av >toxcore-av.c
other/deploy/single-file/make_single_file -core >toxcore-core.c
build-tarball:
name: Source tarball
needs: [prepare]
uses: TokTok/ci-tools/.github/workflows/deploy-artifact.yml@master
with:
project-name: toxcore
artifact-source: tox-*.tar.{gz,xz}
artifact-versioned: $VERSION.tar.{gz,xz}
build: tarball
run: |
sudo apt-get install -y --no-install-recommends libsodium-dev
autoreconf -fi
./configure
make dist
for f in tox-*.tar.gz; do
gunzip -c "$f" | xz -z - >"${f%.gz}.xz"
done

View File

@ -98,26 +98,6 @@ jobs:
cache-from: type=registry,ref=toxchat/c-toxcore:fuzzer
cache-to: type=inline
docker-toxcore-js:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
file: other/emscripten/Dockerfile
push: ${{ github.event_name == 'push' }}
tags: toxchat/c-toxcore:wasm
cache-from: type=registry,ref=toxchat/c-toxcore:wasm
cache-to: type=inline
docker-esp32:
runs-on: ubuntu-latest
steps:

17
.github/workflows/draft.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: draft
on:
push:
branches: [master]
pull_request_target:
branches: [master]
types: [opened, reopened, synchronize]
# Cancel old builds when pushing new commits.
concurrency:
group: draft-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
release:
uses: TokTok/ci-tools/.github/workflows/release-drafter.yml@master

View File

@ -5,15 +5,19 @@ on:
branches: [master]
jobs:
build-alpine-s390x:
runs-on: ubuntu-latest
build:
strategy:
fail-fast: false
matrix:
tool: [alpine-s390x, freebsd]
runs-on: ubuntu-22.04
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Build
uses: docker/build-push-action@v5
with:
file: other/docker/alpine-s390x/Dockerfile
file: other/docker/${{ matrix.tool }}/${{ matrix.tool }}.Dockerfile
docker-coverage:
runs-on: ubuntu-latest

View File

@ -1,12 +1,18 @@
name: release
on:
push:
branches: [master]
pull_request_target:
branches: [master]
types: [opened, reopened, synchronize]
issues:
types: [assigned]
concurrency:
group: release-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
release:
uses: TokTok/ci-tools/.github/workflows/release-drafter.yml@master
name: Release
uses: TokTok/ci-tools/.github/workflows/release-deploy.yml@master
with:
production: true
secrets:
TOKEN_RELEASES: ${{ secrets.TOKEN_RELEASES }}

76
.reviewable/completion.js Normal file
View File

@ -0,0 +1,76 @@
// jshint esversion: 6
// This code will check that the pull request has been approved via GitHub
// review approval by a minimum number of reviewers and by all assignees, and
// that no changes were requested by any reviewers. Only reviewers with write
// access to the repository are considered.
//
// This is very similar to GitHub's built-in branch protection option to require
// pull request reviews before merging, but allows for much more flexibility and
// customization.
// dependencies: lodash4
// Helper function to check if a user is a bot.
function isBotAuthor(author) {
return (
author.username.endsWith("[bot]") || author.username.startsWith("toktok-")
);
}
function equals(a) {
return (b) => a === b;
}
// The number of approvals required to merge: at least 2 humans must approve the
// code. If the author is a bot, then 2 approvals are required; otherwise, only
// 1 approval is required (because 1 human wrote the code, so they approve).
let numApprovalsRequired = isBotAuthor(review.pullRequest.author) ? 2 : 1;
const approvals = review.pullRequest.approvals;
let numApprovals = _.filter(approvals, equals("approved")).length;
const numRejections = _.filter(approvals, equals("changes_requested")).length;
const discussionBlockers = _(review.discussions)
.filter((x) => !x.resolved)
.flatMap("participants")
.filter((x) => !x.resolved)
.map((user) => _.pick(user, "username"))
.value();
let pendingReviewers = _(discussionBlockers)
.map((user) => _.pick(user, "username"))
.concat(review.pullRequest.requestedReviewers)
.value();
const required = _.map(review.pullRequest.assignees, "username");
_.pull(required, review.pullRequest.author.username);
if (required.length) {
numApprovalsRequired = _.max([required.length, numApprovalsRequired]);
numApprovals =
_(approvals).pick(required).filter(equals("approved")).size() +
_.min([numApprovals, numApprovalsRequired - required.length]);
pendingReviewers = _(required)
.reject((username) => approvals[username] === "approved")
.reject((username) => pendingReviewers.length && approvals[username])
.map((username) => ({ username }))
.concat(pendingReviewers)
.value();
}
pendingReviewers = _.uniqBy(pendingReviewers, "username");
const description =
(numRejections ? `${numRejections} change requests, ` : "") +
`${numApprovals} of ${numApprovalsRequired} approvals obtained`;
const shortDescription =
(numRejections ? `${numRejections} ✗, ` : "") +
`${numApprovals} of ${numApprovalsRequired}`;
return {
completed: numApprovals >= numApprovalsRequired,
description,
shortDescription,
pendingReviewers,
};

View File

@ -0,0 +1,4 @@
# Reviewable settings file. Read the docs at https://docs.reviewable.io/repositories.html#store-repository-settings-using-the-reviewable-directory
approval-text: ":lgtm_strong:"
github-status:
updates: always

View File

@ -10,6 +10,8 @@ genrule(
"//c-toxcore/toxcore:tox.h",
"//c-toxcore/toxcore:tox_dispatch.h",
"//c-toxcore/toxcore:tox_events.h",
"//c-toxcore/toxcore:tox_log_level.h",
"//c-toxcore/toxcore:tox_options.h",
"//c-toxcore/toxcore:tox_private.h",
"//c-toxcore/toxencryptsave:toxencryptsave.h",
],
@ -18,6 +20,8 @@ genrule(
"tox/tox.h",
"tox/tox_dispatch.h",
"tox/tox_events.h",
"tox/tox_log_level.h",
"tox/tox_options.h",
"tox/tox_private.h",
"tox/toxencryptsave.h",
],
@ -26,6 +30,8 @@ genrule(
cp $(location //c-toxcore/toxcore:tox.h) $(GENDIR)/c-toxcore/tox/tox.h
cp $(location //c-toxcore/toxcore:tox_dispatch.h) $(GENDIR)/c-toxcore/tox/tox_dispatch.h
cp $(location //c-toxcore/toxcore:tox_events.h) $(GENDIR)/c-toxcore/tox/tox_events.h
cp $(location //c-toxcore/toxcore:tox_log_level.h) $(GENDIR)/c-toxcore/tox/tox_log_level.h
cp $(location //c-toxcore/toxcore:tox_options.h) $(GENDIR)/c-toxcore/tox/tox_options.h
cp $(location //c-toxcore/toxcore:tox_private.h) $(GENDIR)/c-toxcore/tox/tox_private.h
cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h
""",

View File

@ -1,6 +1,41 @@
<a name="v0.2.21-rc.1"></a>
## v0.2.21-rc.1 (2025-02-24)
## v0.2.20
### Release notes
Pre-release for toxcore. Primarily, we now have an experimental network profiling callback.
#### Features
- Add a Makefile for the single file deploy build. ([432ab60c](https://github.com/TokTok/c-toxcore/commit/432ab60c0023e3eb2f02db3d54d7d3aec94c4098))
- Implement Tox network profiler ([80fabd4a](https://github.com/TokTok/c-toxcore/commit/80fabd4a72921c555a0e931ce593b216f086733c))
- Add `to_string` functions for toxencryptsave errors. ([d10c966b](https://github.com/TokTok/c-toxcore/commit/d10c966b9985ea1fd479bcb8496a3663d21db0ab))
- implement the last 2 missing network struct functions and make use of them ([ac812871](https://github.com/TokTok/c-toxcore/commit/ac812871a2ec42c37dd7f73bf0f7a6734dfc0bf2))
- Add option to disable DNS lookups in toxcore. ([819aa2b2](https://github.com/TokTok/c-toxcore/commit/819aa2b26182f703855b09ad3dd618786a64c6cb))
- **net:** add missing connect to network struct ([2e94da60](https://github.com/TokTok/c-toxcore/commit/2e94da60d098329b2b78a881865f7602b3ff2728))
#### Performance
- Use stack allocation for strerror rendering. ([f1991aaa](https://github.com/TokTok/c-toxcore/commit/f1991aaa02978a3cb866826d2a5f24ac1e2fdd16))
#### Bug Fixes
- ip to string function not accepting tcp families ([26a991ed](https://github.com/TokTok/c-toxcore/commit/26a991ed2beeb52750258bf43406f039838f439a))
- run `do_gca` also in bootstrap nodes ([9f723f89](https://github.com/TokTok/c-toxcore/commit/9f723f891d3761d317eaaafa82ece42f5a1b0e96))
- Don't crash on malloc failures in `bin_unpack.` ([edb4dfc4](https://github.com/TokTok/c-toxcore/commit/edb4dfc4869bdd1d1048c88842f9e1ae8bcd3c85))
- Fake broadcast address for 127.x.x.x ([d9b8fa60](https://github.com/TokTok/c-toxcore/commit/d9b8fa6098de6c074038b6664d2572627540b148))
- Avoid `memcpy`-ing structs into onion ping id data. ([3cfe41c7](https://github.com/TokTok/c-toxcore/commit/3cfe41c758791ac1a9006ee2241a4fbd8c16db7a))
- Add more information on why the frame was not sent. ([e32ac001](https://github.com/TokTok/c-toxcore/commit/e32ac0019388a5eaaaa91fcf84c1650c8a87f9c5))
- Allow TCP connections to fail `connect` calls. ([ab887003](https://github.com/TokTok/c-toxcore/commit/ab8870036879e766111d6c854408fdee6018f5ed))
- Allow peers to reconnect to group chats using a password ([fc065060](https://github.com/TokTok/c-toxcore/commit/fc0650601c163f9e035de2fce3cc58fab1ad9615))
- reduce memory usage in group chats by 75% Significantly reduced the memory usage of groups since all message slots are preallocated for every peer for send and receive buffers of buffer size (hundreds of MiB peak when save contained alot of peers to try to connect to) ([11ab1d2a](https://github.com/TokTok/c-toxcore/commit/11ab1d2a7232eee19b51ce126ccce267d6578903))
- friend requests with very long messages are no longer dropped ([93aafd78](https://github.com/TokTok/c-toxcore/commit/93aafd78c1ff74ed994426cbe07f031795923d3c))
- windows use of REUSEADDR ([0ac23cee](https://github.com/TokTok/c-toxcore/commit/0ac23cee035cd1b66d81d2603b2464426a32fce7))
<a name="v0.2.20"></a>
## v0.2.20 (2024-11-11)
### Merged PRs:
@ -30,7 +65,21 @@
- [#2692](https://github.com/TokTok/c-toxcore/pull/2692) refactor: Make tox-bootstrapd use bool instead of int
- [#2651](https://github.com/TokTok/c-toxcore/pull/2651) refactor: Make ToxAV independent of toxcore internals.
## v0.2.19
#### Bug Fixes
- Add missing free in `dht_get_nodes_response` event. ([3acef4bf](https://github.com/TokTok/c-toxcore/commit/3acef4bf0441214e232d2bd55126d6268b079f33))
- `friend_connections` leak on allocation failure clean up when it only contains connections in the NONE state ([5f88a084](https://github.com/TokTok/c-toxcore/commit/5f88a084e8c67ea8d8aa733cbb57aabb5082e6d3))
- wrong comment for closelist ([6d27a1ae](https://github.com/TokTok/c-toxcore/commit/6d27a1ae178edc4c2ebb8768bb3c455a6baac467))
- events leak that can occur if allocation fails rare in practice, found by fuzzing ([40676284](https://github.com/TokTok/c-toxcore/commit/4067628450744bb17b8ada1a11ad35480a386012))
- Return an error instead of crashing on nullptr args in NGC. ([9610ac31](https://github.com/TokTok/c-toxcore/commit/9610ac31c5f00f24f137478819d67e3eda832bec))
- Use Opus in the CBR mode ([03e9fbf3](https://github.com/TokTok/c-toxcore/commit/03e9fbf3703e430d21138c4f69e9ac7dbefb7564))
- toxav rtp temp buffer allocation size was too large and cast from 32bit to 16bit, causing a overflow and making the allocated size too small ([671b1f92](https://github.com/TokTok/c-toxcore/commit/671b1f92332a8314dccf76d5df93c0b6c1230636))
- Memory leak in the bootstrap daemon ([5344d7f8](https://github.com/TokTok/c-toxcore/commit/5344d7f84d060311f2147b343cdd3fd4c433d7dd))
- **toxav:** pass video bit rate as kbit Previously we unintentionally made it Mbit. ([55752a2e](https://github.com/TokTok/c-toxcore/commit/55752a2e2ef894bfa6d7a2a21a0278e3f2bede7d))
<a name="v0.2.19"></a>
## v0.2.19 (2024-03-27)
### Merged PRs:
@ -296,7 +345,76 @@
- [#2014](https://github.com/TokTok/c-toxcore/issues/2014) Add sodium autotools CI build
- [#1144](https://github.com/TokTok/c-toxcore/issues/1144) DHT_bootstrap should not link against misc_tools
## v0.2.18
#### Bug Fixes
- flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to. ([b03b5712](https://github.com/TokTok/c-toxcore/commit/b03b5712720de9a9901ea12fd741f177327a7021))
- Disable IPv6 in Windows cross-compilation tests ([b3c3c49d](https://github.com/TokTok/c-toxcore/commit/b3c3c49d26c0cf2b91b9ec69f9a3f932ab9f2d6d))
- Test the current Windows Dockerfile, not an old Dockerhub image ([dfb9a0b0](https://github.com/TokTok/c-toxcore/commit/dfb9a0b02bd16db24cdae2c0af799129cadb1024))
- Remove unnecessary wsock32 dependency on Windows ([e519f799](https://github.com/TokTok/c-toxcore/commit/e519f7998b75ed3701f6b9d6d9cc7cadc428686c))
- Correct type for conference offline peer numbers. ([be82a3ea](https://github.com/TokTok/c-toxcore/commit/be82a3ea303466797c63018e7a1fb04891e59fee))
- `save_compatibility_test` failing on big-endian systems ([9a8dfa06](https://github.com/TokTok/c-toxcore/commit/9a8dfa06abafdac2c478e5c7339d9f9fbb1ab4a2))
- Don't serve files from websockify. ([86f5e555](https://github.com/TokTok/c-toxcore/commit/86f5e55578b13fe44b6822b97a63e9ecd2b63db0))
- Correctly pass extended public keys to group moderation code. ([710eb674](https://github.com/TokTok/c-toxcore/commit/710eb674a50f17201bb7556d389d82d2133d98de))
- Pass array, not array pointer, to `memcmp`. ([c71567dc](https://github.com/TokTok/c-toxcore/commit/c71567dc18515f69111c5af7902bc0357f0cd9ea))
- Correct a few potential null derefs in bootstrap daemon. ([08d3393d](https://github.com/TokTok/c-toxcore/commit/08d3393def4578fc94076e3a25258a809e4b87e7))
- Add missing memunlock of local variable when it goes out of scope. ([b9877b32](https://github.com/TokTok/c-toxcore/commit/b9877b32b0bda719eea19e931f04bac2c96a9ab4))
- Zero out stack-allocated secret key before return. ([dab5fe44](https://github.com/TokTok/c-toxcore/commit/dab5fe44b9070a406a36011df12840fe9e295ff0))
- Fix some false positive from PVS Studio. ([9fe18b17](https://github.com/TokTok/c-toxcore/commit/9fe18b176fb661142c8565d691c5ad9e60125873))
- Don't use `memcmp` to compare `IP_Port`s. ([39aadf89](https://github.com/TokTok/c-toxcore/commit/39aadf8922cc9276cf7f612cb2eb9b243b363210))
- partially fix a bug that prevented group part messages from sending. ([d94246a9](https://github.com/TokTok/c-toxcore/commit/d94246a9061e2af7c02c4edc94156f5e8148bd9a))
- a few off by one errors in group autotests ([203e1af8](https://github.com/TokTok/c-toxcore/commit/203e1af81e48909f0a6647fcbe6fc5d4764187bd))
- dont resolve to ipv6 addresses when its disabled ([001d00ab](https://github.com/TokTok/c-toxcore/commit/001d00ab30a7ec3771babb82bdbf90401a468497))
- Make all the fuzzers work again, and add a test for protodump. ([4cea4f9c](https://github.com/TokTok/c-toxcore/commit/4cea4f9ca457f4122db2c0912b155d8b451f7aa5))
- Remove fatal error for non-erroneous case ([87bcc432](https://github.com/TokTok/c-toxcore/commit/87bcc4322d50d2ae7714e734b6468ef43dd818a7))
- Make sure there's enough space for CONSUME1 in fuzzers. ([812f931d](https://github.com/TokTok/c-toxcore/commit/812f931d5f082f1dd58d4ced54ac088dd5da40cf))
- issues with packet broadcast error reporting ([072e3beb](https://github.com/TokTok/c-toxcore/commit/072e3beb3f41ab9ed7c26a7eb2c44fa1c509db48))
- don't pass garbage data buffer to packet send functions ([ebc96438](https://github.com/TokTok/c-toxcore/commit/ebc964386285f44ab3e0284c4192a5d8e2fe252c))
- Use QueryPerformanceCounter on windows for monotonic time. ([82d82656](https://github.com/TokTok/c-toxcore/commit/82d8265688a3eb13aa045b5d15723ff0ae84461e))
- unpack enum function names in event impl generator ([41dfb1c1](https://github.com/TokTok/c-toxcore/commit/41dfb1c1c050d9f31ae616af68960fbcce576c13))
- Correct a use-after-free and fix some memory leaks. ([425216d9](https://github.com/TokTok/c-toxcore/commit/425216d9eca8b3c2afd48e52c04c6226b920303a))
- also Install header for private/experimental API functions with autotools ([66453439](https://github.com/TokTok/c-toxcore/commit/66453439acf79a35eb46fe66a1c72595e7d0c9ca))
- Enable debug flag for ubsan. ([39833691](https://github.com/TokTok/c-toxcore/commit/3983369103d3dc13ced13803a97783b6376459bf))
- Add missing `htons` call when adding configured TCP relay. ([d1e850c5](https://github.com/TokTok/c-toxcore/commit/d1e850c56c71d6b592a6b28d9319b59d3ed5cc1d))
- Fix memory leak in the error path of loading savedata. ([94cf9d1f](https://github.com/TokTok/c-toxcore/commit/94cf9d1f360ad6339cb8ed87cef651d7ff02e3be))
- always respond to version packets with toxcore version ([06d949a7](https://github.com/TokTok/c-toxcore/commit/06d949a70196e6add3d3dd29de27072b6d048908))
- Ensure we have allocators available for the error paths. ([24b54722](https://github.com/TokTok/c-toxcore/commit/24b54722aed65b02f1e921f08f8d31d68f92a45a))
- Add missing `#include <array>`. ([7469a529](https://github.com/TokTok/c-toxcore/commit/7469a529b126995199ef819d23e484b25895b7f8))
- `resolve_bootstrap_node()` not checking `net_getipport()` returned count correctly doc: improve inline docu of return of `net_getipport` ([88ffd1a6](https://github.com/TokTok/c-toxcore/commit/88ffd1a6495aa59dcd7144b552a91df0bdb5b6d9))
- expand asserts in `fuzz_support.cc` ([d222d708](https://github.com/TokTok/c-toxcore/commit/d222d708b5756a496917f9b7e713a8bc678334f3))
- #1144 by forcing `misc_tools` to be a static lib ([e1c38b40](https://github.com/TokTok/c-toxcore/commit/e1c38b40d6133c22eea8eba8d79d91f8705a6b3a), closes [#1144](https://github.com/TokTok/c-toxcore/issues/1144))
- TCC doesn't now that abort() never returns ([ce36741c](https://github.com/TokTok/c-toxcore/commit/ce36741c65585c91bb718cbfad8fccf177bb6110))
- tcc needs integer as VLA size ([d5de4dc8](https://github.com/TokTok/c-toxcore/commit/d5de4dc8788e1db136fea7f11e56b08a1cd7e09b))
- missmatch between declaration and definition ([26ce30d8](https://github.com/TokTok/c-toxcore/commit/26ce30d8524c178797babaae42e16da4a20c338d))
- potential endless loop under extremely high load ([ad2375ff](https://github.com/TokTok/c-toxcore/commit/ad2375ffe9cfcf5a7bd50bd15deeb598b14f45aa))
- update Python path for AppVeyor ([de975320](https://github.com/TokTok/c-toxcore/commit/de97532064354fb4d24ad74957046c5a6c56d3c5))
- missing net to host conversion of port in logging in `group_chat.c` ([7dfa935a](https://github.com/TokTok/c-toxcore/commit/7dfa935ac8f1c176d9b14c52064a9c9191137981))
- missing net to host conversion of port in logging ([8054854b](https://github.com/TokTok/c-toxcore/commit/8054854b583c4c11c7ceafae4ab2e0e0150c8115))
- unlock correct `dht_friend` ([306693ab](https://github.com/TokTok/c-toxcore/commit/306693aba33505438e4379a27b94607427d23cd3))
- **ci:** window builds now build in parallel ([acdc6738](https://github.com/TokTok/c-toxcore/commit/acdc67387b3dc25de8b618430374d0336feabc2f))
- **test:** tests use ipv6 by default, even with `USE_IPV6` set to 0 ([d3b935f6](https://github.com/TokTok/c-toxcore/commit/d3b935f63f43f9136c7dfa5b11f724a52ae7a4d2))
#### Features
- add message IDs to private group messages ([7b1db6ad](https://github.com/TokTok/c-toxcore/commit/7b1db6adc1d4244aa1ed02b51609d20fba13b90e))
- Check hashes of Windows dependencies when cross-compiling ([e742dedd](https://github.com/TokTok/c-toxcore/commit/e742deddfff13485d2ac3456c26802dc5ac0d2e7))
- Build the fun utils when cross-compiling to Windows ([1be311e5](https://github.com/TokTok/c-toxcore/commit/1be311e51fda9d7b8c8b4d64aec20a38b3d38313))
- Generate .def, .exp and .lib files when building for Windows ([c4fa8f7f](https://github.com/TokTok/c-toxcore/commit/c4fa8f7fb14a45203731f01d46c91d7c20d194d6))
- Let CMake create the dll instead of doing so ourselves ([74bbac53](https://github.com/TokTok/c-toxcore/commit/74bbac5363172c21fd0e60aa74947aecc2a4df22))
- Harden Windows cross-compilation ([246642e9](https://github.com/TokTok/c-toxcore/commit/246642e9aec5b26ca4ea6c28af5e8bb9237fa6d3))
- Add `dht_get_nodes_response` event to the events system. ([16809dc3](https://github.com/TokTok/c-toxcore/commit/16809dc36e82e9fb01f83ecdbff0331386cc13ad))
- add ngc events ([8c35e0fe](https://github.com/TokTok/c-toxcore/commit/8c35e0fefbe84858f4d1ec63ecb451d830dea025))
- Add `to_string` functions for all public enums. ([5f863a54](https://github.com/TokTok/c-toxcore/commit/5f863a54928cee153f2d2f1acfa79dcf6ac0bcd4))
- Enable ubsan on bootstrap nodes. ([90f74968](https://github.com/TokTok/c-toxcore/commit/90f749681954fca1cc17097593eb274ec383ef4b))
- allow for larger incoming NGC packets ([cd34b60f](https://github.com/TokTok/c-toxcore/commit/cd34b60f0fdd648a0c813d20aee731ef1d98779f))
#### Performance
- Slightly reduce bandwidth usage when there are few nodes. ([028b017d](https://github.com/TokTok/c-toxcore/commit/028b017d7920a7b0ebe738cb72f163989cc284c8))
- Add a KVM FreeBSD build on cirrus ci. ([83efb173](https://github.com/TokTok/c-toxcore/commit/83efb17367a852c56f8525c9e0275f05dbe896fa))
<a name="v0.2.18"></a>
## v0.2.18 (2022-04-18)
### Merged PRs:
@ -410,7 +528,33 @@
- [#2012](https://github.com/TokTok/c-toxcore/issues/2012) Support building a DLL on Windows
- [#907](https://github.com/TokTok/c-toxcore/issues/907) use dll abnormal System.AccessViolationException win7 x32 but x64 no problem
## v0.2.17
#### Bug Fixes
- remove the assert because buffer can be larger than `UINT16_MAX.` ([6b0d1151](https://github.com/TokTok/c-toxcore/commit/6b0d1151ac813170fe9aba1f90e0791c05e53399))
- Fix potential array out-of-bounds in DHT random node retrieval. ([d78ee9b1](https://github.com/TokTok/c-toxcore/commit/d78ee9b12e876604712db68746fc6ddf0a4691e0))
- Allow onion paths to be built from more random nodes. ([5073882e](https://github.com/TokTok/c-toxcore/commit/5073882e0f0ea114e4f0efe719a72ecf7b168926))
- really fix overrun added in e49a477a ([417d28d4](https://github.com/TokTok/c-toxcore/commit/417d28d439e344a21e1e7fbad55354c4c8bcb05b))
- Format IP as string again in error log. ([d0728560](https://github.com/TokTok/c-toxcore/commit/d0728560bc308fe2ef5320d12c3e6021f13cc5d7))
- Fix a stack overflow triggered by small DHT packets. ([7a4cc107](https://github.com/TokTok/c-toxcore/commit/7a4cc107c0d9a30b97a53d584c3ab5e3d84a3b47))
- Don't crash if RNG init failed. ([ddda6055](https://github.com/TokTok/c-toxcore/commit/ddda605509091bb0c0a8e79680f42d80ae91a2b8))
- fix typo in git command in INSTALL.md ([3cc72f5f](https://github.com/TokTok/c-toxcore/commit/3cc72f5f577c7a4bbe1ea913ae4ec82a758bf18c))
- Correct calculation of packet sent time ([c38f21f8](https://github.com/TokTok/c-toxcore/commit/c38f21f8884f1ddcd0e93168918c27a08fca8659))
- Eliminate memory leak in toxav. ([28623dcf](https://github.com/TokTok/c-toxcore/commit/28623dcfa979bacbbf338eb5ac32ae71fd9c4984))
- Allow port range in `DHT_bootstrap.c.` ([001aa634](https://github.com/TokTok/c-toxcore/commit/001aa63401821920695e03a69141587c5067082b))
#### Features
- add forwarding and announce request handling ([e49a477a](https://github.com/TokTok/c-toxcore/commit/e49a477a845bfa5fa5dacc7c65f8e0bd38098cb2))
- Add support for custom random number generator. ([cc31ff07](https://github.com/TokTok/c-toxcore/commit/cc31ff07fabda4dde59c201c0a5bd47b8af00498))
- Allow custom network functions. ([f39aac09](https://github.com/TokTok/c-toxcore/commit/f39aac09e614f9b3dfcdbcc2b217ede99bff846f))
#### Performance
- Make time move a lot faster in fuzzing runs. ([e4558a28](https://github.com/TokTok/c-toxcore/commit/e4558a287cd7c8dd3215204aeb25e3df4142cd91))
<a name="v0.2.17"></a>
## v0.2.17 (2022-03-06)
### Merged PRs:
@ -473,7 +617,16 @@
- [#647](https://github.com/TokTok/c-toxcore/issues/647) `tox_bootstrap` should return an error on unrecoverable `getnodes` failure
- [#169](https://github.com/TokTok/c-toxcore/issues/169) Get rid of TOX_USER_STATUS_BUSY + 1
## v0.2.16
#### Bug Fixes
- Report failure to DHT bootstrap back to the client. ([2ce6f5b1](https://github.com/TokTok/c-toxcore/commit/2ce6f5b1694b12a34dea52bf90a7b2e691df4ded))
- Null function pointer dereference. ([b8ce394e](https://github.com/TokTok/c-toxcore/commit/b8ce394e643dad38e067b44e1e8062eaf18b0e86))
- out-of-memory condition by corrupted save file ([fff2b1c4](https://github.com/TokTok/c-toxcore/commit/fff2b1c4e7aae88b90dc26bf1cc71388243e5b62))
- memory leak during conference load ([12dbafbd](https://github.com/TokTok/c-toxcore/commit/12dbafbd188a64356c07c97f7841016b5c300715))
<a name="v0.2.16"></a>
## v0.2.16 (2022-02-18)
### Merged PRs:
@ -542,7 +695,28 @@
- [#236](https://github.com/TokTok/c-toxcore/issues/236) Tox file transfers do not use available bandwidth
- [#128](https://github.com/TokTok/c-toxcore/issues/128) Toxcore should provide an easy, local method for making sure Travis checks will pass
## v0.2.15
#### Bug Fixes
- properly deallocate frozen peers ([fde2a7d1](https://github.com/TokTok/c-toxcore/commit/fde2a7d16d9b47d1dea7038080371edb486a608d))
- Fix return type of functions returning `uint64_t.` ([598a365e](https://github.com/TokTok/c-toxcore/commit/598a365e1f8334b909734e8e2281e2b63dcda023))
- remove bogus asserts in fuzzer harness ([acf85eee](https://github.com/TokTok/c-toxcore/commit/acf85eee465e44dde6d9dab746d02a721cc5268f))
- syntax error introduced in 8bf37994fd12acec9e3010437502f478399b99b4 ([d429d357](https://github.com/TokTok/c-toxcore/commit/d429d35756c4552a7087b963832a6f6b80bf5af7))
- add msgpack dependency to fuzzer build ([7e1aa442](https://github.com/TokTok/c-toxcore/commit/7e1aa442ef3a965afafee799551755f9b43589ed))
- Fix Conan build link failures ([b64825b3](https://github.com/TokTok/c-toxcore/commit/b64825b3894cd11f8d6be25792c92b75144f4b9a))
#### Performance
- Reduce minimal encoding size of packed events. ([a3cd1102](https://github.com/TokTok/c-toxcore/commit/a3cd1102f77884f3e384715a5d4efd38d48aaac7))
#### Features
- Add unpacker functions for events structures. ([cb8b9bba](https://github.com/TokTok/c-toxcore/commit/cb8b9bbabfc8b669226cddcbe985b82909fdad22))
- Add binary packing functions for tox events. ([0a2190f2](https://github.com/TokTok/c-toxcore/commit/0a2190f28cad0beadb9d9b4b1da2d7f538ca9d7d))
- Add async event handling (callbacks) code. ([de4af4c2](https://github.com/TokTok/c-toxcore/commit/de4af4c2703228bdeb5468be1d9d6771092b2dad))
<a name="v0.2.15"></a>
## v0.2.15 (2022-02-06)
### Merged PRs:
@ -550,7 +724,14 @@
- [#1983](https://github.com/TokTok/c-toxcore/pull/1983) chore: Release 0.2.15
- [#1980](https://github.com/TokTok/c-toxcore/pull/1980) fix: Reduce logging verbosity in TCP server.
## v0.2.14
#### Bug Fixes
- Reduce logging verbosity even more. ([79eb17ae](https://github.com/TokTok/c-toxcore/commit/79eb17aeac5f55ec866e2c52b3023fa5a971bfc4))
- Reduce logging verbosity in TCP server. ([fedcdea9](https://github.com/TokTok/c-toxcore/commit/fedcdea95a2d1b97ee99d19c67cac4174f1dc945))
<a name="v0.2.14"></a>
## v0.2.14 (2022-02-05)
### Merged PRs:
@ -727,7 +908,26 @@
- [#106](https://github.com/TokTok/c-toxcore/issues/106) Sometimes Toxcore reports the wrong connection status for both the DHT, and friends.
- [#85](https://github.com/TokTok/c-toxcore/issues/85) Reproducible Builds // OBS a bad Idea
## v0.2.13
#### Features
- Add WASM build for toxcore and websocket bootstrap node. ([71965a0f](https://github.com/TokTok/c-toxcore/commit/71965a0f3b52b4e26a52128a0c98947c2276f15b))
#### Bug Fixes
- Fix bootstrap on emscripten/wasm. ([727982d2](https://github.com/TokTok/c-toxcore/commit/727982d2f953ae4aa91c0b0a5cc9369ccde1bfbb))
- Fix `toxav_basic_test` buffer overflow. ([28b5e512](https://github.com/TokTok/c-toxcore/commit/28b5e512a2487f215aac215a43d542c601c2022d))
- don't count filetransfer as sending until accepted ([2073d02c](https://github.com/TokTok/c-toxcore/commit/2073d02c33a2bc8478099c66985f2a69854ecaf5))
- Fix some uninitialised memory errors found by valgrind and msan. ([4a2cb37e](https://github.com/TokTok/c-toxcore/commit/4a2cb37e4bc2749d275da7a7516905d93bd61fd6))
- use correct sample size in `toxav_basic_test` ([d2bf7247](https://github.com/TokTok/c-toxcore/commit/d2bf72479cad275cf2b685304483a0bdde7b2385))
- Fixed uninitialised value copy. ([e30266f1](https://github.com/TokTok/c-toxcore/commit/e30266f1ce7538d932a92514f29e1233d68ee337))
#### Performance
- improve speed of cracker.c ([828312c2](https://github.com/TokTok/c-toxcore/commit/828312c2f9bbbbfb7084aa63374d573f2ac87e00))
<a name="v0.2.13"></a>
## v0.2.13 (2021-12-06)
### Merged PRs:
@ -788,7 +988,13 @@
- [#1149](https://github.com/TokTok/c-toxcore/issues/1149) uTox aborts on toxcore restart
- [#886](https://github.com/TokTok/c-toxcore/issues/886) Maybe need to set the stacksize for musl-libc
## v0.2.12
#### Performance
- reduce calling into `Mono_Time` in DHT ([0c320462](https://github.com/TokTok/c-toxcore/commit/0c320462d713b2741045e56df4487cfad559c05e))
<a name="v0.2.12"></a>
## v0.2.12 (2020-05-01)
### Merged PRs:
@ -834,7 +1040,9 @@
- [#1353](https://github.com/TokTok/c-toxcore/issues/1353) libtoxdns.a and libtoxav.a
- [#86](https://github.com/TokTok/c-toxcore/issues/86) Freenet as Offline Messaging Backend
## v0.2.11
<a name="v0.2.11"></a>
## v0.2.11 (2020-03-22)
### Merged PRs:
@ -894,7 +1102,9 @@
- [#1274](https://github.com/TokTok/c-toxcore/issues/1274) build error
- [#850](https://github.com/TokTok/c-toxcore/issues/850) GPG App Usage
## v0.2.10
<a name="v0.2.10"></a>
## v0.2.10 (2019-05-30)
### Merged PRs:
@ -918,7 +1128,9 @@
- [#1261](https://github.com/TokTok/c-toxcore/issues/1261) Bump so version
- [#1116](https://github.com/TokTok/c-toxcore/issues/1116) Message length is too large log spam
## v0.2.9
<a name="v0.2.9"></a>
## v0.2.9 (2019-01-12)
### Merged PRs:
@ -987,7 +1199,9 @@
- [#548](https://github.com/TokTok/c-toxcore/issues/548) toxcore removes message receipts and filetransfers from memory, when client has short network outage
- [#375](https://github.com/TokTok/c-toxcore/issues/375) Invalid bit rate prevents call
## v0.2.8
<a name="v0.2.8"></a>
## v0.2.8 (2018-10-07)
### Merged PRs:
@ -1042,7 +1256,9 @@
- [#960](https://github.com/TokTok/c-toxcore/issues/960) Persistent groups don't work properly when using toxync bot
- [#838](https://github.com/TokTok/c-toxcore/issues/838) How to get groupchat identifier?
## v0.2.7
<a name="v0.2.7"></a>
## v0.2.7 (2018-08-30)
### Merged PRs:
@ -1091,7 +1307,9 @@
- [#1114](https://github.com/TokTok/c-toxcore/issues/1114) Segfault on group quit, free of invalid audio_decoder
- [#1105](https://github.com/TokTok/c-toxcore/issues/1105) Sodium.h missing?
## v0.2.6
<a name="v0.2.6"></a>
## v0.2.6 (2018-08-16)
### Merged PRs:
@ -1130,7 +1348,9 @@
- [#1036](https://github.com/TokTok/c-toxcore/pull/1036) Add deprecation notice to some UPPER_CASE enums.
- [#1016](https://github.com/TokTok/c-toxcore/pull/1016) Split out conference type (text/av) from identifier.
## v0.2.5
<a name="v0.2.5"></a>
## v0.2.5 (2018-08-08)
### Merged PRs:
@ -1159,7 +1379,9 @@
- [#1028](https://github.com/TokTok/c-toxcore/issues/1028) qTox crashes 1-2 times a day after update to 0.2.4
- [#1002](https://github.com/TokTok/c-toxcore/issues/1002) Implement an abstraction over pthread and windows thread synchronisation primitives
## v0.2.4
<a name="v0.2.4"></a>
## v0.2.4 (2018-07-20)
### Merged PRs:
@ -1231,7 +1453,9 @@
- [#450](https://github.com/TokTok/c-toxcore/issues/450) Run format-test earlier in the build
- [#429](https://github.com/TokTok/c-toxcore/issues/429) Cannot build on Windows using MinGW
## v0.2.3
<a name="v0.2.3"></a>
## v0.2.3 (2018-06-25)
### Merged PRs:
@ -1287,7 +1511,9 @@
- [#879](https://github.com/TokTok/c-toxcore/issues/879) DHT_bootstrap asserts due to no default logger
- [#868](https://github.com/TokTok/c-toxcore/issues/868) A tox_friend_connection_status event often occurs
## v0.2.2
<a name="v0.2.2"></a>
## v0.2.2 (2018-04-17)
### Merged PRs:
@ -1312,7 +1538,9 @@
- [#873](https://github.com/TokTok/c-toxcore/issues/873) Onion vulnerability
- [#786](https://github.com/TokTok/c-toxcore/issues/786) Make format strings msvc/mingw-happy
## v0.2.1
<a name="v0.2.1"></a>
## v0.2.1 (2018-03-10)
### Merged PRs:
@ -1323,7 +1551,9 @@
- [#831](https://github.com/TokTok/c-toxcore/pull/831) Don't throw away rtp packets from old Toxcore
- [#828](https://github.com/TokTok/c-toxcore/pull/828) Make file transfers 50% faster.
## v0.2.0
<a name="v0.2.0"></a>
## v0.2.0 (2018-02-28)
### Merged PRs:
@ -1478,7 +1708,9 @@
- [#383](https://github.com/TokTok/c-toxcore/issues/383) TODO: add cmake instructions in README.md
- [#42](https://github.com/TokTok/c-toxcore/issues/42) Remove ToxDNS and related stuff from toxcore
## v0.1.11
<a name="v0.1.11"></a>
## v0.1.11 (2017-12-27)
### Merged PRs:
@ -1509,7 +1741,9 @@
- [#240](https://github.com/TokTok/c-toxcore/issues/240) Tox doesn't reconnect after internet connection interruption
- [#237](https://github.com/TokTok/c-toxcore/issues/237) Contacts are shown offline when they are online
## v0.1.10
<a name="v0.1.10"></a>
## v0.1.10 (2017-08-16)
### Merged PRs:
@ -1517,7 +1751,9 @@
- [#564](https://github.com/TokTok/c-toxcore/pull/564) Fix Windows build
- [#542](https://github.com/TokTok/c-toxcore/pull/542) Save bandwidth by moderating onion pinging
## v0.1.9
<a name="v0.1.9"></a>
## v0.1.9 (2017-06-06)
### Merged PRs:
@ -1548,7 +1784,9 @@
- [#482](https://github.com/TokTok/c-toxcore/issues/482) CMake can't detect and compile ToxAV on OSX
## v0.1.8
<a name="v0.1.8"></a>
## v0.1.8 (2017-04-28)
### Merged PRs:
@ -1570,7 +1808,9 @@
- [#456](https://github.com/TokTok/c-toxcore/issues/456) Tox.h doesn't expose the size of the nospam.
- [#411](https://github.com/TokTok/c-toxcore/issues/411) Reduce CTest timeout to 2 minutes
## v0.1.7
<a name="v0.1.7"></a>
## v0.1.7 (2017-03-26)
### Merged PRs:
@ -1597,7 +1837,9 @@
- [#494](https://github.com/TokTok/c-toxcore/issues/494) Format networking code introduced by #461
- [#474](https://github.com/TokTok/c-toxcore/issues/474) TOX_VERSION_PATCH isn't in sync with the version
## v0.1.6
<a name="v0.1.6"></a>
## v0.1.6 (2017-01-27)
### Merged PRs:
@ -1614,7 +1856,9 @@
- [#457](https://github.com/TokTok/c-toxcore/issues/457) EPOLLRDHUP not defined in android ndk on lower API that 21
- [#415](https://github.com/TokTok/c-toxcore/issues/415) Set up a native windows build on appveyor
## v0.1.5
<a name="v0.1.5"></a>
## v0.1.5 (2017-01-19)
### Merged PRs:
@ -1633,7 +1877,9 @@
- [#413](https://github.com/TokTok/c-toxcore/issues/413) Support C compilation with `-std=c99` in autotools
## v0.1.4
<a name="v0.1.4"></a>
## v0.1.4 (2017-01-13)
### Merged PRs:
@ -1664,7 +1910,9 @@
- [#364](https://github.com/TokTok/c-toxcore/issues/364) Delete misc_tools.h after replacing its use by qsort.
- [#363](https://github.com/TokTok/c-toxcore/issues/363) Test against NaCl in addition to libsodium on Travis.
## v0.1.3
<a name="v0.1.3"></a>
## v0.1.3 (2017-01-06)
### Merged PRs:
@ -1686,7 +1934,9 @@
- [#347](https://github.com/TokTok/c-toxcore/issues/347) Implement our own secure `memcmp` and `memzero` if libsodium isn't available
- [#319](https://github.com/TokTok/c-toxcore/issues/319) toxcore installs `DHT_bootstrap` even though `--disable-daemon` is passed to `./configure`
## v0.1.2
<a name="v0.1.2"></a>
## v0.1.2 (2016-12-23)
### Merged PRs:
@ -1705,7 +1955,9 @@
- [#342](https://github.com/TokTok/c-toxcore/issues/342) Wrap all libsodium functions we use in toxcore in `crypto_core`.
- [#278](https://github.com/TokTok/c-toxcore/issues/278) ToxAV use-after-free bug
## v0.1.1
<a name="v0.1.1"></a>
## v0.1.1 (2016-12-17)
### Merged PRs:
@ -1722,7 +1974,9 @@
- [#327](https://github.com/TokTok/c-toxcore/issues/327) The `TOX_VERSION_REQUIRE` macro is broken.
- [#221](https://github.com/TokTok/c-toxcore/issues/221) Option to disable local peer detection
## v0.1.0
<a name="v0.1.0"></a>
## v0.1.0 (2016-12-14)
### Merged PRs:
@ -1753,7 +2007,9 @@
- [#266](https://github.com/TokTok/c-toxcore/issues/266) Support all levels listed in TOX_DHT_NAT_LEVEL
- [#216](https://github.com/TokTok/c-toxcore/issues/216) When v0.1 release?
## v0.0.5
<a name="v0.0.5"></a>
## v0.0.5 (2016-11-25)
### Merged PRs:
@ -1776,7 +2032,9 @@
- [#215](https://github.com/TokTok/c-toxcore/issues/215) The current tox save format is non-portable
- [#205](https://github.com/TokTok/c-toxcore/issues/205) nospam value is reversed in array returned by `tox_self_get_address()`
## v0.0.4
<a name="v0.0.4"></a>
## v0.0.4 (2016-11-14)
### Merged PRs:
@ -1791,7 +2049,9 @@
- [#248](https://github.com/TokTok/c-toxcore/pull/248) Remove new_nonce function in favour of random_nonce.
- [#224](https://github.com/TokTok/c-toxcore/pull/224) Add DHT_create_packet, an abstraction for DHT RPC packets
## v0.0.3
<a name="v0.0.3"></a>
## v0.0.3 (2016-11-07)
### Merged PRs:
@ -1816,7 +2076,9 @@
- [#40](https://github.com/TokTok/c-toxcore/issues/40) Stateless callbacks in toxcore's public API
## v0.0.2
<a name="v0.0.2"></a>
## v0.0.2 (2016-10-30)
### Merged PRs:
@ -1843,7 +2105,9 @@
- [#201](https://github.com/TokTok/c-toxcore/issues/201) Logging callback was broken
## v0.0.1
<a name="v0.0.1"></a>
## v0.0.1 (2016-10-01)
### Merged PRs:
@ -1965,3 +2229,9 @@
- [#9](https://github.com/TokTok/c-toxcore/issues/9) Fix the failing test
- [#8](https://github.com/TokTok/c-toxcore/issues/8) Toxcore should make more liberal use of assertions
- [#4](https://github.com/TokTok/c-toxcore/issues/4) Integrate hstox tests with toxcore Travis build
#### Bug Fixes
- replace memset with `sodium_memzero` for sensitive data ([23b0c9cd](https://github.com/TokTok/c-toxcore/commit/23b0c9cdedae01b09055a0476823e225680d3930))
- compare sensitive data with `sodium_memcmp` fix: make `increment_nonce` & `increment_nonce_number` independent of user-controlled input fix: make `crypto_core` more stable agains null ptr dereference ([ed3a794c](https://github.com/TokTok/c-toxcore/commit/ed3a794c9bf6380801ee21c816505f457b6a1348))
- bad memset length in `ip_init()` ([f267266b](https://github.com/TokTok/c-toxcore/commit/f267266bf611570c6e79dfb800e97396151ff870))

View File

@ -44,7 +44,7 @@ set_source_files_properties(
# versions in a synchronised way.
set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "2")
set(PROJECT_VERSION_PATCH "20")
set(PROJECT_VERSION_PATCH "21")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
# set .so library version / following libtool scheme
@ -238,7 +238,7 @@ set(toxcore_SOURCES
toxcore/events/conference_peer_list_changed.c
toxcore/events/conference_peer_name.c
toxcore/events/conference_title.c
toxcore/events/dht_get_nodes_response.c
toxcore/events/dht_nodes_response.c
toxcore/events/events_alloc.c
toxcore/events/events_alloc.h
toxcore/events/file_chunk_request.c
@ -341,13 +341,17 @@ set(toxcore_SOURCES
toxcore/timed_auth.h
toxcore/tox_api.c
toxcore/tox.c
toxcore/tox.h
toxcore/tox_dispatch.c
toxcore/tox_dispatch.h
toxcore/tox_event.c
toxcore/tox_event.h
toxcore/tox_events.c
toxcore/tox_events.h
toxcore/tox.h
toxcore/tox_log_level.c
toxcore/tox_log_level.h
toxcore/tox_options.c
toxcore/tox_options.h
toxcore/tox_private.c
toxcore/tox_private.h
toxcore/tox_pack.c
@ -369,10 +373,12 @@ endif()
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
set(toxcore_API_HEADERS
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox)
${toxcore_SOURCE_DIR}/toxcore/tox_log_level.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox)
if(EXPERIMENTAL_API)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)
endif()

View File

@ -48,7 +48,7 @@ auto_test(conference_simple)
auto_test(conference_two)
auto_test(crypto)
#auto_test(dht) # Doesn't work with UNITY_BUILD.
auto_test(dht_getnodes_api)
auto_test(dht_nodes_response_api)
auto_test(encryptsave)
auto_test(file_saving)
auto_test(file_streaming)

View File

@ -271,7 +271,7 @@ static void kill_tcp_con(struct sec_TCP_con *con)
free(con);
}
static int write_packet_tcp_test_connection(const Logger *logger, struct sec_TCP_con *con, const uint8_t *data,
static int write_packet_tcp_test_connection(const Logger *logger, const Memory *mem, struct sec_TCP_con *con, const uint8_t *data,
uint16_t length)
{
const uint16_t packet_size = sizeof(uint16_t) + length + CRYPTO_MAC_SIZE;
@ -338,9 +338,9 @@ static void test_some(void)
// Sending wrong public keys to test server response.
memcpy(requ_p + 1, con3->public_key, CRYPTO_PUBLIC_KEY_SIZE);
write_packet_tcp_test_connection(logger, con1, requ_p, sizeof(requ_p));
write_packet_tcp_test_connection(logger, mem, con1, requ_p, sizeof(requ_p));
memcpy(requ_p + 1, con1->public_key, CRYPTO_PUBLIC_KEY_SIZE);
write_packet_tcp_test_connection(logger, con3, requ_p, sizeof(requ_p));
write_packet_tcp_test_connection(logger, mem, con3, requ_p, sizeof(requ_p));
do_tcp_server_delay(tcp_s, mono_time, 50);
@ -362,9 +362,9 @@ static void test_some(void)
const uint8_t test_packet[512] = {16, 17, 16, 86, 99, 127, 255, 189, 78}; // What is this packet????
write_packet_tcp_test_connection(logger, con3, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, con3, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, con3, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, mem, con3, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, mem, con3, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, mem, con3, test_packet, sizeof(test_packet));
do_tcp_server_delay(tcp_s, mono_time, 50);
@ -388,9 +388,9 @@ static void test_some(void)
ck_assert_msg(len == sizeof(test_packet), "wrong len %d", len);
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
write_packet_tcp_test_connection(logger, con1, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, con1, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, con1, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, mem, con1, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, mem, con1, test_packet, sizeof(test_packet));
write_packet_tcp_test_connection(logger, mem, con1, test_packet, sizeof(test_packet));
do_tcp_server_delay(tcp_s, mono_time, 50);
len = read_packet_sec_tcp(logger, con3, data, 2 + sizeof(test_packet) + CRYPTO_MAC_SIZE);
ck_assert_msg(len == sizeof(test_packet), "wrong len %d", len);
@ -405,8 +405,8 @@ static void test_some(void)
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
uint8_t ping_packet[1 + sizeof(uint64_t)] = {TCP_PACKET_PING, 8, 6, 9, 67};
write_packet_tcp_test_connection(logger, con1, ping_packet, sizeof(ping_packet));
const uint8_t ping_packet[1 + sizeof(uint64_t)] = {TCP_PACKET_PING, 8, 6, 9, 67};
write_packet_tcp_test_connection(logger, mem, con1, ping_packet, sizeof(ping_packet));
do_tcp_server_delay(tcp_s, mono_time, 50);

View File

@ -1,12 +1,11 @@
/**
* This autotest creates a small local DHT and makes sure that each peer can crawl
* the entire DHT using the DHT getnodes api functions.
* the entire DHT using the DHT nodes request/response api functions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "../toxcore/tox.h"
#include "../toxcore/tox_private.h"
@ -72,16 +71,16 @@ static bool all_nodes_crawled(const AutoTox *autotoxes, uint32_t num_toxes, uint
return true;
}
static void getnodes_response_cb(const Tox_Event_Dht_Get_Nodes_Response *event, void *user_data)
static void nodes_response_cb(const Tox_Event_Dht_Nodes_Response *event, void *user_data)
{
ck_assert(user_data != nullptr);
AutoTox *autotox = (AutoTox *)user_data;
State *state = (State *)autotox->state;
const uint8_t *public_key = tox_event_dht_get_nodes_response_get_public_key(event);
const char *ip = (const char *)tox_event_dht_get_nodes_response_get_ip(event);
const uint16_t port = tox_event_dht_get_nodes_response_get_port(event);
const uint8_t *public_key = tox_event_dht_nodes_response_get_public_key(event);
const char *ip = (const char *)tox_event_dht_nodes_response_get_ip(event);
const uint16_t port = tox_event_dht_nodes_response_get_port(event);
if (node_crawled(state->nodes, state->num_nodes, public_key)) {
return;
@ -101,11 +100,11 @@ static void getnodes_response_cb(const Tox_Event_Dht_Get_Nodes_Response *event,
// ask new node to give us their close nodes to every public key
for (size_t i = 0; i < NUM_TOXES; ++i) {
tox_dht_get_nodes(autotox->tox, public_key, ip, port, state->public_key_list[i], nullptr);
tox_dht_send_nodes_request(autotox->tox, public_key, ip, port, state->public_key_list[i], nullptr);
}
}
static void test_dht_getnodes(AutoTox *autotoxes)
static void test_dht_nodes_request(AutoTox *autotoxes)
{
ck_assert(NUM_TOXES >= 2);
@ -125,7 +124,7 @@ static void test_dht_getnodes(AutoTox *autotoxes)
ck_assert(public_key_list[i] != nullptr);
tox_self_get_dht_id(autotoxes[i].tox, public_key_list[i]);
tox_events_callback_dht_get_nodes_response(autotoxes[i].dispatch, getnodes_response_cb);
tox_events_callback_dht_nodes_response(autotoxes[i].dispatch, nodes_response_cb);
printf("Peer %zu dht closenode count total/announce-capable: %d/%d\n",
i,
@ -153,7 +152,7 @@ int main(void)
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, NUM_TOXES, test_dht_getnodes, sizeof(State), &options);
run_auto_test(nullptr, NUM_TOXES, test_dht_nodes_request, sizeof(State), &options);
return 0;
}

View File

@ -13,11 +13,13 @@
#include <stdlib.h>
#include <string.h>
#include "../testing/misc_tools.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/tox.h"
#include "auto_test_support.h"
#include "check_compat.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/tox.h"
#include "../toxencryptsave/toxencryptsave.h"
static const char *pphrase = "bar";
@ -27,21 +29,26 @@ static const char *savefile = "./save";
static void save_data_encrypted(void)
{
struct Tox_Options *options = tox_options_new(nullptr);
ck_assert(options != nullptr);
Tox *t = tox_new_log(options, nullptr, nullptr);
ck_assert(t != nullptr);
tox_options_free(options);
tox_self_set_name(t, (const uint8_t *)name, strlen(name), nullptr);
FILE *f = fopen(savefile, "wb");
ck_assert(f != nullptr);
size_t size = tox_get_savedata_size(t);
uint8_t *clear = (uint8_t *)malloc(size);
ck_assert(clear != nullptr);
/*this function does not write any data at all*/
tox_get_savedata(t, clear);
size += TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
uint8_t *cipher = (uint8_t *)malloc(size);
ck_assert(cipher != nullptr);
Tox_Err_Encryption eerr;
@ -66,11 +73,12 @@ static void load_data_decrypted(void)
int64_t size = ftell(f);
fseek(f, 0, SEEK_SET);
ck_assert_msg(0 <= size && size <= UINT_MAX, "file size out of range");
ck_assert_msg(TOX_PASS_ENCRYPTION_EXTRA_LENGTH <= size && size <= UINT_MAX, "file size out of range");
uint8_t *cipher = (uint8_t *)malloc(size);
ck_assert(cipher != nullptr);
uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
const size_t clear_size = size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
uint8_t *clear = (uint8_t *)malloc(clear_size);
ck_assert(clear != nullptr);
size_t read_value = fread(cipher, sizeof(*cipher), size, f);
printf("Read read_value = %u of %u\n", (unsigned)read_value, (unsigned)size);
@ -78,23 +86,23 @@ static void load_data_decrypted(void)
Tox_Err_Decryption derr;
ck_assert_msg(tox_pass_decrypt(cipher, size, (const uint8_t *)pphrase, strlen(pphrase), clear, &derr),
"Could not decrypt, error code %d.", derr);
"Could not decrypt, error code %s.", tox_err_decryption_to_string(derr));
struct Tox_Options *options = tox_options_new(nullptr);
ck_assert(options != nullptr);
tox_options_set_experimental_owned_data(options, true);
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
tox_options_set_savedata_data(options, clear, size);
ck_assert(tox_options_set_savedata_data(options, clear, clear_size));
free(clear);
Tox_Err_New err;
Tox *t = tox_new_log(options, &err, nullptr);
ck_assert_msg(t != nullptr, "tox_new returned the error value %s", tox_err_new_to_string(err));
tox_options_free(options);
ck_assert_msg(t != nullptr, "tox_new returned the error value %d", err);
uint8_t *readname = (uint8_t *)malloc(tox_self_get_name_size(t));
ck_assert(readname != nullptr);
tox_self_get_name(t, readname);
@ -103,7 +111,6 @@ static void load_data_decrypted(void)
"name returned by tox_self_get_name does not match expected result");
tox_kill(t);
free(clear);
free(cipher);
free(readname);
fclose(f);

View File

@ -1,7 +1,5 @@
#include <stdlib.h>
#include <string.h>
#include "../testing/misc_tools.h"
#include "../toxcore/network.h"
#include "check_compat.h"
@ -34,9 +32,8 @@ static void test_addr_resolv_localhost(void)
bool res = addr_resolve_or_parse_ip(ns, mem, localhost, &ip, nullptr, true);
int error = net_error();
char *strerror = net_new_strerror(error);
ck_assert_msg(res, "Resolver failed: %d, %s", error, strerror);
net_kill_strerror(strerror);
Net_Strerror error_str;
ck_assert_msg(res, "Resolver failed: %d, %s", error, net_strerror(error, &error_str));
Ip_Ntoa ip_str;
ck_assert_msg(net_family_is_ipv4(ip.family), "Expected family TOX_AF_INET, got %u.", ip.family.value);
@ -57,9 +54,7 @@ static void test_addr_resolv_localhost(void)
}
error = net_error();
strerror = net_new_strerror(error);
ck_assert_msg(res, "Resolver failed: %d, %s", error, strerror);
net_kill_strerror(strerror);
ck_assert_msg(res, "Resolver failed: %d, %s", error, net_strerror(error, &error_str));
ck_assert_msg(net_family_is_ipv6(ip.family), "Expected family TOX_AF_INET6 (%d), got %u.", TOX_AF_INET6,
ip.family.value);
@ -80,9 +75,7 @@ static void test_addr_resolv_localhost(void)
ip_reset(&extra);
res = addr_resolve_or_parse_ip(ns, mem, localhost, &ip, &extra, true);
error = net_error();
strerror = net_new_strerror(error);
ck_assert_msg(res, "Resolver failed: %d, %s", error, strerror);
net_kill_strerror(strerror);
ck_assert_msg(res, "Resolver failed: %d, %s", error, net_strerror(error, &error_str));
#if USE_IPV6
ck_assert_msg(net_family_is_ipv6(ip.family), "Expected family TOX_AF_INET6 (%d), got %u.", TOX_AF_INET6,

View File

@ -60,7 +60,7 @@ int main(int argc, char **argv)
c_sleep(100);
}
const uint16_t tcp_port = 8082;
const uint16_t tcp_port = 7082;
uint32_t index[] = { 1, 2, 3, 4 };
struct Tox_Options *tox_options = tox_options_new(nullptr);
@ -92,7 +92,7 @@ int main(int argc, char **argv)
// tox3 has UDP disabled and connects to tox1 via an HTTP proxy
tox_options_set_udp_enabled(tox_options, false);
tox_options_set_proxy_host(tox_options, "127.0.0.1");
tox_options_set_proxy_port(tox_options, 8080);
tox_options_set_proxy_port(tox_options, 7080);
tox_options_set_proxy_type(tox_options, TOX_PROXY_TYPE_HTTP);
Tox *tox3 = tox_new_log(tox_options, nullptr, &index[2]);
@ -101,7 +101,7 @@ int main(int argc, char **argv)
// tox4 has UDP disabled and connects to tox1 via a SOCKS5 proxy
tox_options_set_udp_enabled(tox_options, false);
tox_options_set_proxy_host(tox_options, "127.0.0.1");
tox_options_set_proxy_port(tox_options, 8081);
tox_options_set_proxy_port(tox_options, 7081);
tox_options_set_proxy_type(tox_options, TOX_PROXY_TYPE_SOCKS5);
Tox *tox4 = tox_new_log(tox_options, nullptr, &index[3]);

View File

@ -20,8 +20,10 @@ endmacro()
function(_make_version_script target)
set(${target}_VERSION_SCRIPT "${CMAKE_BINARY_DIR}/${target}.ld")
if(NOT APPLE)
file(WRITE ${${target}_VERSION_SCRIPT}
"{ global:\n")
endif()
foreach(sublib ${ARGN})
string(REPLACE "^" ";" sublib ${sublib})
@ -32,24 +34,40 @@ function(_make_version_script target)
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '[a-z0-9_]+' | sort -u"
OUTPUT_VARIABLE sublib_SYMS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${sublib_SYMS}" STREQUAL "")
continue()
endif()
string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})
foreach(sym ${sublib_SYMS})
file(APPEND ${${target}_VERSION_SCRIPT}
"${sym};\n")
if(APPLE)
file(APPEND ${${target}_VERSION_SCRIPT} "_")
endif()
file(APPEND ${${target}_VERSION_SCRIPT} "${sym}")
if(NOT APPLE)
file(APPEND ${${target}_VERSION_SCRIPT} ";")
endif()
file(APPEND ${${target}_VERSION_SCRIPT} "\n")
endforeach(sym)
endforeach(sublib)
if(NOT APPLE)
file(APPEND ${${target}_VERSION_SCRIPT}
"local: *; };\n")
endif()
if(APPLE)
set_target_properties(${target}_shared PROPERTIES
LINK_FLAGS -Wl,-exported_symbols_list,${${target}_VERSION_SCRIPT})
else()
set_target_properties(${target}_shared PROPERTIES
LINK_FLAGS -Wl,--version-script,${${target}_VERSION_SCRIPT})
endif()
endfunction()
option(STRICT_ABI "Enforce strict ABI export in dynamic libraries" OFF)
if((WIN32 AND NOT MINGW) OR APPLE)
# Windows and macOS don't have this linker functionality.
if(WIN32 AND NOT MINGW)
# Windows doesn't have this linker functionality.
set(STRICT_ABI OFF)
endif()

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([tox], [0.2.20])
AC_INIT([tox], [0.2.21])
AC_CONFIG_AUX_DIR(configure_aux)
AC_CONFIG_SRCDIR([toxcore/net_crypto.c])
AM_INIT_AUTOMAKE([foreign 1.10 -Wall -Werror subdir-objects tar-ustar])

View File

@ -262,6 +262,8 @@ int main(int argc, char *argv[])
last_lan_discovery = mono_time_get(mono_time);
}
do_gca(mono_time, gc_announces_list);
#ifdef TCP_RELAY_ENABLED
do_tcp_server(tcp_s, mono_time);
#endif

View File

@ -1 +1 @@
9ec2993a28988bd147bf8f4f21a824c2fc5dbf7255e391b3ce517d337ebce5c1 /usr/local/bin/tox-bootstrapd
abd103553021d86f54c874fe582001f28372b4e56502421955552117ac5f7b3b /usr/local/bin/tox-bootstrapd

View File

@ -595,6 +595,8 @@ int main(int argc, char *argv[])
last_lan_discovery = mono_time_get(mono_time);
}
do_gca(mono_time, group_announce);
if (enable_tcp_relay) {
do_tcp_server(tcp_server, mono_time);
}

View File

@ -1,5 +1,7 @@
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@ -17,6 +19,7 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

View File

@ -8,6 +8,7 @@
// - Proper logging.
// - Proper error handling in general.
// - Support both websocket and regular GET requests on /.
// - Write logs in the standard Tox format.
//
// Copyright 2022-2025 The TokTok team.
// Copyright 2021 Michael.liu.
@ -22,6 +23,9 @@ import (
"log"
"net"
"net/http"
"os"
"regexp"
"strings"
"github.com/gorilla/websocket"
)
@ -31,10 +35,12 @@ var (
targetAddr = flag.String("t", "127.0.0.1:5900", "tcp service address")
)
var upgrader = websocket.Upgrader{
// Should be enough to fit any Tox TCP packets.
ReadBufferSize: 2048,
WriteBufferSize: 2048,
const bufferSize = 2048
var upgrader = websocket.Upgrader{
ReadBufferSize: bufferSize,
WriteBufferSize: bufferSize,
Subprotocols: []string{"binary"},
CheckOrigin: func(r *http.Request) bool {
return true
@ -42,7 +48,7 @@ var upgrader = websocket.Upgrader{
}
func forwardTCP(wsconn *websocket.Conn, conn net.Conn) {
var tcpbuffer [2048]byte
var tcpbuffer [bufferSize]byte
defer wsconn.Close()
defer conn.Close()
for {
@ -97,7 +103,52 @@ func serveWs(w http.ResponseWriter, r *http.Request) {
}
type logEntry struct {
time string
file string
line string
message string
}
type logWriter struct{}
// Write implements the io.Writer interface.
//
// This parses the Go log format and outputs it as the standard Tox format.
//
// Go format:
// "15:02:46.433968 websockify.go:106: Starting up websockify endpoint\n"
//
// Standard Tox format:
// "[15:02:46.433 UTC] (websockify) websockify.go:106 : Debug: Starting up websockify endpoint"
func (writer *logWriter) Write(bytes []byte) (int, error) {
// Parse the Go log format (skipping the last 3 digits of the microseconds).
re := regexp.MustCompile(`^(\d{2}:\d{2}:\d{2}\.\d{3})\d{3} ([^:]+):(\d+): (.*)$`)
matches := re.FindStringSubmatch(strings.TrimSuffix(string(bytes), "\n"))
if len(matches) != 5 {
// If the log format doesn't match, just print it as is.
fmt.Fprintf(os.Stderr, "%s (unparsed)", string(bytes))
return len(bytes), nil
}
// Extract the log fields.
entry := logEntry{
time: matches[1],
file: matches[2],
line: matches[3],
message: matches[4],
}
// Print the Go log format in the standard Tox format to stderr.
fmt.Fprintf(os.Stderr, "[%s UTC] (websockify) %s:%s : Debug: %s\n", entry.time, entry.file, entry.line, entry.message)
return len(bytes), nil
}
func main() {
log.SetFlags(log.Ltime | log.Lshortfile | log.LUTC | log.Lmicroseconds)
log.SetOutput(new(logWriter))
flag.Parse()
log.Println("Starting up websockify endpoint")

102
other/deploy/android.sh Executable file
View File

@ -0,0 +1,102 @@
#!/bin/bash
set -eu
if [ -n "${CI-}" ]; then
sudo apt-get install -y --no-install-recommends ninja-build yasm
fi
# Set up environment
NDK=$ANDROID_NDK_HOME
ABI=${1:-"armeabi-v7a"}
case $ABI in
armeabi-v7a)
TARGET=armv7a-linux-androideabi
NDK_API=21
ANDROID_VPX_ABI=armv7-android-gcc
;;
arm64-v8a)
TARGET=aarch64-linux-android
NDK_API=21
ANDROID_VPX_ABI=arm64-android-gcc
;;
x86)
TARGET=i686-linux-android
NDK_API=21
ANDROID_VPX_ABI=x86-android-gcc
;;
x86_64)
TARGET=x86_64-linux-android
NDK_API=21
ANDROID_VPX_ABI=x86_64-android-gcc
;;
*)
exit 1
;;
esac
PREFIX="$PWD/deps-prefix-android-$ABI"
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
SYSROOT="$TOOLCHAIN/sysroot"
export CC="$TOOLCHAIN/bin/$TARGET$NDK_API-clang"
export CXX="$TOOLCHAIN/bin/$TARGET$NDK_API-clang++"
export LDFLAGS=-static-libstdc++
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
# Build libsodium
if [ ! -f "$PREFIX/lib/libsodium.a" ]; then
tar zxf <(wget -O- https://github.com/jedisct1/libsodium/releases/download/1.0.20-RELEASE/libsodium-1.0.20.tar.gz)
pushd libsodium-1.0.20
./configure --prefix="$PREFIX" --host="$TARGET" --with-sysroot="$SYSROOT" --disable-shared --disable-pie
make -j"$(nproc)" install
popd
rm -rf libsodium-1.0.20
fi
# Build opus
if [ ! -f "$PREFIX/lib/libopus.a" ]; then
tar zxf <(wget -O- https://github.com/xiph/opus/releases/download/v1.5.2/opus-1.5.2.tar.gz)
pushd opus-1.5.2
CFLAGS="-fPIC" ./configure --prefix="$PREFIX" --host="$TARGET" --with-sysroot="$SYSROOT" --disable-shared
make "-j$(nproc)"
make install
popd
rm -rf opus-1.5.2
fi
# Build libvpx
if [ ! -f "$PREFIX/lib/libvpx.a" ]; then
tar zxf <(wget -O- https://github.com/webmproject/libvpx/archive/refs/tags/v1.15.0.tar.gz)
pushd libvpx-1.15.0
./configure --prefix="$PREFIX" --libc="$SYSROOT" --target="$ANDROID_VPX_ABI" --disable-examples --disable-unit-tests --enable-pic ||
(cat config.log && exit 1)
sed -i -e "s!^AS=as!AS=$CC -c!" ./*.mk
sed -i -e "s!^STRIP=strip!STRIP=$TOOLCHAIN/bin/llvm-strip!" ./*.mk
make "-j$(nproc)"
make install
popd
rm -rf libvpx-1.15.0
fi
# Build c-toxcore
rm -rf _build
cmake -B _build -G Ninja \
-DANDROID_ABI="$ABI" \
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-android-$ABI" \
-DCMAKE_PREFIX_PATH="$PREFIX" \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON
cmake --build _build
cmake --install _build

5
other/deploy/apple/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/Tox.xcframework
/toxcore-ios*
/toxcore-iphonesimulator*
/toxcore-macos*
/smoke-test.c

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Tox</string>
<key>CFBundleName</key>
<string>Tox</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>chat.tox.toxcore</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.2.20</string>
<key>CFBundleShortVersionString</key>
<string>0.2.20</string>
<key>CFBundleGetInfoString</key>
<string>Tox Framework</string>
</dict>
</plist>

1
other/deploy/apple/LICENSE Symbolic link
View File

@ -0,0 +1 @@
../../../LICENSE

View File

@ -0,0 +1,29 @@
#!/bin/bash
# Download the nightly builds of Tox for iOS, iPhone simulator, and macOS.
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
for arch in arm64 armv7 armv7s; do
if [ ! -d "toxcore-ios-$arch" ]; then
tar -zxf \
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-ios-$arch.tar.gz")
fi
done
for arch in arm64 x86_64; do
if [ ! -d "toxcore-iphonesimulator-$arch" ]; then
tar -zxf \
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-iphonesimulator-$arch.tar.gz")
fi
done
for arch in arm64 x86_64; do
if [ ! -d "toxcore-macos-$arch" ]; then
tar -zxf \
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-macos-$arch.tar.gz")
fi
done

View File

@ -0,0 +1,71 @@
#!/bin/bash
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS from the nightly builds.
#
# Run download-nightly.sh before running this script if you run it locally.
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Make a Tox.framework for iOS.
rm -rf toxcore-ios/Tox.framework
mkdir -p toxcore-ios/Tox.framework
cp Info.plist toxcore-ios/Tox.framework
cp -r toxcore-ios-arm64/include/tox toxcore-ios/Tox.framework/Headers
lipo -create -output toxcore-ios/Tox.framework/Tox \
toxcore-ios-arm64/lib/libtoxcore.dylib \
toxcore-ios-armv7/lib/libtoxcore.dylib \
toxcore-ios-armv7s/lib/libtoxcore.dylib
install_name_tool -id @rpath/Tox.framework/Tox toxcore-ios/Tox.framework/Tox
# Make a Tox.framework for iPhone simulator.
rm -rf toxcore-iphonesimulator/Tox.framework
mkdir -p toxcore-iphonesimulator/Tox.framework
cp Info.plist toxcore-iphonesimulator/Tox.framework
cp -r toxcore-iphonesimulator-arm64/include/tox toxcore-iphonesimulator/Tox.framework/Headers
lipo -create -output toxcore-iphonesimulator/Tox.framework/Tox \
toxcore-iphonesimulator-arm64/lib/libtoxcore.dylib \
toxcore-iphonesimulator-x86_64/lib/libtoxcore.dylib
install_name_tool -id @rpath/Tox.framework/Tox toxcore-iphonesimulator/Tox.framework/Tox
# Make a Tox.framework for macOS.
rm -rf toxcore-macos/Tox.framework
mkdir -p toxcore-macos/Tox.framework
cp Info.plist toxcore-macos/Tox.framework
cp -r toxcore-macos-arm64/include/tox toxcore-macos/Tox.framework/Headers
lipo -create -output toxcore-macos/Tox.framework/Tox \
toxcore-macos-arm64/lib/libtoxcore.dylib \
toxcore-macos-x86_64/lib/libtoxcore.dylib
install_name_tool -id @rpath/Tox.framework/Tox toxcore-macos/Tox.framework/Tox
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS.
rm -rf Tox.xcframework
xcodebuild -create-xcframework -output Tox.xcframework \
-framework toxcore-ios/Tox.framework \
-framework toxcore-iphonesimulator/Tox.framework \
-framework toxcore-macos/Tox.framework
# Test the Tox.xcframework.
cat >smoke-test.c <<'EOF'
#include <stdio.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdocumentation-deprecated-sync"
#include <tox/tox.h>
#pragma GCC diagnostic pop
int main(void) {
Tox *tox = tox_new(NULL, NULL);
if (tox == NULL) {
fprintf(stderr, "tox_new failed\n");
return 1;
}
tox_kill(tox);
return 0;
}
EOF
pod lib lint toxcore.podspec
rm smoke-test.c

View File

@ -0,0 +1,24 @@
Pod::Spec.new do |s|
s.name = "toxcore"
s.version = "0.2.20"
s.summary = "Cocoapods wrapper for toxcore"
s.homepage = "https://github.com/TokTok/c-toxcore"
s.license = 'GPLv3'
s.author = { "Iphigenia Df" => "iphydf@gmail.com" }
s.source = {
:git => "https://github.com/TokTok/c-toxcore.git",
:tag => s.version.to_s,
:submodules => true
}
s.requires_arc = false
s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.15'
s.vendored_frameworks = 'Tox.xcframework'
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}"' }
s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'smoke-test.c'
end
end

30
other/deploy/deps.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -eux -o pipefail
SYSTEM="$1"
ARCH="$2"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
DEP_PREFIX="$PWD/deps-prefix-$SYSTEM-$ARCH"
if [ -d "$DEP_PREFIX" ]; then
exit 0
fi
if [ -d ../dockerfiles ]; then
DOCKERFILES="$(realpath ../dockerfiles)"
else
git clone --depth=1 https://github.com/TokTok/dockerfiles "$SCRIPT_DIR/dockerfiles"
DOCKERFILES="$SCRIPT_DIR/dockerfiles"
fi
for dep in sodium opus vpx; do
mkdir -p "external/$dep"
pushd "external/$dep"
SCRIPT="$DOCKERFILES/qtox/build_$dep.sh"
"$SCRIPT" --arch "$SYSTEM-$ARCH" --libtype "static" --buildtype "release" --prefix "$DEP_PREFIX" --macos "10.15"
popd
rm -rf "external/$dep"
done

58
other/deploy/ios.sh Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET="$1"
if [ -n "${CI-}" ]; then
brew install bash coreutils ninja yasm
fi
SYSTEM="${TARGET%%-*}"
ARCH="${TARGET#*-}"
"$SCRIPT_DIR/deps.sh" "$SYSTEM" "$ARCH"
export PKG_CONFIG_PATH="$PWD/deps-prefix-$SYSTEM-$ARCH/lib/pkgconfig"
if [ "$SYSTEM" = "ios" ]; then
XC_SDK="iphoneos"
TARGET_IPHONE_SIMULATOR=OFF
IOS_FLAGS="-miphoneos-version-min=10.0 -arch $ARCH"
elif [ "$SYSTEM" = "iphonesimulator" ]; then
XC_SDK="iphonesimulator"
TARGET_IPHONE_SIMULATOR=ON
IOS_FLAGS="-arch $ARCH"
else
echo "Unexpected system $SYSTEM"
exit 1
fi
BUILD_DIR="_build-$SYSTEM-$ARCH"
# Build for iOS 10
cmake \
-B "$BUILD_DIR" \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-$SYSTEM-$ARCH" \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON \
-DCMAKE_C_FLAGS="$IOS_FLAGS" \
-DCMAKE_CXX_FLAGS="$IOS_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$IOS_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$IOS_FLAGS" \
-DCMAKE_OSX_SYSROOT="$(xcrun --sdk "$XC_SDK" --show-sdk-path)" \
-DCMAKE_OSX_ARCHITECTURES="$ARCH"
cmake --build "$BUILD_DIR"
cmake --install "$BUILD_DIR"

29
other/deploy/linux.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ARCH="$1"
"$SCRIPT_DIR/deps.sh" linux "$ARCH"
export PKG_CONFIG_PATH="$PWD/deps-prefix-linux-$ARCH/lib/pkgconfig"
# Build
cmake \
-B _build \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-linux-$ARCH" \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON
cmake --build _build
cmake --install _build

37
other/deploy/macos.sh Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ARCH="$1"
if [ -n "${CI-}" ]; then
brew install bash coreutils ninja yasm
fi
"$SCRIPT_DIR/deps.sh" macos "$ARCH"
export PKG_CONFIG_PATH="$PWD/deps-prefix-macos-$ARCH/lib/pkgconfig"
BUILD_DIR="_build-macos-$ARCH"
# Build for macOS
cmake \
-B "$BUILD_DIR" \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-macos-$ARCH" \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15
cmake --build "$BUILD_DIR"
cmake --install "$BUILD_DIR"

1
other/deploy/single-file/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!/Makefile

View File

@ -0,0 +1,26 @@
TARGETS = libtoxcore.a libtoxcore-minimal.a
all: $(TARGETS)
libtoxcore.o: $(wildcard toxcore-*av.c)
$(CC) -c -o $@ $< \
-O2 \
-Wno-discarded-qualifiers \
-fPIC \
-Wl,-Bstatic \
$(shell pkg-config --cflags --libs libsodium) \
-Wl,-Bdynamic \
$(shell pkg-config --cflags --libs opus vpx) \
-pthread
libtoxcore-minimal.o: $(wildcard toxcore-*core.c)
$(CC) -c -o $@ $< \
-O2 \
-Wno-discarded-qualifiers \
-fPIC \
-Wl,-Bstatic \
$(shell pkg-config --cflags --libs libsodium) \
-pthread
%.a: %.o
$(AR) rcs $@ $^

View File

@ -6,10 +6,10 @@
#
# Example:
#
# other/make_single_file auto_tests/toxav_basic_test.c auto_tests/auto_test_support.c testing/misc_tools.c | \
# other/deploy/single-file/make_single_file auto_tests/toxav_basic_test.c auto_tests/auto_test_support.c testing/misc_tools.c | \
# tcc -o toxav_basic_test - $(pkg-config --cflags --libs libsodium opus vpx)
#
# other/make_single_file -core auto_tests/send_message_test.c auto_tests/auto_test_support.c testing/misc_tools.c | \
# other/deploy/single-file/make_single_file -core auto_tests/send_message_test.c auto_tests/auto_test_support.c testing/misc_tools.c | \
# tcc -o send_message_test - $(pkg-config --cflags --libs libsodium)
use strict;
@ -45,15 +45,16 @@ sub emit {
}
}
my @core = (<toxcore/*.c>, <toxcore/*/*.c>, <toxencryptsave/*.c>, <third_party/cmp/*.c>);
if (@ARGV and $ARGV[0] eq "-core") {
shift @ARGV;
for my $fn (<toxcore/*.c>, <toxcore/*/*.c>, <third_party/cmp/*.c>) {
emit(abs_path $fn);
}
emit(abs_path $_) for @core;
} else {
for my $fn (<toxav/*.c>, <toxcore/*.c>, <toxcore/*/*.c>, <toxencryptsave/*.c>, <third_party/cmp/*.c>) {
emit(abs_path $fn);
if (@ARGV and $ARGV[0] eq "-av") {
# Ignore -av, it's the default.
shift @ARGV;
}
emit(abs_path $_) for (<toxav/*.c>, @core);
}
emit(abs_path $_) for @ARGV;

View File

@ -0,0 +1,24 @@
# ===== common =====
# Ignore everything ...
**/*
# ... except sources
!**/*.[ch]
!**/*.cc
!**/*.hh
!CHANGELOG.md
!LICENSE
!README.md
!auto_tests/data/*
!other/bootstrap_daemon/bash-completion/**
!other/bootstrap_daemon/tox-bootstrapd.*
!other/proxy/*.mod
!other/proxy/*.sum
!other/proxy/*.go
# ... and CMake build files (used by most builds).
!**/CMakeLists.txt
!.github/scripts/flags*.sh
!cmake/*.cmake
!other/pkgconfig/*
!other/rpm/*
!so.version
!.github/scripts/cmake-alpine-s390x

View File

@ -0,0 +1 @@
!.github/scripts/cmake-alpine-s390x

View File

@ -1,5 +1,3 @@
#!/bin/sh
#!/usr/bin/env bash
set -eux
BUILD=alpine-s390x
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
. "$(cd "$(dirname "${BASH_SOURCE[0]}")/../sources" && pwd)/run.sh"

View File

@ -92,10 +92,6 @@
<alloc init="true">new_networking_no_udp</alloc>
<dealloc arg="1">kill_networking</dealloc>
</resource>
<resource>
<alloc init="true">net_new_strerror</alloc>
<dealloc arg="1">net_kill_strerror</dealloc>
</resource>
<resource>
<alloc init="true">new_onion</alloc>
<dealloc arg="1">kill_onion</dealloc>

View File

@ -11,9 +11,9 @@ RUN apt-get update && \
WORKDIR /work
COPY --from=sources /src/ /work/
COPY other/make_single_file /work/other/
COPY other/deploy/single-file/make_single_file /work/
RUN other/make_single_file -core auto_tests/tox_new_test.c other/docker/goblint/sodium.c > analysis.c
RUN ./make_single_file -core auto_tests/tox_new_test.c other/docker/goblint/sodium.c > analysis.c
# Try compiling+linking just to make sure we have all the fake functions.
RUN tcc analysis.c

View File

@ -98,6 +98,17 @@ int crypto_hash_sha512(unsigned char *out, const unsigned char *in,
{
return 0;
}
int crypto_pwhash_scryptsalsa208sha256(unsigned char *const out,
unsigned long long outlen,
const char *const passwd,
unsigned long long passwdlen,
const unsigned char *const salt,
unsigned long long opslimit,
size_t memlimit)
{
memset(out, 0, outlen);
return 0;
}
void randombytes(unsigned char *const buf, const unsigned long long buf_len)
{
memset(buf, 0, buf_len);

View File

@ -12,24 +12,24 @@ MODS = {}
STD_MODULE = """module std [system] {
textual header "/usr/include/alloca.h"
textual header "/usr/include/assert.h"
textual header "/usr/include/c++/13.2.1/algorithm"
textual header "/usr/include/c++/13.2.1/array"
textual header "/usr/include/c++/13.2.1/chrono"
textual header "/usr/include/c++/13.2.1/cstddef"
textual header "/usr/include/c++/13.2.1/cstdint"
textual header "/usr/include/c++/13.2.1/cstdio"
textual header "/usr/include/c++/13.2.1/cstdlib"
textual header "/usr/include/c++/13.2.1/cstring"
textual header "/usr/include/c++/13.2.1/iomanip"
textual header "/usr/include/c++/13.2.1/iosfwd"
textual header "/usr/include/c++/13.2.1/limits"
textual header "/usr/include/c++/13.2.1/memory"
textual header "/usr/include/c++/13.2.1/ostream"
textual header "/usr/include/c++/13.2.1/random"
textual header "/usr/include/c++/13.2.1/stdlib.h"
textual header "/usr/include/c++/13.2.1/thread"
textual header "/usr/include/c++/13.2.1/type_traits"
textual header "/usr/include/c++/13.2.1/vector"
textual header "/usr/include/c++/14.2.0/algorithm"
textual header "/usr/include/c++/14.2.0/array"
textual header "/usr/include/c++/14.2.0/chrono"
textual header "/usr/include/c++/14.2.0/cstddef"
textual header "/usr/include/c++/14.2.0/cstdint"
textual header "/usr/include/c++/14.2.0/cstdio"
textual header "/usr/include/c++/14.2.0/cstdlib"
textual header "/usr/include/c++/14.2.0/cstring"
textual header "/usr/include/c++/14.2.0/iomanip"
textual header "/usr/include/c++/14.2.0/iosfwd"
textual header "/usr/include/c++/14.2.0/limits"
textual header "/usr/include/c++/14.2.0/memory"
textual header "/usr/include/c++/14.2.0/ostream"
textual header "/usr/include/c++/14.2.0/random"
textual header "/usr/include/c++/14.2.0/stdlib.h"
textual header "/usr/include/c++/14.2.0/thread"
textual header "/usr/include/c++/14.2.0/type_traits"
textual header "/usr/include/c++/14.2.0/vector"
textual header "/usr/include/errno.h"
textual header "/usr/include/fortify/stdio.h"
textual header "/usr/include/fortify/string.h"

View File

@ -0,0 +1,2 @@
!other/docker/modules/check
!**/BUILD.bazel

View File

@ -1,5 +1,4 @@
FROM toxchat/c-toxcore:sources AS sources
FROM alpine:3.19.0
FROM alpine:3.21.0
RUN ["apk", "add", "--no-cache", \
"bash", \
@ -15,7 +14,7 @@ RUN ["apk", "add", "--no-cache", \
"python3"]
WORKDIR /work
COPY --from=sources /src/ /work/
COPY . /work/
COPY toxcore/BUILD.bazel /work/toxcore/
COPY other/docker/modules/check /work/other/docker/modules/

View File

@ -0,0 +1,25 @@
# ===== common =====
# Ignore everything ...
**/*
# ... except sources
!**/*.[ch]
!**/*.cc
!**/*.hh
!CHANGELOG.md
!LICENSE
!README.md
!auto_tests/data/*
!other/bootstrap_daemon/bash-completion/**
!other/bootstrap_daemon/tox-bootstrapd.*
!other/proxy/*.mod
!other/proxy/*.sum
!other/proxy/*.go
# ... and CMake build files (used by most builds).
!**/CMakeLists.txt
!.github/scripts/flags*.sh
!cmake/*.cmake
!other/pkgconfig/*
!other/rpm/*
!so.version
!other/docker/modules/check
!**/BUILD.bazel

View File

@ -1,6 +1,3 @@
#!/bin/sh
#!/usr/bin/env bash
set -eux
BUILD=modules
other/docker/sources/build
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
. "$(cd "$(dirname "${BASH_SOURCE[0]}")/../sources" && pwd)/run.sh"

View File

@ -0,0 +1 @@
!other/docker/pkgsrc/pkgsrc.patch

View File

@ -1,11 +1,14 @@
FROM toxchat/pkgsrc:latest
WORKDIR /work
COPY . /work/c-toxcore-0.2.18
RUN ["tar", "zcf", "c-toxcore.tar.gz", "c-toxcore-0.2.18"]
COPY . /work/c-toxcore-0.2.21
RUN ["tar", "zcf", "c-toxcore.tar.gz", "c-toxcore-0.2.21"]
WORKDIR /work/pkgsrc
COPY other/docker/pkgsrc/pkgsrc.patch /tmp/pkgsrc.patch
RUN ["patch", "-p1", "-i", "/tmp/pkgsrc.patch"]
WORKDIR /work/pkgsrc/chat/toxcore
RUN ["sed", "-i", "-e", "s/libtoxcore.so.2.18.0/libtoxcore.so.2.20.0/g", "PLIST"]
RUN ["bmake", "clean"]
RUN ["bmake", "DISTFILES=c-toxcore.tar.gz", "DISTDIR=/work", "NO_CHECKSUM=yes"]
RUN ["bmake", "install"]
RUN ["bmake", "DISTFILES=c-toxcore.tar.gz", "DISTDIR=/work", "NO_CHECKSUM=yes", "install"]

View File

@ -21,3 +21,4 @@
!other/pkgconfig/*
!other/rpm/*
!so.version
!other/docker/pkgsrc/pkgsrc.patch

View File

@ -0,0 +1,31 @@
diff --git a/chat/toxcore/Makefile b/chat/toxcore/Makefile
index 70466704d..53a08ad08 100644
--- a/chat/toxcore/Makefile
+++ b/chat/toxcore/Makefile
@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.6 2024/01/22 13:16:56 ryoon Exp $
-DISTNAME= toxcore-0.2.18
+DISTNAME= toxcore-0.2.21
PKGREVISION= 2
CATEGORIES= chat
MASTER_SITES= ${MASTER_SITE_GITHUB:=TokTok/}
diff --git a/chat/toxcore/PLIST b/chat/toxcore/PLIST
index f0a5e4f04..4122b0867 100644
--- a/chat/toxcore/PLIST
+++ b/chat/toxcore/PLIST
@@ -4,11 +4,11 @@ bin/tox-bootstrapd
include/tox/tox.h
-include/tox/tox_dispatch.h
-include/tox/tox_events.h
+include/tox/tox_log_level.h
+include/tox/tox_options.h
include/tox/toxav.h
include/tox/toxencryptsave.h
lib/libtoxcore.a
lib/libtoxcore.so
lib/libtoxcore.so.2
-lib/libtoxcore.so.2.18.0
+lib/libtoxcore.so.2.21.0
lib/pkgconfig/toxcore.pc
share/bash-completion/completions/tox-bootstrapd

View File

@ -27,8 +27,8 @@ RUN make install -j4 PREFIX=/usr/local
WORKDIR /work/c-toxcore
COPY --from=sources /src/ /work/c-toxcore
#COPY other/make_single_file /work/c-toxcore/other/
#RUN other/make_single_file auto_tests/tox_new_test.c > crash.c
#COPY other/deploy/single-file/make_single_file /work/c-toxcore/
#RUN ./make_single_file auto_tests/tox_new_test.c > crash.c
#RUN sparsec $(pkg-config --cflags --libs libsodium opus vpx) crash.c
COPY other/docker/sparse/Makefile /work/c-toxcore/

View File

@ -33,9 +33,9 @@ RUN tcc \
$(pkg-config --cflags --libs libsodium opus vpx) \
&& ./send_message_test | grep 'tox clients connected'
COPY other/make_single_file /work/other/
COPY other/deploy/single-file/make_single_file /work/
RUN \
other/make_single_file -core \
./make_single_file -core \
auto_tests/auto_test_support.c \
auto_tests/send_message_test.c \
testing/misc_tools.c | \
@ -47,7 +47,7 @@ RUN \
&& ./send_message_test | grep 'tox clients connected'
RUN \
other/make_single_file \
./make_single_file \
auto_tests/auto_test_support.c \
auto_tests/toxav_basic_test.c \
testing/misc_tools.c | \

3
other/docker/wasm/run Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
. "$(cd "$(dirname "${BASH_SOURCE[0]}")/../sources" && pwd)/run.sh"

View File

@ -0,0 +1,136 @@
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND="noninteractive"
# Install dependencies.
RUN apt-get update && apt-get install --no-install-recommends -y \
autoconf \
automake \
ca-certificates \
cmake \
curl \
git \
libtool \
make \
ninja-build \
pkg-config \
python3 \
unzip \
wget \
xz-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /work/emsdk
RUN git clone --depth=1 https://github.com/emscripten-core/emsdk /work/emsdk \
&& ./emsdk install 4.0.3 \
&& ./emsdk activate 4.0.3
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /work
# Build libsodium.
RUN . "/work/emsdk/emsdk_env.sh" \
&& tar zxf <(curl -L https://github.com/jedisct1/libsodium/releases/download/1.0.20-RELEASE/libsodium-1.0.20.tar.gz) \
&& cd /work/libsodium-* \
&& emconfigure ./configure \
--prefix=/wasm \
--enable-static \
--disable-shared \
--without-pthreads \
--disable-ssp \
--disable-asm \
--disable-pie \
&& emmake make -j"$(nproc)" \
&& emmake make install \
&& rm -rf /work/libsodium-*
# Build libvpx.
RUN . "/work/emsdk/emsdk_env.sh" \
&& tar zxf <(curl -L https://github.com/webmproject/libvpx/archive/v1.15.0.tar.gz) \
&& cd /work/libvpx-* \
&& emconfigure ./configure \
--prefix=/wasm \
--enable-static \
--disable-shared \
--target=generic-gnu \
--disable-examples \
--disable-tools \
--disable-docs \
--disable-unit-tests \
--enable-pic \
&& emmake make -j"$(nproc)" \
&& emmake make install \
&& rm -rf /work/libvpx-*
# Build opus.
RUN . "/work/emsdk/emsdk_env.sh" \
&& tar zxf <(curl -L https://github.com/xiph/opus/releases/download/v1.5.2/opus-1.5.2.tar.gz) \
&& cd /work/opus-* \
&& emconfigure ./configure \
--prefix=/wasm \
--enable-static \
--disable-shared \
--host wasm32-unknown-emscripten \
--disable-extra-programs \
--disable-doc \
CFLAGS="-O3 -flto -fPIC" \
&& emmake make -j"$(nproc)" \
&& emmake make install \
&& rm -rf /work/opus-*
# Build an unused binding without toxcore first so emcc caches all the system
# libraries. This makes rebuilds of toxcore below much faster.
RUN . "/work/emsdk/emsdk_env.sh" \
&& mkdir -p /wasm/bin \
&& emcc -O3 -flto \
-s EXPORT_NAME=libtoxcore \
-s MAIN_MODULE=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s STRICT=1 \
-s WEBSOCKET_URL=ws:// \
--no-entry \
/wasm/lib/libopus.a \
/wasm/lib/libsodium.a \
/wasm/lib/libvpx.a \
-o /wasm/bin/libtoxcore.js
ENV PKG_CONFIG_PATH="/wasm/lib/pkgconfig"
# Build c-toxcore.
COPY . /work/c-toxcore
RUN . "/work/emsdk/emsdk_env.sh" \
&& cd /work/c-toxcore \
&& emcmake cmake \
-B_build \
-GNinja \
-DCMAKE_INSTALL_PREFIX="/wasm" \
-DCMAKE_C_FLAGS="-O3 -flto -fPIC" \
-DCMAKE_UNITY_BUILD=ON \
-DMUST_BUILD_TOXAV=ON \
-DENABLE_SHARED=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DMIN_LOGGER_LEVEL=TRACE \
. \
&& emmake cmake --build _build \
&& emmake cmake --install _build
# Link together all the libraries.
RUN . "/work/emsdk/emsdk_env.sh" \
&& mkdir -p /wasm/bin \
&& emcc -O3 -flto \
-s EXPORT_NAME=libtoxcore \
-s EXPORTED_RUNTIME_METHODS='["HEAPU8", "wasmExports"]' \
-s MAIN_MODULE=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s STRICT=1 \
-s WEBSOCKET_URL=ws:// \
--no-entry \
/wasm/lib/libopus.a \
/wasm/lib/libsodium.a \
/wasm/lib/libvpx.a \
/wasm/lib/libtoxcore.a \
-o /wasm/bin/libtoxcore.js
RUN ls -lh /wasm/bin/libtoxcore.js /wasm/bin/libtoxcore.wasm

View File

@ -0,0 +1,23 @@
# ===== common =====
# Ignore everything ...
**/*
# ... except sources
!**/*.[ch]
!**/*.cc
!**/*.hh
!CHANGELOG.md
!LICENSE
!README.md
!auto_tests/data/*
!other/bootstrap_daemon/bash-completion/**
!other/bootstrap_daemon/tox-bootstrapd.*
!other/proxy/*.mod
!other/proxy/*.sum
!other/proxy/*.go
# ... and CMake build files (used by most builds).
!**/CMakeLists.txt
!.github/scripts/flags*.sh
!cmake/*.cmake
!other/pkgconfig/*
!other/rpm/*
!so.version

View File

@ -1,85 +0,0 @@
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND="noninteractive"
# Install dependencies.
RUN apt-get update && apt-get install --no-install-recommends -y \
autoconf \
automake \
ca-certificates \
cmake \
curl \
git \
libtool \
make \
ninja-build \
pkg-config \
python3 \
unzip \
wget \
xz-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /work/emsdk
RUN git clone --depth=1 https://github.com/emscripten-core/emsdk /work/emsdk \
&& ./emsdk install 3.1.3 \
&& ./emsdk activate 3.1.3
# Build libsodium.
RUN . "/work/emsdk/emsdk_env.sh" \
&& git clone --depth=1 --branch=1.0.18 https://github.com/jedisct1/libsodium /work/libsodium \
&& cd /work/libsodium \
&& autoreconf -fi \
&& emconfigure ./configure --disable-shared \
--without-pthreads \
--disable-ssp --disable-asm --disable-pie \
--host x86_64-linux-gnu \
&& emmake make install -j8
# Build an unused libsodium binding first so emcc caches all the system
# libraries. This makes rebuilds of toxcore below much faster.
RUN . "/work/emsdk/emsdk_env.sh" \
&& mkdir -p /work/wasm \
&& emcc -O3 -flto \
--closure=1 \
-s ALLOW_UNIMPLEMENTED_SYSCALLS=1 \
-s EXPORT_NAME=libtoxcore \
-s IGNORE_MISSING_MAIN=1 \
-s MAIN_MODULE=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s STRICT=1 \
-s WEBSOCKET_URL=wss:// \
/usr/local/lib/libsodium.a \
-o /work/wasm/libsodium.js
# Build c-toxcore.
COPY . /work/c-toxcore
RUN . "/work/emsdk/emsdk_env.sh" \
&& cd /work/c-toxcore \
&& emcmake cmake -B_build -H. -GNinja \
-DCMAKE_INSTALL_PREFIX:PATH="/usr/local" \
-DCMAKE_C_FLAGS="-O3 -flto -fPIC" \
-DBUILD_TOXAV=OFF \
-DENABLE_SHARED=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DMIN_LOGGER_LEVEL=DEBUG \
&& emmake cmake --build _build --parallel 8 --target install
# Build wasm bindings.
RUN . "/work/emsdk/emsdk_env.sh" \
&& mkdir -p /work/wasm \
&& emcc -O3 -flto \
--closure=1 \
-s ALLOW_UNIMPLEMENTED_SYSCALLS=1 \
-s EXPORT_NAME=libtoxcore \
-s IGNORE_MISSING_MAIN=1 \
-s MAIN_MODULE=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s STRICT=1 \
-s WEBSOCKET_URL=wss:// \
/usr/local/lib/libsodium.a \
/usr/local/lib/libtoxcore.a \
-o /work/wasm/libtoxcore.js

View File

@ -1,3 +0,0 @@
#!/bin/sh
docker build -t toxchat/toxcore-js -f other/emscripten/Dockerfile .

View File

@ -15,8 +15,8 @@ import (
const (
debug = false
httpAddr = ":8080"
socks5Addr = ":8081"
httpAddr = ":7080"
socks5Addr = ":7081"
)
func handleTunneling(w http.ResponseWriter, r *http.Request) {

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
set -eu
@ -23,15 +23,21 @@ update() {
fi
}
update 'configure.ac' 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/'
update 'configure.ac' 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['"$VER"'])/'
update 'toxcore/tox.api.h' 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/'
update 'toxcore/tox.h' 's/\(#define TOX_VERSION_MAJOR *\).*/\1'"$MAJOR"'/'
update 'toxcore/tox.h' 's/\(#define TOX_VERSION_MINOR *\).*/\1'"$MINOR"'/'
update 'toxcore/tox.h' 's/\(#define TOX_VERSION_PATCH *\).*/\1'"$PATCH"'/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MAJOR "\).*"/\1'$MAJOR'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MINOR "\).*"/\1'$MINOR'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_PATCH "\).*"/\1'$PATCH'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MAJOR "\).*"/\1'"$MAJOR"'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MINOR "\).*"/\1'"$MINOR"'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_PATCH "\).*"/\1'"$PATCH"'"/'
update 'other/docker/pkgsrc/pkgsrc.Dockerfile' 's/\(COPY . \/work\/c-toxcore-\).*/\1'"$VER"'/'
update 'other/docker/pkgsrc/pkgsrc.Dockerfile' 's/\(tar", "zcf", "c-toxcore.tar.gz", "c-toxcore-\).*/\1'"$VER"'"]/'
update 'other/docker/pkgsrc/pkgsrc.patch' 's/\(+DISTNAME=\ttoxcore-\).*/\1'"$VER"'/'
update 'other/docker/pkgsrc/pkgsrc.patch' 's/\(+lib\/libtoxcore.so.\).*/\1'"$MINOR.$PATCH.0"'/'
#
# calculating the SO version
@ -64,14 +70,14 @@ update 'CMakeLists.txt' 's/\(PROJECT_VERSION_PATCH "\).*"/\1'$PATCH'"/'
# this must be constant starting from the 1.0 release
LAST_SOMAJOR=2
if [ $MAJOR -eq 0 ]; then
if [ "$MAJOR" -eq 0 ]; then
SOMAJOR=$MINOR
SOMINOR=$PATCH
# update lastmajor above
update 'other/version-sync' 's/^\(LAST_SOMAJOR=\).*/\1'$SOMAJOR'/'
update 'other/version-sync' 's/^\(LAST_SOMAJOR=\).*/\1'"$SOMAJOR"'/'
else
SOMAJOR=$(expr $MAJOR + $LAST_SOMAJOR)
SOMAJOR=$(("$MAJOR" + "$LAST_SOMAJOR"))
SOMINOR=$MINOR
fi
@ -115,16 +121,16 @@ fi
# <=> major.minor.patch
#
if [ $MAJOR -eq 0 ]; then
LIBTOOL_CURRENT=$(expr $SOMAJOR + $SOMINOR)
if [ "$MAJOR" -eq 0 ]; then
LIBTOOL_CURRENT=$(("$SOMAJOR" + "$SOMINOR"))
LIBTOOL_AGE=$SOMINOR
LIBTOOL_REVISION=0
else
LIBTOOL_CURRENT=$(expr $SOMAJOR + $SOMINOR)
LIBTOOL_CURRENT=$(("$SOMAJOR" + "$SOMINOR"))
LIBTOOL_AGE=$SOMINOR
LIBTOOL_REVISION=$PATCH
fi
update 'so.version' 's/^\(CURRENT=\).*/\1'$LIBTOOL_CURRENT'/'
update 'so.version' 's/^\(AGE=\).*/\1'$LIBTOOL_AGE'/'
update 'so.version' 's/^\(REVISION=\).*/\1'$LIBTOOL_REVISION'/'
update 'so.version' 's/^\(CURRENT=\).*/\1'"$LIBTOOL_CURRENT"'/'
update 'so.version' 's/^\(AGE=\).*/\1'"$LIBTOOL_AGE"'/'
update 'so.version' 's/^\(REVISION=\).*/\1'"$LIBTOOL_REVISION"'/'

View File

@ -11,6 +11,6 @@
# For a full reference see:
# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
CURRENT=22
CURRENT=23
REVISION=0
AGE=20
AGE=21

View File

@ -20,10 +20,13 @@ function(fuzz_test target source_dir)
endfunction()
fuzz_test(bootstrap .) # Fuzzes the bootstrap process
fuzz_test(toxsave .) # Fuzzes the bootstrap process
# TODO(iphydf): Fix this in the cmake build.
# fuzz_test(e2e .) # Fuzzes an end-to-end connection
fuzz_test(toxsave .) # Fuzzes tox_new and tox_get_savedata
fuzz_test(DHT ../../toxcore)
fuzz_test(forwarding ../../toxcore)
fuzz_test(group_announce ../../toxcore)
fuzz_test(group_moderation ../../toxcore)
fuzz_test(net_crypto ../../toxcore)
fuzz_test(tox_events ../../toxcore)

View File

@ -109,7 +109,7 @@ void TestBootstrap(Fuzz_Data &input)
[](Tox *tox, Tox_Log_Level level, const char *file, uint32_t line, const char *func,
const char *message, void *user_data) {
// Log to stdout.
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("[tox1] %c %s:%d(%s): %s\n", tox_log_level_name(level), file, line,
func, message);
}
@ -161,6 +161,7 @@ void TestBootstrap(Fuzz_Data &input)
assert(dispatch != nullptr);
setup_callbacks(dispatch);
size_t input_size = input.size();
while (!input.empty()) {
Tox_Err_Events_Iterate error_iterate;
Tox_Events *events = tox_events_iterate(tox, true, &error_iterate);
@ -170,6 +171,11 @@ void TestBootstrap(Fuzz_Data &input)
// Move the clock forward a decent amount so all the time-based checks
// trigger more quickly.
sys.clock += 200;
// If no input was consumed, something went wrong.
assert(input_size != input.size());
input_size = input.size();
}
tox_dispatch_free(dispatch);

View File

@ -5,7 +5,6 @@
#include <cassert>
#include <cstdio>
#include <fstream>
#include <vector>
#include "../../toxcore/crypto_core.h"
@ -144,7 +143,7 @@ void TestEndToEnd(Fuzz_Data &input)
[](Tox *tox, Tox_Log_Level level, const char *file, uint32_t line, const char *func,
const char *message, void *user_data) {
// Log to stdout.
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("[tox1] %c %s:%d(%s): %s\n", tox_log_level_name(level), file, line,
func, message);
}

View File

@ -57,13 +57,13 @@ static int recv_common(Fuzz_Data &input, uint8_t *buf, size_t buf_len)
if (fuzz_len == 0xffff) {
errno = EWOULDBLOCK;
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("recvfrom: no data for tox1\n");
}
return -1;
}
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf(
"recvfrom: %zu (%02x, %02x) for tox1\n", fuzz_len, input.data()[-2], input.data()[-1]);
}
@ -77,7 +77,7 @@ static int recv_common(Fuzz_Data &input, uint8_t *buf, size_t buf_len)
static void *report_alloc(const char *name, const char *func, std::size_t size, void *ptr)
{
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
printf("%s: %s(%zu): %s\n", name, func, size, ptr == nullptr ? "false" : "true");
}
return ptr;
@ -175,13 +175,40 @@ static constexpr Network_Funcs fuzz_network_funcs = {
static constexpr Random_Funcs fuzz_random_funcs = {
/* .random_bytes = */
![](Fuzz_System *self, uint8_t *bytes, size_t length) {
// Amount of data is limited
const size_t bytes_read = std::min(length, self->data.size());
// Initialize everything to make MSAN and others happy
std::memset(bytes, 0, length);
CONSUME_OR_ABORT(const uint8_t *data, self->data, bytes_read);
std::copy(data, data + bytes_read, bytes);
if (Fuzz_Data::DEBUG) {
// Initialize the buffer with zeros in case there's no randomness left.
std::fill_n(bytes, length, 0);
// For integers, we copy bytes directly, because we want to control the
// exact values.
if (length == sizeof(uint8_t) || length == sizeof(uint16_t) || length == sizeof(uint32_t)
|| length == sizeof(uint64_t)) {
CONSUME_OR_RETURN(const uint8_t *data, self->data, length);
std::copy(data, data + length, bytes);
if (Fuzz_Data::FUZZ_DEBUG) {
if (length == 1) {
std::printf("rng: %d (0x%02x)\n", bytes[0], bytes[0]);
} else {
std::printf("rng: %02x..%02x[%zu]\n", bytes[0], bytes[length - 1], length);
}
}
return;
}
// For nonces and keys, we fill the buffer with the same 1-2 bytes
// repeated. We only need these to be different enough to not often be
// the same.
assert(length == 24 || length == 32);
// We must cover the case of having only 1 byte left in the input. In
// that case, we will use the same byte for all the bytes in the output.
const size_t chunk_size = std::max(self->data.size(), static_cast<std::size_t>(2));
CONSUME_OR_RETURN(const uint8_t *chunk, self->data, chunk_size);
if (chunk_size == 2) {
std::fill_n(bytes, length / 2, chunk[0]);
std::fill_n(bytes + length / 2, length / 2, chunk[1]);
} else {
std::fill_n(bytes, length, chunk[0]);
}
if (Fuzz_Data::FUZZ_DEBUG) {
if (length == 1) {
std::printf("rng: %d (0x%02x)\n", bytes[0], bytes[0]);
} else {
@ -364,7 +391,7 @@ static constexpr Network_Funcs record_network_funcs = {
if (self->recvq.empty()) {
self->push("\xff\xff");
errno = EWOULDBLOCK;
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("%s: recvfrom: no data\n", self->name_);
}
return -1;
@ -387,7 +414,7 @@ static constexpr Network_Funcs record_network_funcs = {
assert(recvlen > 0 && recvlen <= INT_MAX);
self->push(uint8_t(recvlen >> 8));
self->push(uint8_t(recvlen & 0xff));
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("%s: recvfrom: %zu (%02x, %02x)\n", self->name_, recvlen,
self->recording().end()[-2], self->recording().end()[-1]);
}
@ -428,7 +455,7 @@ static constexpr Random_Funcs record_random_funcs = {
bytes[i] = simple_rng(self->seed_) & 0xff;
self->push(bytes[i]);
}
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf(
"%s: rng: %02x..%02x[%zu]\n", self->name_, bytes[0], bytes[length - 1], length);
}

View File

@ -5,21 +5,21 @@
#ifndef C_TOXCORE_TESTING_FUZZING_FUZZ_SUPPORT_H
#define C_TOXCORE_TESTING_FUZZING_FUZZ_SUPPORT_H
#include <array>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include "../../toxcore/tox.h"
#include "../../toxcore/tox_private.h"
struct Fuzz_Data {
static constexpr bool DEBUG = false;
static constexpr bool FUZZ_DEBUG = false;
static constexpr std::size_t TRACE_TRAP = -1; // 579;
private:
@ -47,7 +47,7 @@ public:
// Special case because memcpy causes UB for bool (which can't be
// anything other than 0 or 1).
const bool val = fd.data_[0];
if (DEBUG) {
if (FUZZ_DEBUG) {
std::printf("consume@%zu(%s): bool %s\n", fd.pos(), func, val ? "true" : "false");
}
++fd.data_;
@ -74,7 +74,7 @@ public:
const uint8_t *consume(const char *func, std::size_t count)
{
const uint8_t *val = data_;
if (DEBUG) {
if (FUZZ_DEBUG) {
if (pos() == TRACE_TRAP) {
__asm__("int $3");
}
@ -256,6 +256,38 @@ struct Null_System : System {
Null_System();
};
template <typename V>
class int_map {
public:
struct iterator {
std::pair<uint16_t, V> pair;
bool operator==(const iterator &rhs) const { return pair.first == rhs.pair.first; }
bool operator!=(const iterator &rhs) const { return pair.first != rhs.pair.first; }
std::pair<uint16_t, V> operator*() const { return pair; }
const std::pair<uint16_t, V> *operator->() const { return &pair; }
};
int_map() = default;
~int_map() = default;
iterator find(uint16_t key) const
{
if (!values[key]) {
return end();
}
return {{key, values[key]}};
}
iterator end() const { return {{static_cast<uint16_t>(values.size()), nullptr}}; }
void emplace(uint16_t key, V value) { values[key] = value; }
private:
std::array<V, UINT16_MAX> values;
};
/**
* A Tox_System implementation that records all I/O but does not actually
* perform any real I/O. Everything inside this system is hermetic in-process
@ -266,7 +298,7 @@ struct Null_System : System {
* initialised with the same seed will be identical (same keys, etc.).
*/
struct Record_System : System {
static constexpr bool DEBUG = Fuzz_Data::DEBUG;
static constexpr bool FUZZ_DEBUG = Fuzz_Data::FUZZ_DEBUG;
/** @brief State shared between all tox instances. */
struct Global {
@ -280,7 +312,7 @@ struct Record_System : System {
* toxcore sends packets to itself sometimes when doing onion routing
* with only 2 nodes in the network.
*/
std::unordered_map<uint16_t, Record_System *> bound;
int_map<Record_System *> bound;
};
Global &global_;
@ -300,7 +332,7 @@ struct Record_System : System {
void push(bool byte)
{
if (DEBUG) {
if (FUZZ_DEBUG) {
if (recording_.size() == Fuzz_Data::TRACE_TRAP) {
__asm__("int $3");
}
@ -312,7 +344,7 @@ struct Record_System : System {
void push(uint8_t byte)
{
if (DEBUG) {
if (FUZZ_DEBUG) {
if (recording_.size() == Fuzz_Data::TRACE_TRAP) {
__asm__("int $3");
}
@ -323,7 +355,7 @@ struct Record_System : System {
void push(const uint8_t *bytes, std::size_t size)
{
if (DEBUG) {
if (FUZZ_DEBUG) {
if (recording_.size() == Fuzz_Data::TRACE_TRAP) {
__asm__("int $3");
}
@ -352,7 +384,7 @@ private:
* everything down drastically. It's useful while developing the fuzzer and the
* protodump program.
*/
extern const bool DEBUG;
extern const bool FUZZ_DEBUG;
inline constexpr char tox_log_level_name(Tox_Log_Level level)
{

View File

@ -31,8 +31,6 @@
#include "../../toxcore/tox_dispatch.h"
#include "../../toxcore/tox_events.h"
#include "../../toxcore/tox_private.h"
#include "../../toxcore/tox_struct.h"
#include "../../toxcore/util.h"
#include "fuzz_support.hh"
namespace {
@ -179,7 +177,7 @@ void dump(std::vector<uint8_t> recording, const char *filename)
void RecordBootstrap(const char *init, const char *bootstrap)
{
Record_System::Global global;
auto global = std::make_unique<Record_System::Global>();
Tox_Options *opts = tox_options_new(nullptr);
assert(opts != nullptr);
@ -198,9 +196,9 @@ void RecordBootstrap(const char *init, const char *bootstrap)
Tox_Err_New_Testing error_new_testing;
Tox_Options_Testing tox_options_testing;
Record_System sys1(global, 4, "tox1"); // fair dice roll
tox_options_set_log_user_data(opts, &sys1);
tox_options_testing.operating_system = sys1.sys.get();
auto sys1 = std::make_unique<Record_System>(*global, 4, "tox1"); // fair dice roll
tox_options_set_log_user_data(opts, sys1.get());
tox_options_testing.operating_system = sys1->sys.get();
Tox *tox1 = tox_new_testing(opts, &error_new, &tox_options_testing, &error_new_testing);
assert(tox1 != nullptr);
assert(error_new == TOX_ERR_NEW_OK);
@ -212,9 +210,9 @@ void RecordBootstrap(const char *init, const char *bootstrap)
std::array<uint8_t, TOX_PUBLIC_KEY_SIZE> dht_key1;
tox_self_get_dht_id(tox1, dht_key1.data());
Record_System sys2(global, 5, "tox2"); // unfair dice roll
tox_options_set_log_user_data(opts, &sys2);
tox_options_testing.operating_system = sys2.sys.get();
auto sys2 = std::make_unique<Record_System>(*global, 5, "tox2"); // unfair dice roll
tox_options_set_log_user_data(opts, sys2.get());
tox_options_testing.operating_system = sys2->sys.get();
Tox *tox2 = tox_new_testing(opts, &error_new, &tox_options_testing, &error_new_testing);
assert(tox2 != nullptr);
assert(error_new == TOX_ERR_NEW_OK);
@ -252,31 +250,31 @@ void RecordBootstrap(const char *init, const char *bootstrap)
Tox_Events *events;
events = tox_events_iterate(tox1, true, &error_iterate);
assert(tox_events_equal(sys1.sys.get(), events, events));
assert(tox_events_equal(sys1->sys.get(), events, events));
tox_dispatch_invoke(dispatch, events, &state1);
tox_events_free(events);
events = tox_events_iterate(tox2, true, &error_iterate);
assert(tox_events_equal(sys2.sys.get(), events, events));
assert(tox_events_equal(sys2->sys.get(), events, events));
tox_dispatch_invoke(dispatch, events, &state2);
tox_events_free(events);
// Move the clock forward a decent amount so all the time-based checks
// trigger more quickly.
sys1.clock += clock_increment;
sys2.clock += clock_increment;
sys1->clock += clock_increment;
sys2->clock += clock_increment;
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
printf("tox1: rng: %d (for clock)\n", clock_increment);
printf("tox2: rng: %d (for clock)\n", clock_increment);
}
sys1.push(clock_increment);
sys2.push(clock_increment);
sys1->push(clock_increment);
sys2->push(clock_increment);
};
while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE
|| tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE) {
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("tox1: %d, tox2: %d\n", tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2));
}
@ -291,7 +289,7 @@ void RecordBootstrap(const char *init, const char *bootstrap)
while (tox_friend_get_connection_status(tox2, friend_number, nullptr) == TOX_CONNECTION_NONE
|| tox_friend_get_connection_status(tox1, 0, nullptr) == TOX_CONNECTION_NONE) {
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("tox1: %d, tox2: %d, tox1 -> tox2: %d, tox2 -> tox1: %d\n",
tox_self_get_connection_status(tox1), tox_self_get_connection_status(tox2),
tox_friend_get_connection_status(tox1, 0, nullptr),
@ -302,10 +300,10 @@ void RecordBootstrap(const char *init, const char *bootstrap)
std::printf("tox clients connected\n");
dump(sys1.take_recording(), init);
dump(sys1->take_recording(), init);
while (state1.done < MESSAGE_COUNT && state2.done < MESSAGE_COUNT) {
if (Fuzz_Data::DEBUG) {
if (Fuzz_Data::FUZZ_DEBUG) {
std::printf("tox1: %d, tox2: %d, tox1 -> tox2: %d, tox2 -> tox1: %d\n",
tox_self_get_connection_status(tox1), tox_self_get_connection_status(tox2),
tox_friend_get_connection_status(tox1, 0, nullptr),
@ -320,7 +318,7 @@ void RecordBootstrap(const char *init, const char *bootstrap)
tox_kill(tox2);
tox_kill(tox1);
dump(sys1.recording(), bootstrap);
dump(sys1->recording(), bootstrap);
}
}

View File

@ -11,7 +11,7 @@
namespace {
constexpr bool PROTODUMP_DEBUG = Fuzz_Data::DEBUG;
constexpr bool PROTODUMP_DEBUG = Fuzz_Data::FUZZ_DEBUG;
void setup_callbacks(Tox_Dispatch *dispatch)
{

View File

@ -1,6 +1,10 @@
#!/bin/sh
set -eux
set -eux -o pipefail
WORKSPACE_ROOT=$(bazel info workspace)
cd "$WORKSPACE_ROOT"
bazel test --config=asan-libfuzzer //c-toxcore/testing/fuzzing:protodump_reduce_test

View File

@ -20,6 +20,8 @@ void TestSaveDataLoading(Fuzz_Data &input)
const size_t savedata_size = input.size();
CONSUME_OR_RETURN(const uint8_t *savedata, input, savedata_size);
tox_options_set_experimental_groups_persistence(tox_options, true);
// pass test data to Tox
tox_options_set_savedata_data(tox_options, savedata, savedata_size);
tox_options_set_savedata_type(tox_options, TOX_SAVEDATA_TYPE_TOX_SAVE);

View File

@ -1 +1,2 @@
googletest
/ci-tools
/googletest

15
tools/update-versions.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eux -o pipefail
VERSION=$1
GIT_ROOT=$(git rev-parse --show-toplevel)
cd "$GIT_ROOT"
# Strip suffixes (e.g. "-rc.1") from the version for the toxcore version sync.
VERSION="${VERSION%-*}"
IFS="." read -ra version_parts <<<"$VERSION"
other/version-sync "$GIT_ROOT" "${version_parts[0]}" "${version_parts[1]}" "${version_parts[2]}"

View File

@ -17,6 +17,7 @@
#include "../toxcore/logger.h"
#include "../toxcore/mono_time.h"
#include "../toxcore/net_crypto.h"
#include "../toxcore/network.h"
#include "../toxcore/tox_private.h"
#include "../toxcore/util.h"
@ -678,7 +679,7 @@ static uint32_t rtp_random_u32(void)
return randombytes_random();
}
RTPSession *rtp_new(const Logger *log, int payload_type, Tox *tox, ToxAV *toxav, uint32_t friendnumber,
RTPSession *rtp_new(const Logger *log, const Memory *mem, int payload_type, Tox *tox, ToxAV *toxav, uint32_t friendnumber,
BWController *bwc, void *cs, rtp_m_cb *mcb)
{
assert(mcb != nullptr);
@ -704,6 +705,8 @@ RTPSession *rtp_new(const Logger *log, int payload_type, Tox *tox, ToxAV *toxav,
session->ssrc = payload_type == RTP_TYPE_VIDEO ? 0 : rtp_random_u32(); // Zoff: what is this??
session->payload_type = payload_type;
session->log = log;
session->mem = mem;
session->tox = tox;
session->toxav = toxav;
session->friend_number = friendnumber;
@ -773,18 +776,17 @@ void rtp_stop_receiving(Tox *tox)
* @param error the error from rtp_send_custom_lossy_packet.
* @param rdata_size The package length to be shown in the log.
*/
static void rtp_report_error_maybe(const Logger *log, Tox_Err_Friend_Custom_Packet error, uint16_t rdata_size)
static void rtp_report_error_maybe(const Logger *log, const Memory *mem, Tox_Err_Friend_Custom_Packet error, uint16_t rdata_size)
{
if (error != TOX_ERR_FRIEND_CUSTOM_PACKET_OK) {
char *netstrerror = net_new_strerror(net_error());
Net_Strerror error_str;
const char *toxerror = tox_err_friend_custom_packet_to_string(error);
LOGGER_WARNING(log, "RTP send failed (len: %u)! tox error: %s net error: %s",
rdata_size, toxerror, netstrerror);
net_kill_strerror(netstrerror);
rdata_size, toxerror, net_strerror(net_error(), &error_str));
}
}
static void rtp_send_piece(const Logger *log, Tox *tox, uint32_t friend_number, const struct RTPHeader *header,
static void rtp_send_piece(const Logger *log, const Memory *mem, Tox *tox, uint32_t friend_number, const struct RTPHeader *header,
const uint8_t *data, uint8_t *rdata, uint16_t length)
{
rtp_header_pack(rdata + 1, header);
@ -795,7 +797,7 @@ static void rtp_send_piece(const Logger *log, Tox *tox, uint32_t friend_number,
Tox_Err_Friend_Custom_Packet error;
tox_friend_send_lossy_packet(tox, friend_number, rdata, rdata_size, &error);
rtp_report_error_maybe(log, error, rdata_size);
rtp_report_error_maybe(log, mem, error, rdata_size);
}
static struct RTPHeader rtp_default_header(const RTPSession *session, uint32_t length, bool is_keyframe)
@ -868,7 +870,7 @@ int rtp_send_data(const Logger *log, RTPSession *session, const uint8_t *data, u
* Send the packet in single piece.
*/
assert(length < UINT16_MAX);
rtp_send_piece(log, session->tox, session->friend_number, &header, data, rdata, length);
rtp_send_piece(log, session->mem, session->tox, session->friend_number, &header, data, rdata, length);
} else {
/*
* The length is greater than the maximum allowed length (including header)
@ -878,7 +880,7 @@ int rtp_send_data(const Logger *log, RTPSession *session, const uint8_t *data, u
uint16_t piece = MAX_CRYPTO_DATA_SIZE - (RTP_HEADER_SIZE + 1);
while ((length - sent) + RTP_HEADER_SIZE + 1 > MAX_CRYPTO_DATA_SIZE) {
rtp_send_piece(log, session->tox, session->friend_number, &header, data + sent, rdata, piece);
rtp_send_piece(log, session->mem, session->tox, session->friend_number, &header, data + sent, rdata, piece);
sent += piece;
header.offset_lower = sent;
@ -889,7 +891,7 @@ int rtp_send_data(const Logger *log, RTPSession *session, const uint8_t *data, u
piece = length - sent;
if (piece != 0) {
rtp_send_piece(log, session->tox, session->friend_number, &header, data + sent, rdata, piece);
rtp_send_piece(log, session->mem, session->tox, session->friend_number, &header, data + sent, rdata, piece);
}
}

View File

@ -162,6 +162,7 @@ typedef struct RTPSession {
struct RTPWorkBufferList *work_buffer_list;
uint8_t first_packets_counter; /* dismiss first few lost video packets */
const Logger *log;
const Memory *mem;
Tox *tox;
ToxAV *toxav;
uint32_t friend_number;
@ -192,7 +193,7 @@ size_t rtp_header_pack(uint8_t *rdata, const struct RTPHeader *header);
*/
size_t rtp_header_unpack(const uint8_t *data, struct RTPHeader *header);
RTPSession *rtp_new(const Logger *log, int payload_type, Tox *tox, ToxAV *toxav, uint32_t friendnumber,
RTPSession *rtp_new(const Logger *log, const Memory *mem, int payload_type, Tox *tox, ToxAV *toxav, uint32_t friendnumber,
BWController *bwc, void *cs, rtp_m_cb *mcb);
void rtp_kill(const Logger *log, RTPSession *session);
void rtp_allow_receiving_mark(RTPSession *session);

View File

@ -13,6 +13,7 @@
#include "rtp.h"
#include "toxav_hacks.h"
#include "../toxcore/Messenger.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/logger.h"
#include "../toxcore/mono_time.h"
@ -87,6 +88,7 @@ typedef struct DecodeTimeStats {
} DecodeTimeStats;
struct ToxAV {
const Memory *mem;
Logger *log;
Tox *tox;
MSISession *msi;
@ -219,6 +221,7 @@ ToxAV *toxav_new(Tox *tox, Toxav_Err_New *error)
goto RETURN;
}
av->mem = tox->sys.mem;
av->log = tox->m->log;
av->tox = tox;
av->msi = msi_new(av->log, av->tox);
@ -994,9 +997,8 @@ static Toxav_Err_Send_Frame send_frames(const ToxAV *av, ToxAVCall *call)
is_keyframe);
if (res < 0) {
char *netstrerror = net_new_strerror(net_error());
LOGGER_WARNING(av->log, "Could not send video frame: %s", netstrerror);
net_kill_strerror(netstrerror);
Net_Strerror error_str;
LOGGER_WARNING(av->log, "Could not send video frame: %s", net_strerror(net_error(), &error_str));
return TOXAV_ERR_SEND_FRAME_RTP_FAILED;
}
}
@ -1507,7 +1509,7 @@ static bool call_prepare_transmission(ToxAVCall *call)
goto FAILURE;
}
call->audio_rtp = rtp_new(av->log, RTP_TYPE_AUDIO, av->tox, av, call->friend_number, call->bwc,
call->audio_rtp = rtp_new(av->log, av->mem, RTP_TYPE_AUDIO, av->tox, av, call->friend_number, call->bwc,
call->audio, ac_queue_message);
if (call->audio_rtp == nullptr) {
@ -1523,7 +1525,7 @@ static bool call_prepare_transmission(ToxAVCall *call)
goto FAILURE;
}
call->video_rtp = rtp_new(av->log, RTP_TYPE_VIDEO, av->tox, av, call->friend_number, call->bwc,
call->video_rtp = rtp_new(av->log, av->mem, RTP_TYPE_VIDEO, av->tox, av, call->friend_number, call->bwc,
call->video, vc_queue_message);
if (call->video_rtp == nullptr) {

View File

@ -6,6 +6,8 @@ exports_files(
"tox.h",
"tox_dispatch.h",
"tox_events.h",
"tox_log_level.h",
"tox_options.h",
"tox_private.h",
],
visibility = ["//c-toxcore:__subpackages__"],
@ -192,6 +194,7 @@ cc_library(
deps = [
":attributes",
":ccompat",
":mem",
"//c-toxcore/third_party:cmp",
],
)
@ -204,6 +207,7 @@ cc_test(
":bin_pack",
":bin_unpack",
":logger",
":mem",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
@ -766,6 +770,23 @@ cc_library(
],
)
cc_fuzz_test(
name = "net_crypto_fuzz_test",
size = "small",
testonly = True,
srcs = ["net_crypto_fuzz_test.cc"],
corpus = ["//tools/toktok-fuzzer/corpus:net_crypto_fuzz_test"],
deps = [
":DHT",
":TCP_client",
":mem_test_util",
":net_crypto",
":network",
"//c-toxcore/testing/fuzzing:fuzz_support",
"//c-toxcore/testing/fuzzing:fuzz_tox",
],
)
cc_library(
name = "onion_announce",
srcs = ["onion_announce.c"],
@ -1070,6 +1091,25 @@ cc_library(
],
)
cc_library(
name = "tox_options",
srcs = ["tox_options.c"],
hdrs = ["tox_options.h"],
copts = ["-UTOX_HIDE_DEPRECATED"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":ccompat",
":tox_log_level",
],
)
cc_library(
name = "tox_log_level",
srcs = ["tox_log_level.c"],
hdrs = ["tox_log_level.h"],
visibility = ["//c-toxcore:__subpackages__"],
)
cc_library(
name = "tox",
srcs = [
@ -1102,6 +1142,8 @@ cc_library(
":network",
":onion_client",
":state",
":tox_log_level",
":tox_options",
":util",
"//c-toxcore/toxencryptsave:defines",
"@pthread",
@ -1115,6 +1157,8 @@ cc_test(
deps = [
":crypto_core",
":tox",
":tox_log_level",
":tox_options",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],

View File

@ -30,8 +30,8 @@
/** The timeout after which a node is discarded completely. */
#define KILL_NODE_TIMEOUT (BAD_NODE_TIMEOUT + PING_INTERVAL)
/** Ping interval in seconds for each random sending of a get nodes request. */
#define GET_NODE_INTERVAL 20
/** Ping interval in seconds for each random sending of a nodes request. */
#define NODES_REQUEST_INTERVAL 20
#define MAX_PUNCHING_PORTS 48
@ -46,7 +46,7 @@
#define NAT_PING_REQUEST 0
#define NAT_PING_RESPONSE 1
/** Number of get node requests to send to quickly find close nodes. */
/** Number of node requests to send to quickly find close nodes. */
#define MAX_BOOTSTRAP_TIMES 5
// TODO(sudden6): find out why we need multiple callbacks and if we really need 32
@ -66,9 +66,9 @@ struct DHT_Friend {
uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE];
Client_data client_list[MAX_FRIEND_CLIENTS];
/* Time at which the last get_nodes request was sent. */
uint64_t lastgetnode;
/* number of times get_node packets were sent. */
/* Time at which the last nodes request was sent. */
uint64_t last_nodes_request;
/* number of times nodes request packets were sent. */
uint32_t bootstrap_times;
/* Symmetric NAT hole punching stuff. */
@ -104,7 +104,7 @@ struct DHT {
bool lan_discovery_enabled;
Client_data close_clientlist[LCLIENT_LIST];
uint64_t close_lastgetnodes;
uint64_t close_last_nodes_request;
uint32_t close_bootstrap_times;
/* DHT keypair */
@ -130,7 +130,7 @@ struct DHT {
Node_format to_bootstrap[MAX_CLOSE_TO_BOOTSTRAP_NODES];
unsigned int num_to_bootstrap;
dht_get_nodes_response_cb *get_nodes_response;
dht_nodes_response_cb *nodes_response_callback;
};
const uint8_t *dht_friend_public_key(const DHT_Friend *dht_friend)
@ -431,7 +431,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
const int ipp_size = unpack_ip_port(&nodes[num].ip_port, data + len_processed, length - len_processed, tcp_enabled);
if (ipp_size == -1) {
return -1;
break;
}
len_processed += ipp_size;
@ -450,6 +450,10 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
#endif /* NDEBUG */
}
if (num == 0 && max_num_nodes > 0 && length > 0) {
return -1;
}
if (processed_data_len != nullptr) {
*processed_data_len = len_processed;
}
@ -708,7 +712,7 @@ static void get_close_nodes_inner(
}
/**
* Find MAX_SENT_NODES nodes closest to the public_key for the send nodes request:
* Find MAX_SENT_NODES nodes closest to the public_key for the nodes request:
* put them in the nodes_list and return how many were found.
*
* want_announce: return only nodes which implement the dht announcements protocol.
@ -1131,7 +1135,7 @@ static bool is_pk_in_close_list(const DHT *dht, const uint8_t *public_key, const
ip_port);
}
/** @brief Check if the node obtained with a get_nodes with public_key should be pinged.
/** @brief Check if the node obtained from a nodes response with public_key should be pinged.
*
* NOTE: for best results call it after addto_lists.
*
@ -1139,7 +1143,7 @@ static bool is_pk_in_close_list(const DHT *dht, const uint8_t *public_key, const
* return true if it should.
*/
non_null()
static bool ping_node_from_getnodes_ok(DHT *dht, const uint8_t *public_key, const IP_Port *ip_port)
static bool ping_node_from_nodes_response_ok(DHT *dht, const uint8_t *public_key, const IP_Port *ip_port)
{
bool ret = false;
@ -1310,7 +1314,7 @@ static void returnedip_ports(DHT *dht, const IP_Port *ip_port, const uint8_t *pu
}
}
bool dht_getnodes(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id)
bool dht_send_nodes_request(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id)
{
/* Check if packet is going to be sent to ourself. */
if (pk_equal(public_key, dht->self_public_key)) {
@ -1345,20 +1349,20 @@ bool dht_getnodes(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, c
const uint8_t *shared_key = dht_get_shared_key_sent(dht, public_key);
const int len = dht_create_packet(dht->mem, dht->rng,
dht->self_public_key, shared_key, NET_PACKET_GET_NODES,
dht->self_public_key, shared_key, NET_PACKET_NODES_REQUEST,
plain, sizeof(plain), data, sizeof(data));
if (len != sizeof(data)) {
LOGGER_ERROR(dht->log, "getnodes packet encryption failed");
LOGGER_ERROR(dht->log, "nodes request packet encryption failed");
return false;
}
return sendpacket(dht->net, ip_port, data, len) > 0;
}
/** Send a send nodes response: message for IPv6 nodes */
/** Send a nodes response */
non_null()
static int sendnodes_ipv6(const DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id,
static int send_nodes_response(const DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id,
const uint8_t *sendback_data, uint16_t length, const uint8_t *shared_encryption_key)
{
/* Check if packet is going to be sent to ourself. */
@ -1396,7 +1400,7 @@ static int sendnodes_ipv6(const DHT *dht, const IP_Port *ip_port, const uint8_t
VLA(uint8_t, data, data_size);
const int len = dht_create_packet(dht->mem, dht->rng,
dht->self_public_key, shared_encryption_key, NET_PACKET_SEND_NODES_IPV6,
dht->self_public_key, shared_encryption_key, NET_PACKET_NODES_RESPONSE,
plain, 1 + nodes_length + length, data, data_size);
if (len < 0 || (uint32_t)len != data_size) {
@ -1409,7 +1413,7 @@ static int sendnodes_ipv6(const DHT *dht, const IP_Port *ip_port, const uint8_t
#define CRYPTO_NODE_SIZE (CRYPTO_PUBLIC_KEY_SIZE + sizeof(uint64_t))
non_null()
static int handle_getnodes(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata)
static int handle_nodes_request(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata)
{
DHT *const dht = (DHT *)object;
@ -1436,16 +1440,16 @@ static int handle_getnodes(void *object, const IP_Port *source, const uint8_t *p
return 1;
}
sendnodes_ipv6(dht, source, packet + 1, plain, plain + CRYPTO_PUBLIC_KEY_SIZE, sizeof(uint64_t), shared_key);
send_nodes_response(dht, source, packet + 1, plain, plain + CRYPTO_PUBLIC_KEY_SIZE, sizeof(uint64_t), shared_key);
ping_add(dht->ping, packet + 1, source);
return 0;
}
/** Return true if we sent a getnode packet to the peer associated with the supplied info. */
/** Return true if we sent a nodes request packet to the peer associated with the supplied info. */
non_null()
static bool sent_getnode_to_node(DHT *dht, const uint8_t *public_key, const IP_Port *node_ip_port, uint64_t ping_id)
static bool sent_nodes_request_to_node(DHT *dht, const uint8_t *public_key, const IP_Port *node_ip_port, uint64_t ping_id)
{
uint8_t data[sizeof(Node_format) * 2];
@ -1463,7 +1467,7 @@ static bool sent_getnode_to_node(DHT *dht, const uint8_t *public_key, const IP_P
}
non_null()
static bool handle_sendnodes_core(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
static bool handle_nodes_response_core(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
Node_format *plain_nodes, uint16_t size_plain_nodes, uint32_t *num_nodes_out)
{
DHT *const dht = (DHT *)object;
@ -1505,7 +1509,7 @@ static bool handle_sendnodes_core(void *object, const IP_Port *source, const uin
uint64_t ping_id;
memcpy(&ping_id, plain + 1 + data_size, sizeof(ping_id));
if (!sent_getnode_to_node(dht, packet + 1, source, ping_id)) {
if (!sent_nodes_request_to_node(dht, packet + 1, source, ping_id)) {
return false;
}
@ -1533,14 +1537,14 @@ static bool handle_sendnodes_core(void *object, const IP_Port *source, const uin
}
non_null()
static int handle_sendnodes_ipv6(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
static int handle_nodes_response(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
void *userdata)
{
DHT *const dht = (DHT *)object;
Node_format plain_nodes[MAX_SENT_NODES];
uint32_t num_nodes;
if (!handle_sendnodes_core(object, source, packet, length, plain_nodes, MAX_SENT_NODES, &num_nodes)) {
if (!handle_nodes_response_core(object, source, packet, length, plain_nodes, MAX_SENT_NODES, &num_nodes)) {
return 1;
}
@ -1550,11 +1554,11 @@ static int handle_sendnodes_ipv6(void *object, const IP_Port *source, const uint
for (uint32_t i = 0; i < num_nodes; ++i) {
if (ipport_isset(&plain_nodes[i].ip_port)) {
ping_node_from_getnodes_ok(dht, plain_nodes[i].public_key, &plain_nodes[i].ip_port);
ping_node_from_nodes_response_ok(dht, plain_nodes[i].public_key, &plain_nodes[i].ip_port);
returnedip_ports(dht, &plain_nodes[i].ip_port, plain_nodes[i].public_key, packet + 1);
if (dht->get_nodes_response != nullptr) {
dht->get_nodes_response(dht, &plain_nodes[i], userdata);
if (dht->nodes_response_callback != nullptr) {
dht->nodes_response_callback(dht, &plain_nodes[i], userdata);
}
}
}
@ -1767,7 +1771,7 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
if (mono_time_is_timeout(dht->mono_time, assoc->last_pinged, PING_INTERVAL)) {
const IP_Port *target = &assoc->ip_port;
const uint8_t *target_key = client->public_key;
dht_getnodes(dht, target, target_key, public_key);
dht_send_nodes_request(dht, target, target_key, public_key);
assoc->last_pinged = temp_time;
}
@ -1792,7 +1796,7 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
sort_client_list(dht->mem, list, dht->cur_time, list_count, public_key);
}
if (num_nodes > 0 && (mono_time_is_timeout(dht->mono_time, *lastgetnode, GET_NODE_INTERVAL)
if (num_nodes > 0 && (mono_time_is_timeout(dht->mono_time, *lastgetnode, NODES_REQUEST_INTERVAL)
|| *bootstrap_times < MAX_BOOTSTRAP_TIMES)) {
uint32_t rand_node = random_range_u32(dht->rng, num_nodes);
@ -1802,7 +1806,7 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
const IP_Port *target = &assoc_list[rand_node]->ip_port;
const uint8_t *target_key = client_list[rand_node]->public_key;
dht_getnodes(dht, target, target_key, public_key);
dht_send_nodes_request(dht, target, target_key, public_key);
*lastgetnode = temp_time;
++*bootstrap_times;
@ -1815,7 +1819,7 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
/** @brief Ping each client in the "friends" list every PING_INTERVAL seconds.
*
* Send a get nodes request every GET_NODE_INTERVAL seconds to a random good
* Send a nodes request every NODES_REQUEST_INTERVAL seconds to a random good
* node for each "friend" in our "friends" list.
*/
non_null()
@ -1825,31 +1829,31 @@ static void do_dht_friends(DHT *dht)
DHT_Friend *const dht_friend = &dht->friends_list[i];
for (size_t j = 0; j < dht_friend->num_to_bootstrap; ++j) {
dht_getnodes(dht, &dht_friend->to_bootstrap[j].ip_port, dht_friend->to_bootstrap[j].public_key, dht_friend->public_key);
dht_send_nodes_request(dht, &dht_friend->to_bootstrap[j].ip_port, dht_friend->to_bootstrap[j].public_key, dht_friend->public_key);
}
dht_friend->num_to_bootstrap = 0;
do_ping_and_sendnode_requests(dht, &dht_friend->lastgetnode, dht_friend->public_key, dht_friend->client_list,
do_ping_and_sendnode_requests(dht, &dht_friend->last_nodes_request, dht_friend->public_key, dht_friend->client_list,
MAX_FRIEND_CLIENTS, &dht_friend->bootstrap_times, true);
}
}
/** @brief Ping each client in the close nodes list every PING_INTERVAL seconds.
*
* Send a get nodes request every GET_NODE_INTERVAL seconds to a random good node in the list.
* Send a nodes request every NODES_REQUEST_INTERVAL seconds to a random good node in the list.
*/
non_null()
static void do_close(DHT *dht)
{
for (size_t i = 0; i < dht->num_to_bootstrap; ++i) {
dht_getnodes(dht, &dht->to_bootstrap[i].ip_port, dht->to_bootstrap[i].public_key, dht->self_public_key);
dht_send_nodes_request(dht, &dht->to_bootstrap[i].ip_port, dht->to_bootstrap[i].public_key, dht->self_public_key);
}
dht->num_to_bootstrap = 0;
const uint8_t not_killed = do_ping_and_sendnode_requests(
dht, &dht->close_lastgetnodes, dht->self_public_key, dht->close_clientlist, LCLIENT_LIST, &dht->close_bootstrap_times,
dht, &dht->close_last_nodes_request, dht->self_public_key, dht->close_clientlist, LCLIENT_LIST, &dht->close_bootstrap_times,
false);
if (not_killed != 0) {
@ -1883,7 +1887,7 @@ bool dht_bootstrap(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key)
return true;
}
return dht_getnodes(dht, ip_port, public_key, dht->self_public_key);
return dht_send_nodes_request(dht, ip_port, public_key, dht->self_public_key);
}
bool dht_bootstrap_from_address(DHT *dht, const char *address, bool ipv6enabled, bool dns_enabled,
@ -2530,9 +2534,9 @@ static int cryptopacket_handle(void *object, const IP_Port *source, const uint8_
return 1;
}
void dht_callback_get_nodes_response(DHT *dht, dht_get_nodes_response_cb *function)
void dht_callback_nodes_response(DHT *dht, dht_nodes_response_cb *function)
{
dht->get_nodes_response = function;
dht->nodes_response_callback = function;
}
non_null(1, 2, 3) nullable(5)
@ -2593,8 +2597,8 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
return nullptr;
}
networking_registerhandler(dht->net, NET_PACKET_GET_NODES, &handle_getnodes, dht);
networking_registerhandler(dht->net, NET_PACKET_SEND_NODES_IPV6, &handle_sendnodes_ipv6, dht);
networking_registerhandler(dht->net, NET_PACKET_NODES_REQUEST, &handle_nodes_request, dht);
networking_registerhandler(dht->net, NET_PACKET_NODES_RESPONSE, &handle_nodes_response, dht);
networking_registerhandler(dht->net, NET_PACKET_CRYPTO, &cryptopacket_handle, dht);
networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, &handle_lan_discovery, dht);
cryptopacket_registerhandler(dht, CRYPTO_PACKET_NAT_PING, &handle_nat_ping, dht);
@ -2672,8 +2676,8 @@ void kill_dht(DHT *dht)
return;
}
networking_registerhandler(dht->net, NET_PACKET_GET_NODES, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_SEND_NODES_IPV6, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_NODES_REQUEST, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_NODES_RESPONSE, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_CRYPTO, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, nullptr, nullptr);
cryptopacket_registerhandler(dht, CRYPTO_PACKET_NAT_PING, nullptr, nullptr);

View File

@ -36,7 +36,7 @@ extern "C" {
#define MAX_CLOSE_TO_BOOTSTRAP_NODES 8
/** The max number of nodes to send with send nodes. */
/** The max number of nodes to send with nodes response. */
#define MAX_SENT_NODES 4
/** Ping timeout in seconds */
@ -259,21 +259,21 @@ non_null()
const uint8_t *dht_get_shared_key_sent(DHT *dht, const uint8_t *public_key);
/**
* Sends a getnodes request to `ip_port` with the public key `public_key` for nodes
* Sends a nodes request to `ip_port` with the public key `public_key` for nodes
* that are close to `client_id`.
*
* @retval true on success.
*/
non_null()
bool dht_getnodes(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id);
bool dht_send_nodes_request(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id);
typedef void dht_ip_cb(void *object, int32_t number, const IP_Port *ip_port);
typedef void dht_get_nodes_response_cb(const DHT *dht, const Node_format *node, void *user_data);
typedef void dht_nodes_response_cb(const DHT *dht, const Node_format *node, void *user_data);
/** Sets the callback to be triggered on a getnodes response. */
/** Sets the callback to be triggered on a nodes response. */
non_null(1) nullable(2)
void dht_callback_get_nodes_response(DHT *dht, dht_get_nodes_response_cb *function);
void dht_callback_nodes_response(DHT *dht, dht_nodes_response_cb *function);
/** @brief Add a new friend to the friends list.
* @param public_key must be CRYPTO_PUBLIC_KEY_SIZE bytes long.
@ -390,7 +390,7 @@ void do_dht(DHT *dht);
* Use these two functions to bootstrap the client.
*/
/**
* @brief Sends a "get nodes" request to the given node with ip, port and public_key
* @brief Sends a "nodes request" to the given node with ip, port and public_key
* to setup connections
*/
non_null()
@ -398,7 +398,7 @@ bool dht_bootstrap(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key);
/** @brief Resolves address into an IP address.
*
* If successful, sends a "get nodes" request to the given node with ip, port
* If successful, sends a "nodes request" to the given node with ip, port
* and public_key to setup connections
*
* @param address can be a hostname or an IP address (IPv4 or IPv6).

View File

@ -1,26 +1,20 @@
lib_LTLIBRARIES += libtoxcore.la
libtoxcore_la_include_HEADERS = \
../toxcore/tox.h
../toxcore/tox.h \
../toxcore/tox_options.h
libtoxcore_la_includedir = $(includedir)/tox
libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \
../third_party/cmp/cmp.h \
../toxcore/attributes.h \
../toxcore/bin_pack.c \
../toxcore/bin_pack.h \
../toxcore/bin_unpack.c \
../toxcore/bin_unpack.h \
../toxcore/ccompat.c \
../toxcore/ccompat.h \
../toxcore/events/conference_connected.c \
../toxcore/events/conference_invite.c \
../toxcore/events/conference_message.c \
../toxcore/events/conference_peer_list_changed.c \
../toxcore/events/conference_peer_name.c \
../toxcore/events/conference_title.c \
../toxcore/events/dht_get_nodes_response.c \
../toxcore/events/dht_nodes_response.c \
../toxcore/events/events_alloc.c \
../toxcore/events/events_alloc.h \
../toxcore/events/file_chunk_request.c \
@ -56,97 +50,108 @@ libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \
../toxcore/events/group_topic.c \
../toxcore/events/group_topic_lock.c \
../toxcore/events/group_voice_state.c \
../toxcore/DHT.h \
../toxcore/DHT.c \
../toxcore/mem.h \
../toxcore/mem.c \
../toxcore/mono_time.h \
../toxcore/mono_time.c \
../toxcore/network.h \
../toxcore/network.c \
../toxcore/crypto_core.h \
../toxcore/crypto_core.c \
../toxcore/crypto_core_pack.h \
../toxcore/announce.c \
../toxcore/announce.h \
../toxcore/attributes.h \
../toxcore/bin_pack.c \
../toxcore/bin_pack.h \
../toxcore/bin_unpack.c \
../toxcore/bin_unpack.h \
../toxcore/ccompat.c \
../toxcore/ccompat.h \
../toxcore/crypto_core_pack.c \
../toxcore/timed_auth.h \
../toxcore/timed_auth.c \
../toxcore/ping_array.h \
../toxcore/ping_array.c \
../toxcore/net_crypto.h \
../toxcore/net_crypto.c \
../toxcore/net_profile.c \
../toxcore/net_profile.h \
../toxcore/friend_requests.h \
../toxcore/friend_requests.c \
../toxcore/LAN_discovery.h \
../toxcore/LAN_discovery.c \
../toxcore/friend_connection.h \
../toxcore/crypto_core_pack.h \
../toxcore/crypto_core.c \
../toxcore/crypto_core.h \
../toxcore/DHT.c \
../toxcore/DHT.h \
../toxcore/forwarding.c \
../toxcore/forwarding.h \
../toxcore/friend_connection.c \
../toxcore/Messenger.h \
../toxcore/Messenger.c \
../toxcore/ping.h \
../toxcore/ping.c \
../toxcore/shared_key_cache.h \
../toxcore/shared_key_cache.c \
../toxcore/sort.h \
../toxcore/sort.c \
../toxcore/state.h \
../toxcore/state.c \
../toxcore/tox.h \
../toxcore/tox.c \
../toxcore/tox_dispatch.h \
../toxcore/tox_dispatch.c \
../toxcore/tox_event.h \
../toxcore/tox_event.c \
../toxcore/tox_events.h \
../toxcore/tox_events.c \
../toxcore/tox_pack.h \
../toxcore/tox_pack.c \
../toxcore/tox_unpack.h \
../toxcore/tox_unpack.c \
../toxcore/tox_private.c \
../toxcore/tox_private.h \
../toxcore/tox_struct.h \
../toxcore/tox_api.c \
../toxcore/util.h \
../toxcore/util.c \
../toxcore/group.h \
../toxcore/group.c \
../toxcore/group_announce.h \
../toxcore/friend_connection.h \
../toxcore/friend_requests.c \
../toxcore/friend_requests.h \
../toxcore/group_announce.c \
../toxcore/group_onion_announce.c \
../toxcore/group_onion_announce.h \
../toxcore/group_chats.h \
../toxcore/group_announce.h \
../toxcore/group_chats.c \
../toxcore/group_chats.h \
../toxcore/group_common.h \
../toxcore/group_connection.c \
../toxcore/group_connection.h \
../toxcore/group_pack.c \
../toxcore/group_pack.h \
../toxcore/group_moderation.c \
../toxcore/group_moderation.h \
../toxcore/onion.h \
../toxcore/onion.c \
../toxcore/logger.h \
../toxcore/logger.c \
../toxcore/onion_announce.h \
../toxcore/onion_announce.c \
../toxcore/onion_client.h \
../toxcore/onion_client.c \
../toxcore/announce.h \
../toxcore/announce.c \
../toxcore/forwarding.h \
../toxcore/forwarding.c \
../toxcore/TCP_client.h \
../toxcore/TCP_client.c \
../toxcore/TCP_common.h \
../toxcore/TCP_common.c \
../toxcore/TCP_server.h \
../toxcore/TCP_server.c \
../toxcore/TCP_connection.h \
../toxcore/TCP_connection.c \
../toxcore/group_onion_announce.c \
../toxcore/group_onion_announce.h \
../toxcore/group_pack.c \
../toxcore/group_pack.h \
../toxcore/group.c \
../toxcore/group.h \
../toxcore/LAN_discovery.c \
../toxcore/LAN_discovery.h \
../toxcore/list.c \
../toxcore/list.h
../toxcore/list.h \
../toxcore/logger.c \
../toxcore/logger.h \
../toxcore/mem.c \
../toxcore/mem.h \
../toxcore/Messenger.c \
../toxcore/Messenger.h \
../toxcore/mono_time.c \
../toxcore/mono_time.h \
../toxcore/net_crypto.c \
../toxcore/net_crypto.h \
../toxcore/net_profile.c \
../toxcore/net_profile.h \
../toxcore/network.c \
../toxcore/network.h \
../toxcore/onion_announce.c \
../toxcore/onion_announce.h \
../toxcore/onion_client.c \
../toxcore/onion_client.h \
../toxcore/onion.c \
../toxcore/onion.h \
../toxcore/ping_array.c \
../toxcore/ping_array.h \
../toxcore/ping.c \
../toxcore/ping.h \
../toxcore/shared_key_cache.c \
../toxcore/shared_key_cache.h \
../toxcore/sort.c \
../toxcore/sort.h \
../toxcore/state.c \
../toxcore/state.h \
../toxcore/TCP_client.c \
../toxcore/TCP_client.h \
../toxcore/TCP_common.c \
../toxcore/TCP_common.h \
../toxcore/TCP_connection.c \
../toxcore/TCP_connection.h \
../toxcore/TCP_server.c \
../toxcore/TCP_server.h \
../toxcore/timed_auth.c \
../toxcore/timed_auth.h \
../toxcore/tox_api.c \
../toxcore/tox_dispatch.c \
../toxcore/tox_dispatch.h \
../toxcore/tox_event.c \
../toxcore/tox_event.h \
../toxcore/tox_events.c \
../toxcore/tox_events.h \
../toxcore/tox_log_level.c \
../toxcore/tox_log_level.h \
../toxcore/tox_options.c \
../toxcore/tox_options.h \
../toxcore/tox_pack.c \
../toxcore/tox_pack.h \
../toxcore/tox_private.c \
../toxcore/tox_private.h \
../toxcore/tox_struct.h \
../toxcore/tox_unpack.c \
../toxcore/tox_unpack.h \
../toxcore/tox.c \
../toxcore/tox.h \
../toxcore/util.c \
../toxcore/util.h
libtoxcore_la_CFLAGS = -I$(top_srcdir) \
-I$(top_srcdir)/toxcore \

View File

@ -3171,7 +3171,7 @@ static bool handle_groups_load(void *obj, Bin_Unpack *bu)
non_null()
static State_Load_Status groups_load(Messenger *m, const uint8_t *data, uint32_t length)
{
if (!bin_unpack_obj(handle_groups_load, m, data, length)) {
if (!bin_unpack_obj(m->mem, handle_groups_load, m, data, length)) {
LOGGER_ERROR(m->log, "msgpack failed to unpack groupchats array");
return STATE_LOAD_STATUS_ERROR;
}

View File

@ -236,7 +236,7 @@ int read_tcp_packet(
* return -1 on failure.
*/
non_null()
static uint16_t read_tcp_length(const Logger *logger, const Memory *mem, const Network *ns, Socket sock, const IP_Port *ip_port)
static uint16_t read_tcp_length(const Logger *logger, const Network *ns, Socket sock, const IP_Port *ip_port)
{
const uint16_t count = net_socket_data_recv_buffer(ns, sock);
@ -275,7 +275,7 @@ int read_packet_tcp_secure_connection(
uint16_t max_len, const IP_Port *ip_port)
{
if (*next_packet_length == 0) {
const uint16_t len = read_tcp_length(logger, mem, ns, sock, ip_port);
const uint16_t len = read_tcp_length(logger, ns, sock, ip_port);
if (len == (uint16_t) -1) {
return -1;

View File

@ -920,7 +920,7 @@ static int accept_connection(TCP_Server *tcp_server, Socket sock)
}
non_null()
static Socket new_listening_tcp_socket(const Logger *logger, const Network *ns, Family family, uint16_t port)
static Socket new_listening_tcp_socket(const Logger *logger, const Memory *mem, const Network *ns, Family family, uint16_t port)
{
const Socket sock = net_socket(ns, family, TOX_SOCK_STREAM, TOX_PROTO_TCP);
@ -942,10 +942,9 @@ static Socket new_listening_tcp_socket(const Logger *logger, const Network *ns,
ok = ok && bind_to_port(ns, sock, family, port) && (net_listen(ns, sock, TCP_MAX_BACKLOG) == 0);
if (!ok) {
char *const error = net_new_strerror(net_error());
Net_Strerror error_str;
LOGGER_WARNING(logger, "could not bind to TCP port %d (family = %d): %s",
port, family.value, error != nullptr ? error : "(null)");
net_kill_strerror(error);
port, family.value, net_strerror(net_error(), &error_str));
kill_sock(ns, sock);
return net_invalid_socket();
}
@ -1015,7 +1014,7 @@ TCP_Server *new_tcp_server(const Logger *logger, const Memory *mem, const Random
const Family family = ipv6_enabled ? net_family_ipv6() : net_family_ipv4();
for (uint32_t i = 0; i < num_sockets; ++i) {
const Socket sock = new_listening_tcp_socket(logger, ns, family, ports[i]);
const Socket sock = new_listening_tcp_socket(logger, mem, ns, family, ports[i]);
if (!sock_valid(sock)) {
continue;

View File

@ -3,11 +3,10 @@
#include <gtest/gtest.h>
#include <array>
#include <memory>
#include <vector>
#include "bin_unpack.h"
#include "logger.h"
#include "mem.h"
namespace {
@ -24,6 +23,7 @@ TEST(BinPack, TooSmallBufferIsNotExceeded)
TEST(BinPack, PackedUint64CanBeUnpacked)
{
const Memory *mem = os_memory();
const uint64_t orig = 1234567812345678LL;
std::array<uint8_t, 8> buf;
EXPECT_TRUE(bin_pack_obj(
@ -34,6 +34,7 @@ TEST(BinPack, PackedUint64CanBeUnpacked)
uint64_t unpacked = 0;
EXPECT_TRUE(bin_unpack_obj(
mem,
[](void *obj, Bin_Unpack *bu) {
return bin_unpack_u64_b(bu, static_cast<uint64_t *>(obj));
},
@ -43,6 +44,7 @@ TEST(BinPack, PackedUint64CanBeUnpacked)
TEST(BinPack, MsgPackedUint8CanBeUnpackedAsUint32)
{
const Memory *mem = os_memory();
const uint8_t orig = 123;
std::array<uint8_t, 2> buf;
EXPECT_TRUE(bin_pack_obj(
@ -53,6 +55,7 @@ TEST(BinPack, MsgPackedUint8CanBeUnpackedAsUint32)
uint32_t unpacked = 0;
EXPECT_TRUE(bin_unpack_obj(
mem,
[](void *obj, Bin_Unpack *bu) { return bin_unpack_u32(bu, static_cast<uint32_t *>(obj)); },
&unpacked, buf.data(), buf.size()));
EXPECT_EQ(unpacked, 123);
@ -60,6 +63,7 @@ TEST(BinPack, MsgPackedUint8CanBeUnpackedAsUint32)
TEST(BinPack, MsgPackedUint32CanBeUnpackedAsUint8IfSmallEnough)
{
const Memory *mem = os_memory();
const uint32_t orig = 123;
std::array<uint8_t, 2> buf;
EXPECT_TRUE(bin_pack_obj(
@ -70,6 +74,7 @@ TEST(BinPack, MsgPackedUint32CanBeUnpackedAsUint8IfSmallEnough)
uint8_t unpacked = 0;
EXPECT_TRUE(bin_unpack_obj(
mem,
[](void *obj, Bin_Unpack *bu) { return bin_unpack_u08(bu, static_cast<uint8_t *>(obj)); },
&unpacked, buf.data(), buf.size()));
@ -78,6 +83,7 @@ TEST(BinPack, MsgPackedUint32CanBeUnpackedAsUint8IfSmallEnough)
TEST(BinPack, LargeMsgPackedUint32CannotBeUnpackedAsUint8)
{
const Memory *mem = os_memory();
const uint32_t orig = 1234567;
std::array<uint8_t, 5> buf;
EXPECT_TRUE(bin_pack_obj(
@ -88,12 +94,14 @@ TEST(BinPack, LargeMsgPackedUint32CannotBeUnpackedAsUint8)
uint8_t unpacked = 0;
EXPECT_FALSE(bin_unpack_obj(
mem,
[](void *obj, Bin_Unpack *bu) { return bin_unpack_u08(bu, static_cast<uint8_t *>(obj)); },
&unpacked, buf.data(), buf.size()));
}
TEST(BinPack, BinCanHoldPackedInts)
{
const Memory *mem = os_memory();
struct Stuff {
uint64_t u64;
uint16_t u16;
@ -113,6 +121,7 @@ TEST(BinPack, BinCanHoldPackedInts)
Stuff unpacked;
EXPECT_TRUE(bin_unpack_obj(
mem,
[](void *obj, Bin_Unpack *bu) {
Stuff *stuff = static_cast<Stuff *>(obj);
uint32_t size;
@ -128,6 +137,7 @@ TEST(BinPack, BinCanHoldPackedInts)
TEST(BinPack, BinCanHoldArbitraryData)
{
const Memory *mem = os_memory();
std::array<uint8_t, 7> buf;
EXPECT_TRUE(bin_pack_obj(
[](const void *obj, const Logger *logger, Bin_Pack *bp) {
@ -138,6 +148,7 @@ TEST(BinPack, BinCanHoldArbitraryData)
std::array<uint8_t, 5> str;
EXPECT_TRUE(bin_unpack_obj(
mem,
[](void *obj, Bin_Unpack *bu) {
uint8_t *data = static_cast<uint8_t *>(obj);
return bin_unpack_bin_fixed(bu, data, 5);
@ -148,10 +159,12 @@ TEST(BinPack, BinCanHoldArbitraryData)
TEST(BinPack, OversizedArrayFailsUnpack)
{
const Memory *mem = os_memory();
std::array<uint8_t, 1> buf = {0x91};
uint32_t size;
EXPECT_FALSE(bin_unpack_obj(
mem,
[](void *obj, Bin_Unpack *bu) {
uint32_t *size_ptr = static_cast<uint32_t *>(obj);
return bin_unpack_array(bu, size_ptr);

View File

@ -5,14 +5,16 @@
#include "bin_unpack.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../third_party/cmp/cmp.h"
#include "attributes.h"
#include "ccompat.h"
#include "mem.h"
struct Bin_Unpack {
const Memory *mem;
const uint8_t *bytes;
uint32_t bytes_size;
cmp_ctx_t ctx;
@ -54,17 +56,18 @@ static size_t null_writer(cmp_ctx_t *ctx, const void *data, size_t count)
}
non_null()
static void bin_unpack_init(Bin_Unpack *bu, const uint8_t *buf, uint32_t buf_size)
static void bin_unpack_init(Bin_Unpack *bu, const Memory *mem, const uint8_t *buf, uint32_t buf_size)
{
bu->mem = mem;
bu->bytes = buf;
bu->bytes_size = buf_size;
cmp_init(&bu->ctx, bu, buf_reader, buf_skipper, null_writer);
}
bool bin_unpack_obj(bin_unpack_cb *callback, void *obj, const uint8_t *buf, uint32_t buf_size)
bool bin_unpack_obj(const Memory *mem, bin_unpack_cb *callback, void *obj, const uint8_t *buf, uint32_t buf_size)
{
Bin_Unpack bu;
bin_unpack_init(&bu, buf, buf_size);
bin_unpack_init(&bu, mem, buf, buf_size);
return callback(obj, &bu);
}
@ -120,10 +123,14 @@ bool bin_unpack_bin(Bin_Unpack *bu, uint8_t **data_ptr, uint32_t *data_length_pt
// There aren't as many bytes as this bin claims to want to allocate.
return false;
}
uint8_t *const data = (uint8_t *)malloc(bin_size);
uint8_t *const data = (uint8_t *)mem_balloc(bu->mem, bin_size);
if (data == nullptr) {
return false;
}
if (!bin_unpack_bin_b(bu, data, bin_size)) {
free(data);
mem_delete(bu->mem, data);
return false;
}

Some files were not shown because too many files have changed in this diff Show More