Compare commits

..

No commits in common. "dc7e6d57db22a9fa86223ce62bd9d52fcafd418b" and "fd4c16d090fa334ffe36b4be7961c46a800c2038" have entirely different histories.

1595 changed files with 1343 additions and 387726 deletions

1
.github/FUNDING.yml vendored
View File

@ -1 +0,0 @@
github: Green-Sky

View File

@ -1,327 +0,0 @@
name: ContinuousDelivery
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
BUILD_TYPE: RelWithDebInfo
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
linux-ubuntu:
timeout-minutes: 10
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: sudo apt update && sudo apt -y install libsodium-dev cmake
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
- name: Determine tag name
id: tag
shell: bash
# taken from llama.cpp
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Compress artifacts
shell: bash
run: |
tar -czvf ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz -C ${{github.workspace}}/build/bin/ .
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64
# TODO: do propper packing
path: |
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz
android:
timeout-minutes: 30
# contains sections copied from sdl repo
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- vcpkg_toolkit: arm64-android
ndk_abi: arm64-v8a
- vcpkg_toolkit: x64-android
ndk_abi: x86_64
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: nttld/setup-ndk@v1
id: setup_ndk
with:
local-cache: false # https://github.com/nttld/setup-ndk/issues/518
ndk-version: r26d
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: update vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
- name: Install Dependencies (host)
run: sudo apt update && sudo apt -y install cmake pkg-config nasm
- name: Install Dependencies (target)
env:
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
run: vcpkg install --triplet ${{matrix.platform.vcpkg_toolkit}} --overlay-ports=vcpkg/ports libsodium opus libvpx libpng libjpeg-turbo
# vcpkg scripts root /usr/local/share/vcpkg/scripts
- name: Configure CMake
env:
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{matrix.platform.vcpkg_toolkit}} -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=${{matrix.platform.ndk_abi}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDLIMAGE_JPG_SHARED=OFF -DSDLIMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON
- name: Build (tomato)
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
- name: Build (SDL3-jar) (workaround)
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t SDL3-jar
- name: Build (apk)
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato-apk
- name: Determine tag name
id: tag
shell: bash
# taken from llama.cpp
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: rename apk
id: rename_apk
shell: bash
run: mv "${{github.workspace}}/build/android/tomato.apk" "${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-Android-${{matrix.platform.ndk_abi}}.apk"
- uses: actions/upload-artifact@v4
with:
name: ${{github.event.repository.name}}-${{steps.tag.outputs.name}}-${{runner.os}}-Android-${{matrix.platform.ndk_abi}}
path: |
${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-Android-${{matrix.platform.ndk_abi}}.apk
windows:
timeout-minutes: 15
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
#- name: update vcpkg
# shell: bash
# run: |
# cd C:/vcpkg
# git pull
- name: Install Dependencies
run: vcpkg install pkgconf:x64-windows libsodium:x64-windows-static pthreads:x64-windows-static opus:x64-windows-static libvpx:x64-windows-static
# setup vs env
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
## sdl_image vendored needs nasm for dav1d
#- uses: ilammy/setup-nasm@v1
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDLIMAGE_VENDORED=ON -DSDLIMAGE_DEPS_SHARED=ON -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tomato
- name: Determine tag name
id: tag
shell: bash
# taken from llama.cpp
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Clean temporary artifacts
# msvc sometimes produces .ilk files, which are used for linking only
shell: powershell
run: |
Remove-Item "${{github.workspace}}/build/bin/*.ilk"
- name: Compress artifacts
shell: powershell
run: |
Compress-Archive -Path ${{github.workspace}}/build/bin/* -Destination ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64.zip
- uses: actions/upload-artifact@v4
with:
name: ${{github.event.repository.name}}-${{steps.tag.outputs.name}}-${{runner.os}}-msvc-x86_64
# TODO: do propper packing
path: |
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64.zip
windows-asan:
timeout-minutes: 15
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
#- name: update vcpkg
# shell: bash
# run: |
# cd C:/vcpkg
# git pull
- name: Install Dependencies
run: vcpkg install pkgconf:x64-windows libsodium:x64-windows-static pthreads:x64-windows-static opus:x64-windows-static libvpx:x64-windows-static
# setup vs env
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
## sdl_image vendored needs nasm for dav1d
#- uses: ilammy/setup-nasm@v1
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDLIMAGE_VENDORED=ON -DSDLIMAGE_DEPS_SHARED=ON -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
- name: Determine tag name
id: tag
shell: bash
# taken from llama.cpp
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Clean temporary artifacts
# msvc sometimes produces .ilk files, which are used for linking only
shell: powershell
run: |
Remove-Item "${{github.workspace}}/build/bin/*.ilk"
- name: Compress artifacts
shell: powershell
run: |
Compress-Archive -Path ${{github.workspace}}/build/bin/* -Destination ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64.zip
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64
# TODO: do propper packing
path: |
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64.zip
release:
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) }}
runs-on: ubuntu-latest
needs:
- linux-ubuntu
- android
- windows
- windows-asan
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Determine tag name
id: tag
shell: bash
# taken from llama.cpp
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
id: download-artifact
uses: actions/download-artifact@v4
with:
path: ./artifacts/
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tag.outputs.name }}
shell: bash
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${tag#v}" \
--notes="preview build of the latest commit" \
--prerelease
- name: Upload artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tag.outputs.name }}
shell: bash
run: |
ls -laR ./artifacts
gh release upload "$tag" ./artifacts/*/* \
--repo="$GITHUB_REPOSITORY"

View File

@ -1,147 +1,200 @@
name: ContinuousIntegration name: ci
on: on:
push:
branches: [ master ]
pull_request: pull_request:
branches: [ master ] branches: [master]
env: # Cancel old PR builds when pushing new commits.
BUILD_TYPE: Debug concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
linux: common:
timeout-minutes: 10 uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master
analysis:
strategy:
fail-fast: false
matrix:
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, freebsd, misra, modules, pkgsrc, rpm, slimcc, sparse, tcc, tokstyle]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - name: Set up Docker Buildx
with: uses: docker/setup-buildx-action@v3
submodules: recursive with:
driver: docker
- name: Install Dependencies - name: Build toxchat/c-toxcore:sources
run: sudo apt update && sudo apt -y install libsodium-dev cmake uses: docker/build-push-action@v5
with:
- name: Configure CMake file: other/docker/sources/sources.Dockerfile
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} tags: toxchat/c-toxcore:sources
- name: Docker Build
- name: Build uses: docker/build-push-action@v5
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato with:
file: other/docker/${{ matrix.tool }}/${{ matrix.tool }}.Dockerfile
android:
timeout-minutes: 30
# contains sections copied from sdl repo
coverage-linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build, test, and upload coverage
run: other/docker/coverage/run
generate-events:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run generate_event_c
run: |
other/event_tooling/run
git diff --exit-code
cimplefmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run cimplefmt
run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]")
build-android:
runs-on: ubuntu-latest
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:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build and test
run: .github/scripts/cmake-osx
build-windows-msvc:
strategy: strategy:
matrix: matrix:
platform: version: [2019, 2022]
- vcpkg_toolkit: arm64-android runs-on: windows-${{ matrix.version }}
ndk_abi: arm64-v8a env:
- vcpkg_toolkit: x64-android VCPKG_ROOT: "C:/vcpkg"
ndk_abi: x86_64 VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Export GitHub Actions cache environment variables
- uses: nttld/setup-ndk@v1 uses: actions/github-script@v7
id: setup_ndk with:
with: script: |
local-cache: false # https://github.com/nttld/setup-ndk/issues/518 core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
ndk-version: r26d core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Configure CMake
- uses: actions/setup-java@v4 run: cmake --preset windows-default
with: - name: Build
distribution: 'temurin' run: cmake --build _build -j $([int]$env:NUMBER_OF_PROCESSORS+2)
java-version: '17' - name: Test
run: |
- name: update vcpkg cd _build
run: | ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 --build-config Debug
git clone https://github.com/microsoft/vcpkg.git
- name: Install Dependencies (host)
run: sudo apt update && sudo apt -y install cmake pkg-config nasm
- name: Install Dependencies (target)
env:
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
run: vcpkg install --triplet ${{matrix.platform.vcpkg_toolkit}} --overlay-ports=vcpkg/ports libsodium opus libvpx libpng libjpeg-turbo
# vcpkg scripts root /usr/local/share/vcpkg/scripts
- name: Configure CMake
env:
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{matrix.platform.vcpkg_toolkit}} -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=${{matrix.platform.ndk_abi}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDLIMAGE_JPG_SHARED=OFF -DSDLIMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON
- name: Build (tomato)
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
- name: Build (SDL3-jar) (workaround)
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t SDL3-jar
- name: Build (apk)
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato-apk
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{matrix.platform.vcpkg_toolkit}}
# TODO: do propper packing
path: |
${{github.workspace}}/build/android/tomato.apk
macos:
timeout-minutes: 10
runs-on: macos-latest
build-netbsd:
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Test in NetBSD
id: test
uses: vmactions/netbsd-vm@v1
with:
usesh: true
copyback: false
prepare:
/usr/sbin/pkg_add
cmake
googletest
libconfig
libopus
libsodium
libvpx
pkg-config
- name: Install Dependencies run: |
run: brew install libsodium # TODO(iphydf): Investigate NetBSD failures on these tests.
sed -Ei -e '/\((TCP|dht_getnodes_api)\)/s/^/#/' auto_tests/CMakeLists.txt
- name: Configure CMake cmake . \
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DMIN_LOGGER_LEVEL=TRACE \
-DMUST_BUILD_TOXAV=ON \
- name: Build -DNON_HERMETIC_TESTS=ON \
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato -DTEST_TIMEOUT_SECONDS=90 \
-DUSE_IPV6=OFF \
windows: -DAUTOTEST=ON
timeout-minutes: 15 cmake --build . --target install
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
runs-on: windows-latest
build-freebsd:
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
copyback: false
prepare:
PAGER=cat ASSUME_ALWAYS_YES=YES pkg install
cmake
git
gmake
googletest
libconfig
libsodium
libvpx
opus
pkgconf
#- name: update vcpkg run: |
# shell: bash # TODO(iphydf): Investigate FreeBSD failures on these tests.
# run: | sed -Ei -e '/\(dht_getnodes_api\)/s/^/#/' auto_tests/CMakeLists.txt
# cd C:/vcpkg cmake . \
# git pull -DMIN_LOGGER_LEVEL=TRACE \
-DMUST_BUILD_TOXAV=ON \
- name: Install Dependencies -DNON_HERMETIC_TESTS=ON \
run: vcpkg install pkgconf:x64-windows libsodium:x64-windows-static pthreads:x64-windows-static opus:x64-windows-static libvpx:x64-windows-static -DTEST_TIMEOUT_SECONDS=50 \
-DUSE_IPV6=OFF \
# setup vs env -DAUTOTEST=ON
- uses: ilammy/msvc-dev-cmd@v1 cmake --build . --target install
with: ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
arch: amd64
## sdl_image vendored needs nasm for dav1d
#- uses: ilammy/setup-nasm@v1
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDLIMAGE_VENDORED=ON -DSDLIMAGE_DEPS_SHARED=ON -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install mypy
run: pip install mypy
- name: Run mypy
run: |
(find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \
| xargs -n1 -P8 mypy --strict

119
.gitignore vendored
View File

@ -1,26 +1,101 @@
.vs/ # OS files
*.o
*.swp
~*
*~
.idea/
cmake-build-debug/
cmake-build-debugandtest/
cmake-build-release/
*.stackdump
*.coredump
compile_commands.json
/build*
/result*
.clangd
.cache
.DS_Store .DS_Store
.AppleDouble .DS_Store?
.LSOverride ._*
.mypy_cache
.Spotlight-V100
.Trash*
Icon?
ethumbs.db
Thumbs.db
*.tmp
CMakeLists.txt.user* # Make
/_build
/_install
/tox-0.0.0*
/.vs
/CppProperties.json
CMakeCache.txt CMakeCache.txt
CMakeFiles
Makefile
!/other/rpm/Makefile
cmake_install.cmake
install_manifest.txt
tags
Makefile.in
CMakeLists.txt.user
DartConfiguration.tcl
CTestTestfile.cmake
*.pc
*.tox # Testing
imgui.ini /amalgamation.*
testing/data
*~
# Vim
*.swp
# Object files
*.o
*.lo
*.a
# Executables
*.exe
*.out
*.app
*.la
# Libraries
*.so
# Misc (?)
m4/*
configure
configure_aux
!m4/pkg.m4
aclocal.m4
config.h*
config.log
config.status
stamp-h1
autom4te.cache
libtool
.deps
.libs
.dirstamp
build/
*.nvim*
*.vim*
# kdevelop
.kdev/
*.kdev*
# VScode
.vscode/
# Netbeans
nbproject
# astyle
*.orig
# Android buildscript
android-toolchain-*
toxcore-android-*
# cscope files list
cscope.files
# rpm
tox.spec
# clangd
.cache/
compile_commands.json
/infer
.idea/

31
.gitmodules vendored
View File

@ -1,28 +1,3 @@
[submodule "external/toxcore/c-toxcore/third_party/cmp"] [submodule "third_party/cmp"]
path = external/toxcore/c-toxcore/third_party/cmp path = third_party/cmp
url = https://github.com/camgunz/cmp.git url = https://github.com/camgunz/cmp
shallow = true
[submodule "external/solanaceae_toxcore"]
path = external/solanaceae_toxcore
url = https://github.com/Green-Sky/solanaceae_toxcore.git
[submodule "external/solanaceae_util"]
path = external/solanaceae_util
url = https://github.com/Green-Sky/solanaceae_util.git
[submodule "external/solanaceae_contact"]
path = external/solanaceae_contact
url = https://github.com/Green-Sky/solanaceae_contact.git
[submodule "external/solanaceae_message3"]
path = external/solanaceae_message3
url = https://github.com/Green-Sky/solanaceae_message3.git
[submodule "external/solanaceae_tox"]
path = external/solanaceae_tox
url = https://github.com/Green-Sky/solanaceae_tox.git
[submodule "external/solanaceae_plugin"]
path = external/solanaceae_plugin
url = https://github.com/Green-Sky/solanaceae_plugin.git
[submodule "external/solanaceae_object_store"]
path = external/solanaceae_object_store
url = https://github.com/Green-Sky/solanaceae_object_store.git
[submodule "external/solanaceae_message_serializer"]
path = external/solanaceae_message_serializer
url = https://github.com/Green-Sky/solanaceae_message_serializer.git

View File

@ -1,83 +1,610 @@
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR) ################################################################################
#
# The main toxcore CMake build file.
#
# This file when processed with cmake produces:
# - A number of small libraries (.a/.so/...) containing independent components
# of toxcore. E.g. the DHT has its own library, and the system/network
# abstractions are in their own library as well. These libraries are not
# installed on `make install`. The toxav, and toxencryptsave libraries are
# also not installed.
# - A number of small programs, statically linked if possible.
# - One big library containing all of the toxcore, toxav, and toxencryptsave
# code.
#
################################################################################
# cmake setup begin cmake_minimum_required(VERSION 3.16)
project(tomato) cmake_policy(VERSION 3.16)
project(toxcore)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
# defaulting to debug mode, if not specified option(FLAT_OUTPUT_STRUCTURE "Whether to produce output artifacts in ${CMAKE_BINARY_DIR}/{bin,lib}" OFF)
if (NOT CMAKE_BUILD_TYPE) if(FLAT_OUTPUT_STRUCTURE)
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif() endif()
# setup my vim ycm :D set_source_files_properties(
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) toxcore/mono_time.c
toxcore/network.c
toxcore/tox.c
toxcore/util.c
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
# more paths ################################################################################
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") #
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") # :: Version management
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") #
################################################################################
option(TOMATO_MAIN_SO "Build tomato as a shared object (for eg android apps)" ANDROID) # This version is for the entire project. All libraries (core, av, ...) move in
option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF) # versions in a synchronised way.
option(TOMATO_TOX_AV "Build tomato with ToxAV" OFF) set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "2")
set(PROJECT_VERSION_PATCH "19")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
message("II TOMATO_TOX_AV: ${TOMATO_TOX_AV}") # set .so library version / following libtool scheme
# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
file(STRINGS ${toxcore_SOURCE_DIR}/so.version SOVERSION_CURRENT REGEX "^CURRENT=[0-9]+$")
string(SUBSTRING "${SOVERSION_CURRENT}" 8 -1 SOVERSION_CURRENT)
file(STRINGS ${toxcore_SOURCE_DIR}/so.version SOVERSION_REVISION REGEX "^REVISION=[0-9]+$")
string(SUBSTRING "${SOVERSION_REVISION}" 9 -1 SOVERSION_REVISION)
file(STRINGS ${toxcore_SOURCE_DIR}/so.version SOVERSION_AGE REGEX "^AGE=[0-9]+$")
string(SUBSTRING "${SOVERSION_AGE}" 4 -1 SOVERSION_AGE)
# account for some libtool magic, see other/version-sync script for details
math(EXPR SOVERSION_MAJOR ${SOVERSION_CURRENT}-${SOVERSION_AGE})
set(SOVERSION "${SOVERSION_MAJOR}.${SOVERSION_AGE}.${SOVERSION_REVISION}")
message("SOVERSION: ${SOVERSION}")
if (TOMATO_ASAN) ################################################################################
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") #
if (NOT WIN32) # exclude mingw # :: Dependencies and configuration
#link_libraries(-fsanitize=address) #
link_libraries(-fsanitize=address,undefined) ################################################################################
#link_libraries(-fsanitize=undefined)
link_libraries(-static-libasan) # make it "work" on nix include(CTest)
message("II enabled ASAN") include(ModulePackage)
else() include(StrictAbi)
message("!! can not enable ASAN on this platform (gcc/clang + win)") include(GNUInstallDirs)
endif()
elseif (MSVC) if(APPLE)
add_compile_options("/fsanitize=address") include(MacRpath)
message("II enabled ASAN")
else()
message("!! can not enable ASAN on this platform")
endif()
endif() endif()
# uggly, but it needs to be defined for all of tomato. enable_testing()
# but this also means that we can not compile tomato in the same cmake as plugins find_package(GTest)
add_compile_definitions(ENTT_API_EXPORT)
# external libs set(CMAKE_MACOSX_RPATH ON)
add_subdirectory(./external EXCLUDE_FROM_ALL) # before increasing warn levels, sad :(
# Set standard version for compiler.
if(MSVC AND MSVC_TOOLSET_VERSION LESS 143)
# https://developercommunity.visualstudio.com/t/older-winsdk-headers-are-incompatible-with-zcprepr/1593479
set(CMAKE_C_STANDARD 99)
else()
set(CMAKE_C_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
# bump up warning levels appropriately for clang, gcc & msvc message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
add_compile_options(
-Wall -Wextra # Reasonable and standard # Enable some warnings if we know the compiler.
-Wpedantic # Warn if non-standard C++ is used if(MSVC)
-Wunused # Warn on anything being unused add_compile_options(/W4 /analyze)
#-Wconversion # Warn on type conversions that may lose data add_compile_options(/wd4100) # unreferenced formal parameter
#-Wsign-conversion # Warn on sign conversions add_compile_options(/wd4267) # narrowing conversion
-Wshadow # Warn if a variable declaration shadows one from a parent context add_compile_options(/wd4244) # narrowing conversion
) add_compile_options(/wd4127) # conditional expression is constant
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") add_compile_options(/wd4995) # #pragma deprecated
if (MSVC) add_compile_options(/wd4018) # signed/unsigned compare
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_compile_options(/wd4310) # cast truncates constant value
else() add_compile_options(/wd4389) # signed/unsigned compare
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") add_compile_options(/wd4245) # signed/unsigned assign/return/function call
endif() add_compile_options(/wd4200) # nonstandard extension used: zero-sized array in struct/union
add_compile_options(/wd4702) # unreachable code
add_compile_options(/wd6340) # unsigned int passed to signed parameter
add_compile_options(/wd6326) # potential comparison of a constant with another constant
# TODO(iphydf): Look into these
add_compile_options(/wd4996) # use WSAAddressToStringW() instead of WSAAddressToStringA()
add_compile_options(/wd6255) # don't use alloca
add_compile_options(/wd6385) # reading invalid data
add_compile_options(/wd6001) # using uninitialized memory
add_compile_options(/wd6101) # returning uninitialized memory
add_compile_options(/wd6386) # buffer overrun
add_compile_options(/wd6011) # NULL dereference
add_compile_options(/wd6031) # sscanf return value ignored
add_compile_options(/wd6387) # passing NULL to fwrite
endif() endif()
# cmake setup end set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
if(MIN_LOGGER_LEVEL)
add_subdirectory(./src) if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR
("${MIN_LOGGER_LEVEL}" STREQUAL "DEBUG") OR
# TODO: move to src ("${MIN_LOGGER_LEVEL}" STREQUAL "INFO") OR
if (ANDROID AND TARGET SDL3::Jar) ("${MIN_LOGGER_LEVEL}" STREQUAL "WARNING") OR
message("II building for ANDROID!!!") ("${MIN_LOGGER_LEVEL}" STREQUAL "ERROR"))
add_definitions(-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_${MIN_LOGGER_LEVEL})
add_subdirectory(android) else()
message(FATAL_ERROR "Unknown value provided for MIN_LOGGER_LEVEL: \"${MIN_LOGGER_LEVEL}\", must be one of TRACE, DEBUG, INFO, WARNING or ERROR")
endif()
endif() endif()
option(EXPERIMENTAL_API "Install experimental header file with unstable API" OFF)
option(USE_IPV6 "Use IPv6 in tests" ON)
if(NOT USE_IPV6)
add_definitions(-DUSE_IPV6=0)
endif()
option(BUILD_MISC_TESTS "Build additional tests" OFF)
option(BUILD_FUN_UTILS "Build additional just for fun utilities" OFF)
option(UNITTEST "Enable unit tests (disable if you don't have a working gmock or gtest)" ON)
option(AUTOTEST "Enable autotests (mainly for CI)" OFF)
if(AUTOTEST)
option(NON_HERMETIC_TESTS "Whether to build and run tests that depend on an internet connection" OFF)
option(PROXY_TEST "Enable proxy test (requires other/proxy/proxy_server.go to be running)" OFF)
endif()
option(BUILD_TOXAV "Whether to build the tox AV library" ON)
option(MUST_BUILD_TOXAV "Fail the build if toxav cannot be built" OFF)
option(DHT_BOOTSTRAP "Enable building of DHT_bootstrap" ON)
option(BOOTSTRAP_DAEMON "Enable building of tox-bootstrapd" ON)
if(BOOTSTRAP_DAEMON AND WIN32)
message(WARNING "Building tox-bootstrapd for Windows is not supported, disabling")
set(BOOTSTRAP_DAEMON OFF)
endif()
option(BUILD_FUZZ_TESTS "Build fuzzing harnesses" OFF)
if(MSVC)
option(MSVC_STATIC_SODIUM "Whether to link libsodium statically for MSVC" OFF)
if(MSVC_STATIC_SODIUM)
add_definitions(-DSODIUM_STATIC=1)
endif()
endif()
include(Dependencies)
if(MUST_BUILD_TOXAV)
set(NO_TOXAV_ERROR_TYPE SEND_ERROR)
else()
set(NO_TOXAV_ERROR_TYPE WARNING)
endif()
if(BUILD_TOXAV)
if(NOT OPUS_FOUND)
message(${NO_TOXAV_ERROR_TYPE} "Option BUILD_TOXAV is enabled but required library OPUS was not found.")
set(BUILD_TOXAV OFF)
endif()
if(NOT VPX_FOUND)
message(${NO_TOXAV_ERROR_TYPE} "Option BUILD_TOXAV is enabled but required library VPX was not found.")
set(BUILD_TOXAV OFF)
endif()
endif()
# Disable float/double packing in CMP (C MessagePack library).
# We don't transfer floats over the network, so we disable this functionality.
add_definitions(-DCMP_NO_FLOAT=1)
################################################################################
#
# :: Tox Core Library
#
################################################################################
# toxcore_PKGCONFIG_LIBS is what's added to the Libs: line in toxcore.pc. It
# needs to contain all the libraries a program using toxcore should link against
# if it's statically linked. If it's dynamically linked, there is no need to
# explicitly link against all the dependencies, but it doesn't harm much(*)
# either.
#
# (*) It allows client code to use symbols from our dependencies without
# explicitly linking against them.
set(toxcore_PKGCONFIG_LIBS)
# Requires: in pkg-config file.
set(toxcore_PKGCONFIG_REQUIRES)
set(toxcore_SOURCES
third_party/cmp/cmp.c
third_party/cmp/cmp.h
toxcore/announce.c
toxcore/announce.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.c
toxcore/crypto_core.h
toxcore/crypto_core_pack.c
toxcore/crypto_core_pack.h
toxcore/DHT.c
toxcore/DHT.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/events_alloc.c
toxcore/events/events_alloc.h
toxcore/events/file_chunk_request.c
toxcore/events/file_recv.c
toxcore/events/file_recv_chunk.c
toxcore/events/file_recv_control.c
toxcore/events/friend_connection_status.c
toxcore/events/friend_lossless_packet.c
toxcore/events/friend_lossy_packet.c
toxcore/events/friend_message.c
toxcore/events/friend_name.c
toxcore/events/friend_read_receipt.c
toxcore/events/friend_request.c
toxcore/events/friend_status.c
toxcore/events/friend_status_message.c
toxcore/events/friend_typing.c
toxcore/events/self_connection_status.c
toxcore/events/group_custom_packet.c
toxcore/events/group_custom_private_packet.c
toxcore/events/group_invite.c
toxcore/events/group_join_fail.c
toxcore/events/group_message.c
toxcore/events/group_moderation.c
toxcore/events/group_password.c
toxcore/events/group_peer_exit.c
toxcore/events/group_peer_join.c
toxcore/events/group_peer_limit.c
toxcore/events/group_peer_name.c
toxcore/events/group_peer_status.c
toxcore/events/group_privacy_state.c
toxcore/events/group_private_message.c
toxcore/events/group_self_join.c
toxcore/events/group_topic.c
toxcore/events/group_topic_lock.c
toxcore/events/group_voice_state.c
toxcore/forwarding.c
toxcore/forwarding.h
toxcore/friend_connection.c
toxcore/friend_connection.h
toxcore/friend_requests.c
toxcore/friend_requests.h
toxcore/group.c
toxcore/group_chats.c
toxcore/group_chats.h
toxcore/group_common.h
toxcore/group_connection.c
toxcore/group_connection.h
toxcore/group.h
toxcore/group_announce.c
toxcore/group_announce.h
toxcore/group_moderation.c
toxcore/group_moderation.h
toxcore/group_onion_announce.c
toxcore/group_onion_announce.h
toxcore/group_pack.c
toxcore/group_pack.h
toxcore/LAN_discovery.c
toxcore/LAN_discovery.h
toxcore/list.c
toxcore/list.h
toxcore/logger.c
toxcore/logger.h
toxcore/Messenger.c
toxcore/Messenger.h
toxcore/mem.c
toxcore/mem.h
toxcore/mono_time.c
toxcore/mono_time.h
toxcore/net_crypto.c
toxcore/net_crypto.h
toxcore/network.c
toxcore/network.h
toxcore/onion_announce.c
toxcore/onion_announce.h
toxcore/onion.c
toxcore/onion_client.c
toxcore/onion_client.h
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/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.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.h
toxcore/tox_private.c
toxcore/tox_private.h
toxcore/tox_pack.c
toxcore/tox_pack.h
toxcore/tox_unpack.c
toxcore/tox_unpack.h
toxcore/util.c
toxcore/util.h)
if(TARGET unofficial-sodium::sodium)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} unofficial-sodium::sodium)
else()
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES})
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${LIBSODIUM_LIBRARY_DIRS})
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${LIBSODIUM_INCLUDE_DIRS})
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${LIBSODIUM_CFLAGS_OTHER})
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)
if(EXPERIMENTAL_API)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)
endif()
################################################################################
#
# :: Audio/Video Library
#
################################################################################
if(BUILD_TOXAV)
set(toxcore_SOURCES ${toxcore_SOURCES}
toxav/audio.c
toxav/audio.h
toxav/bwcontroller.c
toxav/bwcontroller.h
toxav/groupav.c
toxav/groupav.h
toxav/msi.c
toxav/msi.h
toxav/ring_buffer.c
toxav/ring_buffer.h
toxav/rtp.c
toxav/rtp.h
toxav/toxav.c
toxav/toxav.h
toxav/toxav_old.c
toxav/video.c
toxav/video.h)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
if(MSVC)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PkgConfig::OPUS PkgConfig::VPX)
else()
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${OPUS_LIBRARY_DIRS} ${VPX_LIBRARY_DIRS})
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${OPUS_INCLUDE_DIRS} ${VPX_INCLUDE_DIRS})
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${OPUS_CFLAGS_OTHER} ${VPX_CFLAGS_OTHER})
endif()
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
endif()
################################################################################
#
# :: Block encryption libraries
#
################################################################################
set(toxcore_SOURCES ${toxcore_SOURCES}
toxencryptsave/toxencryptsave.c
toxencryptsave/toxencryptsave.h)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxencryptsave/toxencryptsave.h^tox)
################################################################################
#
# :: System dependencies
#
################################################################################
# These need to come after other dependencies, since e.g. libvpx may depend on
# pthread, but doesn't list it in VPX_LIBRARIES. We're adding it here, after
# any potential libvpx linking.
message("CMAKE_THREAD_LIBS_INIT: ${CMAKE_THREAD_LIBS_INIT}")
if(CMAKE_THREAD_LIBS_INIT)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif()
if(NSL_LIBRARIES)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${NSL_LIBRARIES})
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl)
endif()
if(RT_LIBRARIES)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${RT_LIBRARIES})
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lrt)
endif()
if(SOCKET_LIBRARIES)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${SOCKET_LIBRARIES})
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
endif()
if(TARGET PThreads4W::PThreads4W)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} Threads::Threads)
endif()
if(WIN32)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} iphlpapi ws2_32)
endif()
################################################################################
#
# :: All layers together in one library for ease of use
#
################################################################################
# Create combined library from all the sources.
if(ENABLE_SHARED)
add_library(toxcore_shared SHARED ${toxcore_SOURCES})
set_target_properties(toxcore_shared PROPERTIES OUTPUT_NAME toxcore)
target_link_libraries(toxcore_shared PRIVATE ${toxcore_LINK_LIBRARIES})
target_link_directories(toxcore_shared PUBLIC ${toxcore_LINK_DIRECTORIES})
target_include_directories(toxcore_shared SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
target_compile_options(toxcore_shared PRIVATE ${toxcore_COMPILE_OPTIONS})
endif()
if(ENABLE_STATIC)
add_library(toxcore_static STATIC ${toxcore_SOURCES})
if(NOT MSVC)
set_target_properties(toxcore_static PROPERTIES OUTPUT_NAME toxcore)
endif()
target_link_libraries(toxcore_static PRIVATE ${toxcore_LINK_LIBRARIES})
target_link_directories(toxcore_static PUBLIC ${toxcore_LINK_DIRECTORIES})
target_include_directories(toxcore_static SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
target_compile_options(toxcore_static PRIVATE ${toxcore_COMPILE_OPTIONS})
endif()
if(BUILD_FUZZ_TESTS)
add_library(toxcore_fuzz STATIC ${toxcore_SOURCES})
target_link_libraries(toxcore_fuzz PRIVATE ${toxcore_LINK_LIBRARIES})
target_link_directories(toxcore_fuzz PUBLIC ${toxcore_LINK_DIRECTORIES})
target_include_directories(toxcore_fuzz SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
target_compile_options(toxcore_fuzz PRIVATE ${toxcore_COMPILE_OPTIONS})
target_compile_definitions(toxcore_fuzz PUBLIC "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION")
endif()
# Make version script (on systems that support it) to limit symbol visibility.
make_version_script(toxcore ${toxcore_API_HEADERS})
# Generate pkg-config file, install library to "${CMAKE_INSTALL_LIBDIR}" and install headers to
# "${CMAKE_INSTALL_INCLUDEDIR}/tox".
install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
################################################################################
#
# :: Unit tests: no networking, just pure function calls.
#
################################################################################
add_library(test_util STATIC
toxcore/DHT_test_util.cc
toxcore/DHT_test_util.hh
toxcore/crypto_core_test_util.cc
toxcore/crypto_core_test_util.hh
toxcore/mem_test_util.cc
toxcore/mem_test_util.hh
toxcore/network_test_util.cc
toxcore/network_test_util.hh
toxcore/test_util.cc
toxcore/test_util.hh)
function(unit_test subdir target)
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
target_link_libraries(unit_${target}_test PRIVATE test_util)
if(TARGET toxcore_static)
target_link_libraries(unit_${target}_test PRIVATE toxcore_static)
else()
target_link_libraries(unit_${target}_test PRIVATE toxcore_shared)
endif()
target_link_libraries(unit_${target}_test PRIVATE GTest::gtest GTest::gtest_main GTest::gmock)
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
endfunction()
# The actual unit tests follow.
#
if(UNITTEST AND TARGET GTest::gtest AND TARGET GTest::gmock)
unit_test(toxav ring_buffer)
unit_test(toxav rtp)
unit_test(toxcore DHT)
unit_test(toxcore bin_pack)
unit_test(toxcore crypto_core)
unit_test(toxcore group_announce)
unit_test(toxcore group_moderation)
unit_test(toxcore list)
unit_test(toxcore mem)
unit_test(toxcore mono_time)
unit_test(toxcore ping_array)
unit_test(toxcore test_util)
unit_test(toxcore tox)
unit_test(toxcore util)
endif()
add_subdirectory(testing)
################################################################################
#
# :: Automated regression tests: create a tox network and run integration tests
#
################################################################################
if(AUTOTEST)
add_subdirectory(auto_tests)
endif()
################################################################################
#
# :: Bootstrap daemon
#
################################################################################
if(DHT_BOOTSTRAP)
add_executable(DHT_bootstrap
other/DHT_bootstrap.c
other/bootstrap_node_packets.c)
if(TARGET toxcore_static)
target_link_libraries(DHT_bootstrap PRIVATE toxcore_static)
else()
target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared)
endif()
target_link_libraries(DHT_bootstrap PRIVATE misc_tools)
if(TARGET unofficial-sodium::sodium)
target_link_libraries(DHT_bootstrap PRIVATE unofficial-sodium::sodium)
endif()
if(TARGET PThreads4W::PThreads4W)
target_link_libraries(DHT_bootstrap PRIVATE PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
target_link_libraries(DHT_bootstrap PRIVATE Threads::Threads)
endif()
install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
endif()
if(BOOTSTRAP_DAEMON)
if(LIBCONFIG_FOUND)
add_subdirectory(other/bootstrap_daemon)
else()
message(WARNING "Option BOOTSTRAP_DAEMON is enabled but required library LIBCONFIG was not found.")
set(BOOTSTRAP_DAEMON OFF)
endif()
endif()
if(BUILD_FUN_UTILS)
add_subdirectory(other/fun)
endif()
if (BUILD_FUZZ_TESTS)
add_subdirectory(testing/fuzzing)
endif()

205
README.md
View File

@ -1,8 +1,205 @@
# Tomato # ![Project Tox](https://raw.github.com/TokTok/c-toxcore/master/other/tox.png "Project Tox")
![tomato](res/icon/tomato_v1_256.png) **Current Coverage:**
[![coverage](https://codecov.io/gh/TokTok/c-toxcore/branch/master/graph/badge.svg?token=BRfCKo02De)](https://codecov.io/gh/TokTok/c-toxcore)
## Highly experimental solanaceae client with Tox built-in [**Website**](https://tox.chat) **|** [**Wiki**](https://wiki.tox.chat/) **|**
[**Blog**](https://blog.tox.chat/) **|**
[**FAQ**](https://wiki.tox.chat/doku.php?id=users:faq) **|**
[**Binaries/Downloads**](https://tox.chat/download.html) **|**
[**Clients**](https://wiki.tox.chat/doku.php?id=clients) **|**
[**Compiling**](/INSTALL.md)
![group chat](res/tomato_screenshot_group_bot_text_23-02-2024.png) ## What is Tox
Tox is a peer to peer (serverless) instant messenger aimed at making security
and privacy easy to obtain for regular users. It uses
[libsodium](https://doc.libsodium.org/) (based on
[NaCl](https://nacl.cr.yp.to/)) for its encryption and authentication.
## IMPORTANT!
### ![Danger: Experimental](other/tox-warning.png)
This is an **experimental** cryptographic network library. It has not been
formally audited by an independent third party that specializes in cryptography
or cryptanalysis. **Use this library at your own risk.**
The underlying crypto library [libsodium](https://doc.libsodium.org/) provides
reliable encryption, but the security model has not yet been fully specified.
See [issue 210](https://github.com/TokTok/c-toxcore/issues/210) for a discussion
on developing a threat model. See other issues for known weaknesses (e.g.
[issue 426](https://github.com/TokTok/c-toxcore/issues/426) describes what can
happen if your secret key is stolen).
## Toxcore Development Roadmap
The roadmap and changelog are generated from GitHub issues. You may view them on
the website, where they are updated at least once every 24 hours:
- Changelog: https://toktok.ltd/changelog/c-toxcore
- Roadmap: https://toktok.ltd/roadmap/c-toxcore
## Installing toxcore
Detailed installation instructions can be found in [INSTALL.md](INSTALL.md).
Be advised that due to the addition of `cmp` as a submodule, you now also need
to initialize the git submodules required by toxcore. This can be done by
cloning the repo with the following command:
`git clone --recurse-submodules https://github.com/Toktok/c-toxcore` or by
running `git submodule update --init` in the root directory of the repo.
In a nutshell, if you have [libsodium](https://github.com/jedisct1/libsodium)
installed, run:
```sh
mkdir _build && cd _build
cmake ..
make
sudo make install
```
If you have [libvpx](https://github.com/webmproject/libvpx) and
[opus](https://github.com/xiph/opus) installed, the above will also build the
A/V library for multimedia chats.
## Using toxcore
The simplest "hello world" example could be an echo bot. Here we will walk
through the implementation of a simple bot.
### Creating the tox instance
All toxcore API functions work with error parameters. They are enums with one
`OK` value and several error codes that describe the different situations in
which the function might fail.
```c
TOX_ERR_NEW err_new;
Tox *tox = tox_new(NULL, &err_new);
if (err_new != TOX_ERR_NEW_OK) {
fprintf(stderr, "tox_new failed with error code %d\n", err_new);
exit(1);
}
```
Here, we simply exit the program, but in a real client you will probably want to
do some error handling and proper error reporting to the user. The `NULL`
argument given to the first parameter of `tox_new` is the `Tox_Options`. It
contains various write-once network settings and allows you to load a previously
serialised instance. See [toxcore/tox.h](tox.h) for details.
### Setting up callbacks
Toxcore works with callbacks that you can register to listen for certain events.
Examples of such events are "friend request received" or "friend sent a
message". Search the API for `tox_callback_*` to find all of them.
Here, we will set up callbacks for receiving friend requests and receiving
messages. We will always accept any friend request (because we're a bot), and
when we receive a message, we send it back to the sender.
```c
tox_callback_friend_request(tox, handle_friend_request);
tox_callback_friend_message(tox, handle_friend_message);
```
These two function calls set up the callbacks. Now we also need to implement
these "handle" functions.
### Handle friend requests
```c
static void handle_friend_request(
Tox *tox, const uint8_t *public_key, const uint8_t *message, size_t length,
void *user_data) {
// Accept the friend request:
TOX_ERR_FRIEND_ADD err_friend_add;
tox_friend_add_norequest(tox, public_key, &err_friend_add);
if (err_friend_add != TOX_ERR_FRIEND_ADD_OK) {
fprintf(stderr, "unable to add friend: %d\n", err_friend_add);
}
}
```
The `tox_friend_add_norequest` function adds the friend without sending them a
friend request. Since we already got a friend request, this is the right thing
to do. If you wanted to send a friend request yourself, you would use
`tox_friend_add`, which has an extra parameter for the message.
### Handle messages
Now, when the friend sends us a message, we want to respond to them by sending
them the same message back. This will be our "echo".
```c
static void handle_friend_message(
Tox *tox, uint32_t friend_number, TOX_MESSAGE_TYPE type,
const uint8_t *message, size_t length,
void *user_data) {
TOX_ERR_FRIEND_SEND_MESSAGE err_send;
tox_friend_send_message(tox, friend_number, type, message, length,
&err_send);
if (err_send != TOX_ERR_FRIEND_SEND_MESSAGE_OK) {
fprintf(stderr, "unable to send message back to friend %d: %d\n",
friend_number, err_send);
}
}
```
That's it for the setup. Now we want to actually run the bot.
### Main event loop
Toxcore works with a main event loop function `tox_iterate` that you need to
call at a certain frequency dictated by `tox_iteration_interval`. This is a
polling function that receives new network messages and processes them.
```c
while (true) {
usleep(1000 * tox_iteration_interval(tox));
tox_iterate(tox, NULL);
}
```
That's it! Now you have a working echo bot. The only problem is that since Tox
works with public keys, and you can't really guess your bot's public key, you
can't add it as a friend in your client. For this, we need to call another API
function: `tox_self_get_address(tox, address)`. This will fill the 38 byte
friend address into the `address` buffer. You can then display that binary
string as hex and input it into your client. Writing a `bin2hex` function is
left as exercise for the reader.
We glossed over a lot of details, such as the user data which we passed to
`tox_iterate` (passing `NULL`), bootstrapping into an actual network (this bot
will work in the LAN, but not on an internet server) and the fact that we now
have no clean way of stopping the bot (`while (true)`). If you want to write a
real bot, you will probably want to read up on all the API functions. Consult
the API documentation in [toxcore/tox.h](toxcore/tox.h) for more information.
### Other resources
- [Another echo bot](https://wiki.tox.chat/developers/client_examples/echo_bot)
- [minitox](https://github.com/hqwrong/minitox) (A minimal tox client)
## SAST Tools
This project uses various tools supporting Static Application Security Testing:
- [clang-tidy](https://clang.llvm.org/extra/clang-tidy/): A clang-based C++
"linter" tool.
- [Coverity](https://scan.coverity.com/): A cloud-based static analyzer service
for Java, C/C++, C#, JavaScript, Ruby, or Python that is free for open source
projects.
- [cppcheck](https://cppcheck.sourceforge.io/): A static analyzer for C/C++
code.
- [cpplint](https://github.com/cpplint/cpplint): Static code checker for C++
- [goblint](https://goblint.in.tum.de/): A static analyzer for multi-threaded C
programs, specializing in finding concurrency bugs.
- [infer](https://github.com/facebook/infer): A static analyzer for Java, C,
C++, and Objective-C.
- [PVS-Studio](https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source):
A static analyzer for C, C++, C#, and Java code.
- [tokstyle](https://github.com/TokTok/hs-tokstyle): A style checker for TokTok
C projects.

View File

@ -1,100 +0,0 @@
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
project(tomato_android)
# here be dragons
list(APPEND CMAKE_MODULE_PATH "${SDL3_SOURCE_DIR}/cmake/android")
find_package(SdlAndroid MODULE)
find_package(Java)
find_package(SdlAndroidPlatform MODULE)
# the existence of SDL3::Jar usually implies platform
if(SdlAndroid_FOUND)
include(SdlAndroidFunctions)
sdl_create_android_debug_keystore(tomato-debug-keystore)
sdl_android_compile_resources(tomato-resources RESFOLDER app/res)
set(ANDROID_MANIFEST_PACKAGE "org.libsdl.app.tomato")
#set(generated_manifest_path "${CMAKE_CURRENT_BINARY_DIR}/android/${TEST}-src/AndroidManifest.xml")
string(REPLACE "." "/" JAVA_PACKAGE_DIR "${ANDROID_MANIFEST_PACKAGE}")
#set(GENERATED_SRC_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/android/${TEST}-src")
#set(GENERATED_RES_FOLDER "${GENERATED_SRC_FOLDER}/res")
#set(JAVA_PACKAGE_DIR "${GENERATED_SRC_FOLDER}/${JAVA_PACKAGE_DIR}")
set(JAVA_PACKAGE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/app/java/${JAVA_PACKAGE_DIR}")
sdl_android_link_resources(tomato-apk-linked
MANIFEST "app/AndroidManifest.xml"
PACKAGE ${ANDROID_MANIFEST_PACKAGE}
RES_TARGETS tomato-resources
TARGET_SDK_VERSION 31
)
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding;utf-8")
set(classes_path "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/tomato-java.dir/classes")
# Some CMake versions have a slow `cmake -E make_directory` implementation
if(NOT IS_DIRECTORY "${classes_path}")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${classes_path}")
endif()
set(OUT_JAR "${CMAKE_CURRENT_BINARY_DIR}/tomato.jar")
# TODO: convert to cmake's add_jar
add_custom_command(
OUTPUT "${OUT_JAR}"
COMMAND ${CMAKE_COMMAND} -E rm -rf "${classes_path}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${classes_path}"
COMMAND ${Java_JAVAC_EXECUTABLE}
-source 1.8 -target 1.8
-bootclasspath "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>"
"${JAVA_PACKAGE_DIR}/TomatoActivity.java"
$<TARGET_PROPERTY:tomato-apk-linked,JAVA_R>
-cp "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>:${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
-d "${classes_path}"
COMMAND ${Java_JAR_EXECUTABLE} cf "${OUT_JAR}" -C "${classes_path}" .
DEPENDS $<TARGET_PROPERTY:tomato-apk-linked,OUTPUTS> "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>"
)
add_custom_target(tomato-jar DEPENDS "${OUT_JAR}")
add_dependencies(tomato-jar SDL3::Jar) # HACK: somehow their jar is not registered as an output
set_property(TARGET tomato-jar PROPERTY OUTPUT "${OUT_JAR}")
set(dexworkdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/tomato-dex.dir")
# Some CMake versions have a slow `cmake -E make_directory` implementation
if(NOT IS_DIRECTORY "${dexworkdir}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${dexworkdir}")
endif()
set(classes_dex_base_name "classes.dex")
set(classes_dex "${dexworkdir}/${classes_dex_base_name}")
add_custom_command(
OUTPUT "${classes_dex}"
COMMAND SdlAndroid::d8
$<TARGET_PROPERTY:tomato-jar,OUTPUT>
$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
--lib "${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
--output "${dexworkdir}"
DEPENDS $<TARGET_PROPERTY:tomato-jar,OUTPUT> $<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
)
add_custom_target(tomato-dex DEPENDS "${classes_dex}")
set_property(TARGET tomato-dex PROPERTY OUTPUT "${classes_dex}")
set_property(TARGET tomato-dex PROPERTY OUTPUT_BASE_NAME "${classes_dex_base_name}")
# file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt)
sdl_add_to_apk_unaligned(tomato-unaligned-apk
APK_IN tomato-apk-linked
OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/intermediates"
#ASSETS ${RESOURCE_FILES}
#NATIVE_LIBS SDL3::SDL3-shared tomato
NATIVE_LIBS tomato
DEX tomato-dex
)
sdl_apk_align(tomato-aligned-apk tomato-unaligned-apk
OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/intermediates"
)
sdl_apk_sign(tomato-apk tomato-aligned-apk
KEYSTORE tomato-debug-keystore
)
else()
message("EE SdlAndroid module not found")
endif()

View File

@ -1,106 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Replace com.test.game with the identifier of your game below, e.g.
com.gamemaker.game
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.libsdl.app.tomato"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
<!-- Touchscreen support -->
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<!-- Game controller support -->
<uses-feature
android:name="android.hardware.bluetooth"
android:required="false" />
<uses-feature
android:name="android.hardware.gamepad"
android:required="false" />
<uses-feature
android:name="android.hardware.usb.host"
android:required="false" />
<!-- External mouse input events -->
<uses-feature
android:name="android.hardware.type.pc"
android:required="false" />
<!-- Audio recording support -->
<!-- if you want to capture audio, uncomment this. -->
<!-- <uses-feature
android:name="android.hardware.microphone"
android:required="false" /> -->
<!-- Camera support -->
<!-- if you want to record video, uncomment this. -->
<!--
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
-->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Allow downloading to the external storage on Android 5.1 and older -->
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> -->
<!-- Allow access to Bluetooth devices -->
<!-- Currently this is just for Steam Controller support and requires setting SDL_HINT_JOYSTICK_HIDAPI_STEAM -->
<!-- <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> -->
<!-- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> -->
<!-- Allow access to the vibrator -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- if you want to capture audio, uncomment this. -->
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
<!-- Create a Java class extending SDLActivity and place it in a
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
in the XML below.
An example Java class can be found in README-android.md
-->
<application android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:appCategory="social"
android:allowBackup="true"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true" >
<!-- setting sdl hints. uses the string value -->
<meta-data android:name="SDL_ENV.SDL_ANDROID_BLOCK_ON_PAUSE" android:value="0"/>
<activity android:name="TomatoActivity"
android:label="@string/app_name"
android:alwaysRetainTaskState="true"
android:launchMode="singleInstance"
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
android:preferMinimalPostProcessing="true"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Let Android know that we can handle some USB devices and should receive this event -->
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<!-- Drop file event -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -1,18 +0,0 @@
package org.libsdl.app.tomato;
import org.libsdl.app.SDLActivity;
public class TomatoActivity extends SDLActivity {
protected String[] getLibraries() {
return new String[] {
// "SDL3", // we link statically
// "SDL3_image",
// "SDL3_mixer",
// "SDL3_net",
// "SDL3_ttf",
// "main"
"tomato"
};
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View File

@ -1,3 +0,0 @@
<resources>
<string name="app_name">Tomato</string>
</resources>

View File

@ -1,10 +0,0 @@
<resources>
<!-- Base application theme. -->
<!-- <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> -->
<!--<style name="AppTheme" parent="android:Theme.AppCompat">-->
<style name="AppTheme" parent="android:Theme.NoTitleBar">
<!-- Customize your theme here. -->
</style>
</resources>

View File

@ -67,7 +67,6 @@ auto_test(invalid_udp_proxy)
auto_test(lan_discovery) auto_test(lan_discovery)
auto_test(lossless_packet) auto_test(lossless_packet)
auto_test(lossy_packet) auto_test(lossy_packet)
auto_test(netprof)
auto_test(network) auto_test(network)
auto_test(onion) auto_test(onion)
auto_test(overflow_recvq) auto_test(overflow_recvq)

View File

@ -111,12 +111,12 @@ static void test_basic(void)
// Sending the handshake // Sending the handshake
ck_assert_msg(net_send(ns, logger, sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, ck_assert_msg(net_send(ns, logger, sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1,
&localhost, nullptr) == TCP_CLIENT_HANDSHAKE_SIZE - 1, &localhost) == TCP_CLIENT_HANDSHAKE_SIZE - 1,
"An attempt to send the initial handshake minus last byte failed."); "An attempt to send the initial handshake minus last byte failed.");
do_tcp_server_delay(tcp_s, mono_time, 50); do_tcp_server_delay(tcp_s, mono_time, 50);
ck_assert_msg(net_send(ns, logger, sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, &localhost, nullptr) == 1, ck_assert_msg(net_send(ns, logger, sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, &localhost) == 1,
"The attempt to send the last byte of handshake failed."); "The attempt to send the last byte of handshake failed.");
free(handshake); free(handshake);
@ -155,7 +155,7 @@ static void test_basic(void)
msg_length = sizeof(r_req) - i; msg_length = sizeof(r_req) - i;
} }
ck_assert_msg(net_send(ns, logger, sock, r_req + i, msg_length, &localhost, nullptr) == msg_length, ck_assert_msg(net_send(ns, logger, sock, r_req + i, msg_length, &localhost) == msg_length,
"Failed to send request after completing the handshake."); "Failed to send request after completing the handshake.");
i += msg_length; i += msg_length;
@ -234,12 +234,12 @@ static struct sec_TCP_con *new_tcp_con(const Logger *logger, const Memory *mem,
"Failed to encrypt the outgoing handshake."); "Failed to encrypt the outgoing handshake.");
ck_assert_msg(net_send(ns, logger, sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, ck_assert_msg(net_send(ns, logger, sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1,
&localhost, nullptr) == TCP_CLIENT_HANDSHAKE_SIZE - 1, &localhost) == TCP_CLIENT_HANDSHAKE_SIZE - 1,
"Failed to send the first portion of the handshake to the TCP relay server."); "Failed to send the first portion of the handshake to the TCP relay server.");
do_tcp_server_delay(tcp_s, mono_time, 50); do_tcp_server_delay(tcp_s, mono_time, 50);
ck_assert_msg(net_send(ns, logger, sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, &localhost, nullptr) == 1, ck_assert_msg(net_send(ns, logger, sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, &localhost) == 1,
"Failed to send last byte of handshake."); "Failed to send last byte of handshake.");
do_tcp_server_delay(tcp_s, mono_time, 50); do_tcp_server_delay(tcp_s, mono_time, 50);
@ -283,7 +283,7 @@ static int write_packet_tcp_test_connection(const Logger *logger, struct sec_TCP
localhost.ip = get_loopback(); localhost.ip = get_loopback();
localhost.port = 0; localhost.port = 0;
ck_assert_msg(net_send(con->ns, logger, con->sock, packet, packet_size, &localhost, nullptr) == packet_size, ck_assert_msg(net_send(con->ns, logger, con->sock, packet, packet_size, &localhost) == packet_size,
"Failed to send a packet."); "Failed to send a packet.");
return 0; return 0;
} }
@ -524,7 +524,7 @@ static void test_client(void)
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]); ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
ip_port_tcp_s.ip = get_loopback(); ip_port_tcp_s.ip = get_loopback();
TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr, nullptr); TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr);
// TCP sockets might need a moment before they can be written to. // TCP sockets might need a moment before they can be written to.
c_sleep(50); c_sleep(50);
do_tcp_connection(logger, mono_time, conn, nullptr); do_tcp_connection(logger, mono_time, conn, nullptr);
@ -560,7 +560,7 @@ static void test_client(void)
crypto_new_keypair(rng, f2_public_key, f2_secret_key); crypto_new_keypair(rng, f2_public_key, f2_secret_key);
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]); ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
TCP_Client_Connection *conn2 = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f2_public_key, TCP_Client_Connection *conn2 = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f2_public_key,
f2_secret_key, nullptr, nullptr); f2_secret_key, nullptr);
c_sleep(50); c_sleep(50);
// The client should call this function (defined earlier) during the routing process. // The client should call this function (defined earlier) during the routing process.
@ -657,7 +657,7 @@ static void test_client_invalid(void)
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]); ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
ip_port_tcp_s.ip = get_loopback(); ip_port_tcp_s.ip = get_loopback();
TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s,
self_public_key, f_public_key, f_secret_key, nullptr, nullptr); self_public_key, f_public_key, f_secret_key, nullptr);
// Run the client's main loop but not the server. // Run the client's main loop but not the server.
mono_time_update(mono_time); mono_time_update(mono_time);

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