Compare commits
	
		
			29 Commits
		
	
	
		
			good_maste
			...
			tmp_window
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 67aefff940 | |||
| 74129cabef | |||
| be8ceb861c | |||
| da0f59a3f5 | |||
| 000254320e | |||
| 2fac7206d2 | |||
| e8234f2a4a | |||
| a0ba0b39d8 | |||
| 845967cf12 | |||
| 92b58cbfa9 | |||
| 5a0651eaf0 | |||
| 14fcaf1d7e | |||
| 5a0252d8d0 | |||
| 9c0ffd38ce | |||
| ae1fb0fde3 | |||
| b2ae9530a4 | |||
| 35ebbbef93 | |||
| 83e200df43 | |||
| 260d3b7818 | |||
| 4ebffd8c63 | |||
| 8923e09b36 | |||
| ec4195f18a | |||
| 062ad7ae80 | |||
| aad07611c7 | |||
| 0dcb66f143 | |||
| 331c25b0e6 | |||
| e50844be06 | |||
| 4dd7c98c1a | |||
| 63bad2e99a | 
							
								
								
									
										72
									
								
								.github/workflows/cd.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										72
									
								
								.github/workflows/cd.yml
									
									
									
									
										vendored
									
									
								
							@@ -10,10 +10,40 @@ env:
 | 
			
		||||
  BUILD_TYPE: Release
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  linux-ubuntu:
 | 
			
		||||
    timeout-minutes: 10
 | 
			
		||||
 | 
			
		||||
    runs-on: ubuntu-20.04
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
      with:
 | 
			
		||||
        submodules: recursive
 | 
			
		||||
 | 
			
		||||
    - name: Install Dependencies
 | 
			
		||||
      run: sudo apt update && sudo apt -y install libsodium-dev
 | 
			
		||||
 | 
			
		||||
    - 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
 | 
			
		||||
 | 
			
		||||
    - name: temp test
 | 
			
		||||
      run: ${{github.workspace}}/build/bin/mono_time_test
 | 
			
		||||
 | 
			
		||||
    - uses: actions/upload-artifact@v3
 | 
			
		||||
      with:
 | 
			
		||||
        name: ${{ github.event.repository.name }}-ubuntu20.04-x86_64
 | 
			
		||||
        # TODO: do propper packing
 | 
			
		||||
        path: |
 | 
			
		||||
          ${{github.workspace}}/build/bin/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  windows:
 | 
			
		||||
    timeout-minutes: 15
 | 
			
		||||
 | 
			
		||||
    runs-on: windows-latest
 | 
			
		||||
    runs-on: windows-2019
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
@@ -34,10 +64,50 @@ jobs:
 | 
			
		||||
    - name: Build
 | 
			
		||||
      run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
 | 
			
		||||
 | 
			
		||||
    - name: temp test
 | 
			
		||||
      run: ${{github.workspace}}/build/bin/mono_time_test.exe
 | 
			
		||||
 | 
			
		||||
    - uses: actions/upload-artifact@v3
 | 
			
		||||
      if: success() || failure()
 | 
			
		||||
      with:
 | 
			
		||||
        name: ${{ github.event.repository.name }}-windows-msvc-x86_64
 | 
			
		||||
        # TODO: do propper packing
 | 
			
		||||
        path: |
 | 
			
		||||
          ${{github.workspace}}/build/bin/
 | 
			
		||||
 | 
			
		||||
  windows-asan:
 | 
			
		||||
    timeout-minutes: 15
 | 
			
		||||
 | 
			
		||||
    runs-on: windows-2019
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
      with:
 | 
			
		||||
        submodules: recursive
 | 
			
		||||
 | 
			
		||||
    - name: Install Dependencies
 | 
			
		||||
      run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
 | 
			
		||||
 | 
			
		||||
    # setup vs env
 | 
			
		||||
    - uses: ilammy/msvc-dev-cmd@v1
 | 
			
		||||
      with:
 | 
			
		||||
        arch: amd64
 | 
			
		||||
 | 
			
		||||
    - 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
 | 
			
		||||
 | 
			
		||||
    - name: Build
 | 
			
		||||
      run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
 | 
			
		||||
 | 
			
		||||
    - name: temp test
 | 
			
		||||
      run: ${{github.workspace}}/build/bin/mono_time_test.exe
 | 
			
		||||
 | 
			
		||||
    - uses: actions/upload-artifact@v3
 | 
			
		||||
      if: success() || failure()
 | 
			
		||||
      with:
 | 
			
		||||
        name: ${{ github.event.repository.name }}-windows-msvc-asan-x86_64
 | 
			
		||||
        # TODO: do propper packing
 | 
			
		||||
        # TODO: also switch to asan dlls
 | 
			
		||||
        path: |
 | 
			
		||||
          ${{github.workspace}}/build/bin/
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							@@ -29,6 +29,9 @@ jobs:
 | 
			
		||||
    - name: Build
 | 
			
		||||
      run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
 | 
			
		||||
 | 
			
		||||
    - name: temp test
 | 
			
		||||
      run: ${{github.workspace}}/build/bin/mono_time_test
 | 
			
		||||
 | 
			
		||||
  macos:
 | 
			
		||||
    timeout-minutes: 10
 | 
			
		||||
 | 
			
		||||
@@ -72,3 +75,6 @@ jobs:
 | 
			
		||||
    - name: Build
 | 
			
		||||
      run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
 | 
			
		||||
 | 
			
		||||
    - name: temp test
 | 
			
		||||
      run: ${{github.workspace}}/build/bin/mono_time_test.exe
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
 | 
			
		||||
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
 | 
			
		||||
 | 
			
		||||
# cmake setup begin
 | 
			
		||||
project(tomato)
 | 
			
		||||
@@ -6,7 +6,7 @@ project(tomato)
 | 
			
		||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 | 
			
		||||
 | 
			
		||||
# defaulting to debug mode, if not specified
 | 
			
		||||
if(NOT CMAKE_BUILD_TYPE)
 | 
			
		||||
if (NOT CMAKE_BUILD_TYPE)
 | 
			
		||||
	set(CMAKE_BUILD_TYPE "Debug")
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
@@ -18,6 +18,26 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
 | 
			
		||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
 | 
			
		||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
 | 
			
		||||
 | 
			
		||||
option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF)
 | 
			
		||||
 | 
			
		||||
if (TOMATO_ASAN)
 | 
			
		||||
	if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
 | 
			
		||||
		if (NOT WIN32) # exclude mingw
 | 
			
		||||
			link_libraries(-fsanitize=address)
 | 
			
		||||
			#link_libraries(-fsanitize=address,undefined)
 | 
			
		||||
			#link_libraries(-fsanitize=undefined)
 | 
			
		||||
			message("II enabled ASAN")
 | 
			
		||||
		else()
 | 
			
		||||
			message("!! can not enable ASAN on this platform (gcc/clang + win)")
 | 
			
		||||
		endif()
 | 
			
		||||
	elseif (MSVC)
 | 
			
		||||
		add_compile_options("/fsanitize=address")
 | 
			
		||||
		message("II enabled ASAN")
 | 
			
		||||
	else()
 | 
			
		||||
		message("!! can not enable ASAN on this platform")
 | 
			
		||||
	endif()
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
# external libs
 | 
			
		||||
add_subdirectory(./external) # before increasing warn levels, sad :(
 | 
			
		||||
 | 
			
		||||
@@ -33,13 +53,8 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL
 | 
			
		||||
		#-Wsign-conversion # Warn on sign conversions
 | 
			
		||||
		-Wshadow # Warn if a variable declaration shadows one from a parent context
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	if (NOT WIN32)
 | 
			
		||||
		#link_libraries(-fsanitize=address,undefined)
 | 
			
		||||
		#link_libraries(-fsanitize=undefined)
 | 
			
		||||
	endif()
 | 
			
		||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
 | 
			
		||||
	if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
 | 
			
		||||
	if (MSVC)
 | 
			
		||||
		string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 | 
			
		||||
	else()
 | 
			
		||||
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								external/solanaceae_plugin
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								external/solanaceae_plugin
									
									
									
									
										vendored
									
									
								
							 Submodule external/solanaceae_plugin updated: eeab3109e7...5ae3f07c3a
									
								
							
							
								
								
									
										2
									
								
								external/solanaceae_tox
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								external/solanaceae_tox
									
									
									
									
										vendored
									
									
								
							 Submodule external/solanaceae_tox updated: 89e74b35f8...c01d91144c
									
								
							
							
								
								
									
										2
									
								
								external/solanaceae_toxcore
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								external/solanaceae_toxcore
									
									
									
									
										vendored
									
									
								
							 Submodule external/solanaceae_toxcore updated: d05875f489...08b3d69c15
									
								
							
							
								
								
									
										8
									
								
								external/toxcore/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								external/toxcore/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							@@ -127,6 +127,8 @@ add_library(toxcore STATIC
 | 
			
		||||
	${TOX_DIR}toxcore/tox.c
 | 
			
		||||
	${TOX_DIR}toxcore/tox_dispatch.c
 | 
			
		||||
	${TOX_DIR}toxcore/tox_dispatch.h
 | 
			
		||||
	${TOX_DIR}toxcore/tox_event.c
 | 
			
		||||
	${TOX_DIR}toxcore/tox_event.h
 | 
			
		||||
	${TOX_DIR}toxcore/tox_events.c
 | 
			
		||||
	${TOX_DIR}toxcore/tox_events.h
 | 
			
		||||
	${TOX_DIR}toxcore/tox.h
 | 
			
		||||
@@ -203,6 +205,10 @@ add_executable(DHT_Bootstrap EXCLUDE_FROM_ALL
 | 
			
		||||
	${TOX_DIR}testing/misc_tools.h
 | 
			
		||||
	${TOX_DIR}testing/misc_tools.c
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_link_libraries(DHT_Bootstrap toxcore)
 | 
			
		||||
 | 
			
		||||
add_executable(mono_time_test
 | 
			
		||||
	./mono_time_test.cc
 | 
			
		||||
)
 | 
			
		||||
target_link_libraries(mono_time_test toxcore)
 | 
			
		||||
target_compile_features(mono_time_test PUBLIC cxx_std_11)
 | 
			
		||||
 
 | 
			
		||||
@@ -134,7 +134,6 @@ jobs:
 | 
			
		||||
      - run:
 | 
			
		||||
          apt-get install -y --no-install-recommends
 | 
			
		||||
            ca-certificates
 | 
			
		||||
            cppcheck
 | 
			
		||||
            g++
 | 
			
		||||
            llvm-dev
 | 
			
		||||
      - checkout
 | 
			
		||||
@@ -142,7 +141,6 @@ jobs:
 | 
			
		||||
      - run: other/analysis/check_includes
 | 
			
		||||
      - run: other/analysis/check_logger_levels
 | 
			
		||||
      - run: other/analysis/run-clang
 | 
			
		||||
      - run: other/analysis/run-cppcheck
 | 
			
		||||
      - run: other/analysis/run-gcc
 | 
			
		||||
 | 
			
		||||
  clang-analyze:
 | 
			
		||||
 
 | 
			
		||||
@@ -11,10 +11,7 @@ add_ld_flag -Wl,-z,defs
 | 
			
		||||
# Make compilation error on a warning
 | 
			
		||||
add_flag -Werror
 | 
			
		||||
 | 
			
		||||
add_config_flag --with-nacl-libs="$CACHEDIR/lib/amd64"
 | 
			
		||||
add_config_flag --with-nacl-headers="$CACHEDIR/include/amd64"
 | 
			
		||||
add_config_flag --disable-ipv6
 | 
			
		||||
add_config_flag --enable-nacl
 | 
			
		||||
add_config_flag --enable-daemon
 | 
			
		||||
add_config_flag --with-log-level=TRACE
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -65,6 +65,8 @@ add_cxx_flag -Wno-c++98-compat-pedantic
 | 
			
		||||
add_cxx_flag -Wno-c99-extensions
 | 
			
		||||
# We're C-compatible, so use C style casts.
 | 
			
		||||
add_cxx_flag -Wno-old-style-cast
 | 
			
		||||
# GTest does this.
 | 
			
		||||
add_cxx_flag -Wno-global-constructors
 | 
			
		||||
 | 
			
		||||
# Downgrade to warning so we still see it.
 | 
			
		||||
add_flag -Wno-error=unreachable-code
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ add_flag --coverage
 | 
			
		||||
add_c_flag -fno-inline -fno-omit-frame-pointer
 | 
			
		||||
 | 
			
		||||
# Show useful stack traces on crash.
 | 
			
		||||
add_flag -fsanitize=undefined -fno-sanitize-recover=all
 | 
			
		||||
add_flag -fsanitize=undefined -fno-sanitize-recover=all -D_DEBUG
 | 
			
		||||
 | 
			
		||||
# In test code (_test.cc and libgtest), throw away all debug information.
 | 
			
		||||
# We only care about stack frames inside toxcore (which is C). Without this,
 | 
			
		||||
 
 | 
			
		||||
@@ -16,9 +16,9 @@ branches:
 | 
			
		||||
          - "bazel-opt"
 | 
			
		||||
          - "build-alpine-s390x"
 | 
			
		||||
          - "build-android"
 | 
			
		||||
          - "build-autotools"
 | 
			
		||||
          - "build-compcert"
 | 
			
		||||
          - "build-macos"
 | 
			
		||||
          - "build-nacl"
 | 
			
		||||
          - "build-tcc"
 | 
			
		||||
          - "build-win32"
 | 
			
		||||
          - "build-win64"
 | 
			
		||||
 
 | 
			
		||||
@@ -13,10 +13,20 @@ jobs:
 | 
			
		||||
  common:
 | 
			
		||||
    uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master
 | 
			
		||||
 | 
			
		||||
  cppcheck:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/cppcheck/Dockerfile
 | 
			
		||||
 | 
			
		||||
  mypy:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Set up Python 3.9
 | 
			
		||||
@@ -34,9 +44,9 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/doxygen/Dockerfile
 | 
			
		||||
 | 
			
		||||
@@ -44,9 +54,9 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/tokstyle/Dockerfile
 | 
			
		||||
 | 
			
		||||
@@ -54,19 +64,19 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/misra/Dockerfile
 | 
			
		||||
 | 
			
		||||
  build-nacl:
 | 
			
		||||
  build-autotools:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/autotools/Dockerfile
 | 
			
		||||
 | 
			
		||||
@@ -74,9 +84,9 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/tcc/Dockerfile
 | 
			
		||||
 | 
			
		||||
@@ -84,26 +94,27 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/compcert/Dockerfile
 | 
			
		||||
 | 
			
		||||
  build-alpine-s390x:
 | 
			
		||||
  generate-events:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/alpine-s390x/Dockerfile
 | 
			
		||||
          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@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Run cimplefmt
 | 
			
		||||
@@ -112,7 +123,7 @@ jobs:
 | 
			
		||||
  build-win32:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Cross compilation
 | 
			
		||||
@@ -121,7 +132,7 @@ jobs:
 | 
			
		||||
  build-win64:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Cross compilation
 | 
			
		||||
@@ -130,7 +141,7 @@ jobs:
 | 
			
		||||
  build-macos:
 | 
			
		||||
    runs-on: macos-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Build and test
 | 
			
		||||
@@ -139,16 +150,16 @@ jobs:
 | 
			
		||||
  coverage-linux:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Build, test, and upload coverage
 | 
			
		||||
        run: .github/scripts/coverage-linux
 | 
			
		||||
        run: other/docker/coverage/run
 | 
			
		||||
 | 
			
		||||
  build-android:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - run: .github/scripts/cmake-android armeabi-v7a
 | 
			
		||||
 
 | 
			
		||||
@@ -17,11 +17,11 @@ jobs:
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
@@ -38,15 +38,15 @@ jobs:
 | 
			
		||||
    needs: [docker-bootstrap-node]
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          context: "{{defaultContext}}:other/bootstrap_daemon/websocket"
 | 
			
		||||
          push: ${{ github.event_name == 'push' }}
 | 
			
		||||
@@ -57,17 +57,17 @@ jobs:
 | 
			
		||||
  docker-clusterfuzz:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          context: "."
 | 
			
		||||
          file: .clusterfuzzlite/Dockerfile
 | 
			
		||||
@@ -80,15 +80,15 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: testing/Dockerfile
 | 
			
		||||
          push: ${{ github.event_name == 'push' }}
 | 
			
		||||
@@ -100,15 +100,15 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/emscripten/Dockerfile
 | 
			
		||||
          push: ${{ github.event_name == 'push' }}
 | 
			
		||||
@@ -120,22 +120,22 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          driver: docker
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - name: Build toxchat/c-toxcore:sources
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/sources/Dockerfile
 | 
			
		||||
          tags: toxchat/c-toxcore:sources
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/esp32/Dockerfile
 | 
			
		||||
          push: ${{ github.event_name == 'push' }}
 | 
			
		||||
@@ -147,15 +147,15 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          context: "{{defaultContext}}:other/docker/windows"
 | 
			
		||||
          push: ${{ github.event_name == 'push' }}
 | 
			
		||||
@@ -171,15 +171,15 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_TOKEN }}
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          context: "{{defaultContext}}:other/docker/windows"
 | 
			
		||||
          push: ${{ github.event_name == 'push' }}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										43
									
								
								external/toxcore/c-toxcore/.github/workflows/post-submit.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								external/toxcore/c-toxcore/.github/workflows/post-submit.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
name: post-submit
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
    branches: [master]
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build-alpine-s390x:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
      - name: Docker Build
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/alpine-s390x/Dockerfile
 | 
			
		||||
 | 
			
		||||
  docker-coverage:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          driver: docker
 | 
			
		||||
      - 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 toxchat/c-toxcore:sources
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/sources/Dockerfile
 | 
			
		||||
          tags: toxchat/c-toxcore:sources
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          file: other/docker/coverage/Dockerfile
 | 
			
		||||
          push: ${{ github.event_name == 'push' }}
 | 
			
		||||
          tags: toxchat/c-toxcore:coverage
 | 
			
		||||
          cache-from: type=registry,ref=toxchat/c-toxcore:coverage
 | 
			
		||||
          cache-to: type=inline
 | 
			
		||||
@@ -19,13 +19,14 @@ jobs:
 | 
			
		||||
      SONAR_SERVER_URL: "https://sonarcloud.io"
 | 
			
		||||
      BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - uses: actions/checkout@v4
 | 
			
		||||
        with:
 | 
			
		||||
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
 | 
			
		||||
          submodules: recursive
 | 
			
		||||
      - name: Set up JDK 17
 | 
			
		||||
        uses: actions/setup-java@v1
 | 
			
		||||
        uses: actions/setup-java@v2
 | 
			
		||||
        with:
 | 
			
		||||
          distribution: "zulu"
 | 
			
		||||
          java-version: 17
 | 
			
		||||
      - name: Download and set up sonar-scanner
 | 
			
		||||
        env:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										94
									
								
								external/toxcore/c-toxcore/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										94
									
								
								external/toxcore/c-toxcore/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							@@ -14,8 +14,8 @@
 | 
			
		||||
#
 | 
			
		||||
################################################################################
 | 
			
		||||
 | 
			
		||||
cmake_minimum_required(VERSION 3.5)
 | 
			
		||||
cmake_policy(VERSION 3.5)
 | 
			
		||||
cmake_minimum_required(VERSION 3.16)
 | 
			
		||||
cmake_policy(VERSION 3.16)
 | 
			
		||||
project(toxcore)
 | 
			
		||||
 | 
			
		||||
list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
 | 
			
		||||
@@ -76,6 +76,7 @@ if(APPLE)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
enable_testing()
 | 
			
		||||
find_package(GTest)
 | 
			
		||||
 | 
			
		||||
set(CMAKE_MACOSX_RPATH ON)
 | 
			
		||||
 | 
			
		||||
@@ -111,16 +112,11 @@ if(NOT USE_IPV6)
 | 
			
		||||
  add_definitions(-DUSE_IPV6=0)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
option(USE_TEST_NETWORK "Use a separate test network with different packet IDs" OFF)
 | 
			
		||||
if(USE_TEST_NETWORK)
 | 
			
		||||
  add_definitions(-DUSE_TEST_NETWORK=1)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
option(BUILD_MISC_TESTS "Build additional tests and utilities" OFF)
 | 
			
		||||
option(BUILD_FUN_UTILS "Build additional just for fun utilities" OFF)
 | 
			
		||||
 | 
			
		||||
option(AUTOTEST "Enable autotests (mainly for CI)" OFF)
 | 
			
		||||
if (AUTOTEST)
 | 
			
		||||
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 (needs HTTP/SOCKS5 proxy on port 8080/8081)" OFF)
 | 
			
		||||
endif()
 | 
			
		||||
@@ -320,6 +316,8 @@ set(toxcore_SOURCES
 | 
			
		||||
  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
 | 
			
		||||
@@ -329,7 +327,10 @@ set(toxcore_SOURCES
 | 
			
		||||
  toxcore/tox_unpack.h
 | 
			
		||||
  toxcore/util.c
 | 
			
		||||
  toxcore/util.h)
 | 
			
		||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
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})
 | 
			
		||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
 | 
			
		||||
set(toxcore_API_HEADERS
 | 
			
		||||
  ${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
 | 
			
		||||
@@ -365,7 +366,10 @@ if(BUILD_TOXAV)
 | 
			
		||||
  set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
 | 
			
		||||
    ${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
 | 
			
		||||
 | 
			
		||||
  set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
 | 
			
		||||
  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})
 | 
			
		||||
  set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
@@ -392,28 +396,28 @@ set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
 | 
			
		||||
# any potential libvpx linking.
 | 
			
		||||
message("CMAKE_THREAD_LIBS_INIT: ${CMAKE_THREAD_LIBS_INIT}")
 | 
			
		||||
if(CMAKE_THREAD_LIBS_INIT)
 | 
			
		||||
  set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${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_MODULES ${toxcore_LINK_MODULES} ${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_MODULES ${toxcore_LINK_MODULES} ${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_MODULES ${toxcore_LINK_MODULES} ${SOCKET_LIBRARIES})
 | 
			
		||||
  set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${SOCKET_LIBRARIES})
 | 
			
		||||
  set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(WIN32)
 | 
			
		||||
  set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ws2_32 iphlpapi)
 | 
			
		||||
  set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ws2_32 iphlpapi)
 | 
			
		||||
  set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lws2_32 -liphlpapi)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
@@ -427,7 +431,18 @@ endif()
 | 
			
		||||
add_module(toxcore ${toxcore_SOURCES})
 | 
			
		||||
 | 
			
		||||
# Link it to all dependencies.
 | 
			
		||||
target_link_modules(toxcore ${toxcore_LINK_MODULES})
 | 
			
		||||
if(TARGET toxcore_static)
 | 
			
		||||
  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(TARGET toxcore_shared)
 | 
			
		||||
  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()
 | 
			
		||||
 | 
			
		||||
# Make version script (on systems that support it) to limit symbol visibility.
 | 
			
		||||
make_version_script(toxcore ${toxcore_API_HEADERS})
 | 
			
		||||
@@ -442,22 +457,36 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
 | 
			
		||||
#
 | 
			
		||||
################################################################################
 | 
			
		||||
 | 
			
		||||
include(CompileGTest)
 | 
			
		||||
function(unit_test subdir target)
 | 
			
		||||
  add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
 | 
			
		||||
  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::Main)
 | 
			
		||||
  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.
 | 
			
		||||
#
 | 
			
		||||
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 mem)
 | 
			
		||||
unit_test(toxcore mono_time)
 | 
			
		||||
unit_test(toxcore ping_array)
 | 
			
		||||
unit_test(toxcore tox)
 | 
			
		||||
unit_test(toxcore util)
 | 
			
		||||
if(GTEST_FOUND)
 | 
			
		||||
  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 tox)
 | 
			
		||||
  unit_test(toxcore util)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
add_subdirectory(testing)
 | 
			
		||||
 | 
			
		||||
@@ -481,7 +510,12 @@ if(DHT_BOOTSTRAP)
 | 
			
		||||
  add_executable(DHT_bootstrap
 | 
			
		||||
    other/DHT_bootstrap.c
 | 
			
		||||
    other/bootstrap_node_packets.c)
 | 
			
		||||
  target_link_modules(DHT_bootstrap toxcore misc_tools)
 | 
			
		||||
  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)
 | 
			
		||||
  install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								external/toxcore/c-toxcore/INSTALL.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								external/toxcore/c-toxcore/INSTALL.md
									
									
									
									
										vendored
									
									
								
							@@ -32,14 +32,14 @@ These instructions will guide you through the process of building and installing
 | 
			
		||||
 | 
			
		||||
This repository, although called `toxcore`, in fact contains several libraries besides `toxcore` which complement it, as well as several executables. However, note that although these are separate libraries, at the moment, when building the libraries, they are all merged into a single `toxcore` library. Here is the full list of the main components that can be built using the CMake, their dependencies and descriptions.
 | 
			
		||||
 | 
			
		||||
| Name             | Type       | Dependencies                                  | Platform       | Description                                                                |
 | 
			
		||||
|------------------|------------|-----------------------------------------------|----------------|----------------------------------------------------------------------------|
 | 
			
		||||
| `toxcore`        | Library    | libnacl or libsodium, libm, libpthread, librt | Cross-platform | The main Tox library that provides the messenger functionality.            |
 | 
			
		||||
| `toxav`          | Library    | libtoxcore, libopus, libvpx                   | Cross-platform | Provides audio/video functionality.                                        |
 | 
			
		||||
| `toxencryptsave` | Library    | libtoxcore, libnacl or libsodium              | Cross-platform | Provides encryption of Tox profiles (savedata), as well as arbitrary data. |
 | 
			
		||||
| `DHT_bootstrap`  | Executable | libtoxcore                                    | Cross-platform | A simple DHT bootstrap node.                                               |
 | 
			
		||||
| `tox-bootstrapd` | Executable | libtoxcore, libconfig                         | Unix-like      | Highly configurable DHT bootstrap node daemon (systemd, SysVinit, Docker). |
 | 
			
		||||
| `cmp`            | Library    |                                               | Cross-platform | C implementation of the MessagePack serialization format. [https://github.com/camgunz/cmp](https://github.com/camgunz/cmp) |
 | 
			
		||||
| Name             | Type       | Dependencies                       | Platform       | Description                                                                |
 | 
			
		||||
|------------------|------------|------------------------------------|----------------|----------------------------------------------------------------------------|
 | 
			
		||||
| `toxcore`        | Library    | libsodium, libm, libpthread, librt | Cross-platform | The main Tox library that provides the messenger functionality.            |
 | 
			
		||||
| `toxav`          | Library    | libtoxcore, libopus, libvpx        | Cross-platform | Provides audio/video functionality.                                        |
 | 
			
		||||
| `toxencryptsave` | Library    | libtoxcore, libsodium              | Cross-platform | Provides encryption of Tox profiles (savedata), as well as arbitrary data. |
 | 
			
		||||
| `DHT_bootstrap`  | Executable | libtoxcore                         | Cross-platform | A simple DHT bootstrap node.                                               |
 | 
			
		||||
| `tox-bootstrapd` | Executable | libtoxcore, libconfig              | Unix-like      | Highly configurable DHT bootstrap node daemon (systemd, SysVinit, Docker). |
 | 
			
		||||
| `cmp`            | Library    |                                    | Cross-platform | C implementation of the MessagePack serialization format. [https://github.com/camgunz/cmp](https://github.com/camgunz/cmp) |
 | 
			
		||||
 | 
			
		||||
#### Secondary
 | 
			
		||||
 | 
			
		||||
@@ -83,7 +83,7 @@ Useful for generating Tox profiles from the output of the vanity key generators,
 | 
			
		||||
Library dependencies are listed in the [components](#components) table. The dependencies need to be satisfied for the components to be built. Note that if you don't have a dependency for some component, e.g. you don't have `libopus` installed required for building `toxav` component, building of that component is silently disabled.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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 addition of `--recurse-submodules` or by running `git submodule update --init` in the root directory of the repo. 
 | 
			
		||||
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 addition of `--recurse-submodules` or by running `git submodule update --init` in the root directory of the repo.
 | 
			
		||||
 | 
			
		||||
#### Compiler requirements
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								external/toxcore/c-toxcore/README.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								external/toxcore/c-toxcore/README.md
									
									
									
									
										vendored
									
									
								
							@@ -8,7 +8,8 @@
 | 
			
		||||
 | 
			
		||||
Tox is a peer to peer (serverless) instant messenger aimed at making security
 | 
			
		||||
and privacy easy to obtain for regular users. It uses
 | 
			
		||||
[NaCl](https://nacl.cr.yp.to/) for its encryption and authentication.
 | 
			
		||||
[libsodium](https://doc.libsodium.org/) (based on
 | 
			
		||||
[NaCl](https://nacl.cr.yp.to/)) for its encryption and authentication.
 | 
			
		||||
 | 
			
		||||
## IMPORTANT!
 | 
			
		||||
 | 
			
		||||
@@ -18,12 +19,12 @@ 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 [NaCl](https://nacl.cr.yp.to/install.html)
 | 
			
		||||
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).
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,18 +3,26 @@ set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the numb
 | 
			
		||||
add_library(auto_test_support
 | 
			
		||||
  auto_test_support.c
 | 
			
		||||
  auto_test_support.h)
 | 
			
		||||
target_link_modules(auto_test_support toxcore misc_tools)
 | 
			
		||||
target_link_libraries(auto_test_support PRIVATE misc_tools)
 | 
			
		||||
if(TARGET toxcore_static)
 | 
			
		||||
  target_link_libraries(auto_test_support PRIVATE toxcore_static)
 | 
			
		||||
else()
 | 
			
		||||
  target_link_libraries(auto_test_support PRIVATE toxcore_shared)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
function(auto_test target)
 | 
			
		||||
  if(AUTOTEST AND NOT (MSVC AND ARGV1 STREQUAL "MSVC_DONT_BUILD"))
 | 
			
		||||
    add_executable(auto_${target}_test ${target}_test.c)
 | 
			
		||||
    target_link_modules(auto_${target}_test toxcore misc_tools auto_test_support)
 | 
			
		||||
    if(NOT ARGV1 STREQUAL "DONT_RUN")
 | 
			
		||||
      add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
 | 
			
		||||
      set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
 | 
			
		||||
      # add the source dir as environment variable, so the testdata can be found
 | 
			
		||||
      set_tests_properties(${target} PROPERTIES ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw;srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
 | 
			
		||||
    endif()
 | 
			
		||||
  add_executable(auto_${target}_test ${target}_test.c)
 | 
			
		||||
  target_link_libraries(auto_${target}_test PRIVATE misc_tools auto_test_support)
 | 
			
		||||
  if(TARGET toxcore_static)
 | 
			
		||||
    target_link_libraries(auto_${target}_test PRIVATE toxcore_static)
 | 
			
		||||
  else()
 | 
			
		||||
    target_link_libraries(auto_${target}_test PRIVATE toxcore_shared)
 | 
			
		||||
  endif()
 | 
			
		||||
  if(NOT ARGV1 STREQUAL "DONT_RUN")
 | 
			
		||||
    add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
 | 
			
		||||
    set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
 | 
			
		||||
    # add the source dir as environment variable, so the testdata can be found
 | 
			
		||||
    set_tests_properties(${target} PROPERTIES ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw;srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
 | 
			
		||||
  endif()
 | 
			
		||||
endfunction()
 | 
			
		||||
 | 
			
		||||
@@ -69,17 +77,28 @@ auto_test(typing)
 | 
			
		||||
auto_test(version)
 | 
			
		||||
auto_test(save_compatibility)
 | 
			
		||||
 | 
			
		||||
target_include_directories(auto_encryptsave_test SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
 | 
			
		||||
 | 
			
		||||
if(NON_HERMETIC_TESTS)
 | 
			
		||||
  auto_test(bootstrap)
 | 
			
		||||
  auto_test(tcp_relay)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(BUILD_TOXAV)
 | 
			
		||||
  auto_test(conference_av MSVC_DONT_BUILD)
 | 
			
		||||
  auto_test(conference_av)
 | 
			
		||||
  auto_test(toxav_basic)
 | 
			
		||||
  auto_test(toxav_many)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
  target_link_libraries(auto_toxav_basic_test PRIVATE ${VPX_LIBRARIES})
 | 
			
		||||
  target_link_directories(auto_toxav_basic_test PRIVATE ${VPX_LIBRARY_DIRS})
 | 
			
		||||
  target_include_directories(auto_toxav_basic_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
 | 
			
		||||
  target_compile_options(auto_toxav_basic_test PRIVATE ${VPX_CFLAGS_OTHER})
 | 
			
		||||
 | 
			
		||||
  target_link_libraries(auto_toxav_many_test PRIVATE ${VPX_LIBRARIES})
 | 
			
		||||
  target_link_directories(auto_toxav_many_test PRIVATE ${VPX_LIBRARY_DIRS})
 | 
			
		||||
  target_include_directories(auto_toxav_many_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
 | 
			
		||||
  target_compile_options(auto_toxav_many_test PRIVATE ${VPX_CFLAGS_OTHER})
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(PROXY_TEST)
 | 
			
		||||
  auto_test(proxy)
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ libauto_test_support_la_SOURCES = ../auto_tests/auto_test_support.c ../auto_test
 | 
			
		||||
libauto_test_support_la_LIBADD = libmisc_tools.la libtoxcore.la
 | 
			
		||||
 | 
			
		||||
TESTS = \
 | 
			
		||||
        announce_test \
 | 
			
		||||
    announce_test \
 | 
			
		||||
	conference_double_invite_test \
 | 
			
		||||
	conference_invite_merge_test \
 | 
			
		||||
	conference_peer_nick_test \
 | 
			
		||||
@@ -13,6 +13,8 @@ TESTS = \
 | 
			
		||||
	conference_test \
 | 
			
		||||
	conference_two_test \
 | 
			
		||||
	crypto_test \
 | 
			
		||||
	encryptsave_test \
 | 
			
		||||
	file_saving_test \
 | 
			
		||||
	file_transfer_test \
 | 
			
		||||
	forwarding_test \
 | 
			
		||||
	friend_connection_test \
 | 
			
		||||
@@ -34,34 +36,24 @@ TESTS = \
 | 
			
		||||
	set_name_test \
 | 
			
		||||
	set_status_message_test \
 | 
			
		||||
	TCP_test \
 | 
			
		||||
	tox_events_test \
 | 
			
		||||
	tox_dispatch_test \
 | 
			
		||||
	tox_events_test \
 | 
			
		||||
	tox_many_tcp_test \
 | 
			
		||||
	tox_many_test \
 | 
			
		||||
	tox_strncasecmp_test \
 | 
			
		||||
	typing_test \
 | 
			
		||||
	version_test
 | 
			
		||||
 | 
			
		||||
if !WITH_NACL
 | 
			
		||||
TESTS += \
 | 
			
		||||
	encryptsave_test \
 | 
			
		||||
	file_saving_test
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
AUTOTEST_CFLAGS = \
 | 
			
		||||
	$(LIBSODIUM_CFLAGS) \
 | 
			
		||||
	$(NACL_CFLAGS)
 | 
			
		||||
	$(LIBSODIUM_CFLAGS)
 | 
			
		||||
 | 
			
		||||
AUTOTEST_LDADD = \
 | 
			
		||||
	$(LIBSODIUM_LDFLAGS) \
 | 
			
		||||
	$(NACL_LDFLAGS) \
 | 
			
		||||
	libmisc_tools.la \
 | 
			
		||||
	libauto_test_support.la \
 | 
			
		||||
	libtoxcore.la \
 | 
			
		||||
	libtoxencryptsave.la \
 | 
			
		||||
	$(LIBSODIUM_LIBS) \
 | 
			
		||||
	$(NACL_OBJECTS) \
 | 
			
		||||
	$(NACL_LIBS)
 | 
			
		||||
	$(LIBSODIUM_LIBS)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if BUILD_AV
 | 
			
		||||
 
 | 
			
		||||
@@ -61,9 +61,13 @@ static void test_store_data(void)
 | 
			
		||||
    ck_assert(log != nullptr);
 | 
			
		||||
    logger_callback_log(log, print_debug_logger, nullptr, nullptr);
 | 
			
		||||
    Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
 | 
			
		||||
    ck_assert(mono_time != nullptr);
 | 
			
		||||
    Networking_Core *net = new_networking_no_udp(log, mem, ns);
 | 
			
		||||
    ck_assert(net != nullptr);
 | 
			
		||||
    DHT *dht = new_dht(log, mem, rng, ns, mono_time, net, true, true);
 | 
			
		||||
    ck_assert(dht != nullptr);
 | 
			
		||||
    Forwarding *forwarding = new_forwarding(log, rng, mono_time, dht);
 | 
			
		||||
    ck_assert(forwarding != nullptr);
 | 
			
		||||
    Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding);
 | 
			
		||||
    ck_assert(announce != nullptr);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,6 @@ static const struct BootstrapNodes {
 | 
			
		||||
    uint16_t      port;
 | 
			
		||||
    const uint8_t key[32];
 | 
			
		||||
} bootstrap_nodes[] = {
 | 
			
		||||
#ifndef USE_TEST_NETWORK
 | 
			
		||||
    {
 | 
			
		||||
        "tox.abilinski.com", 33445,
 | 
			
		||||
        0x10, 0xC0, 0x0E, 0xB2, 0x50, 0xC3, 0x23, 0x3E,
 | 
			
		||||
@@ -57,22 +56,6 @@ static const struct BootstrapNodes {
 | 
			
		||||
        0x6D, 0xC9, 0xD0, 0xA3, 0x00, 0xE6, 0xC3, 0x57,
 | 
			
		||||
        0x63, 0x4E, 0xE2, 0xDA, 0x88, 0xC3, 0x54, 0x63,
 | 
			
		||||
    },
 | 
			
		||||
#else
 | 
			
		||||
    {
 | 
			
		||||
        "172.93.52.70", 33445,
 | 
			
		||||
        0x79, 0xCA, 0xDA, 0x49, 0x74, 0xB0, 0x92, 0x6F,
 | 
			
		||||
        0x28, 0x6F, 0x02, 0x5C, 0xD5, 0xFF, 0xDF, 0x3E,
 | 
			
		||||
        0x65, 0x4A, 0x37, 0x58, 0xC5, 0x3E, 0x02, 0x73,
 | 
			
		||||
        0xEC, 0xFC, 0x4D, 0x12, 0xC2, 0x1D, 0xCA, 0x48,
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "tox.plastiras.org", 38445,
 | 
			
		||||
        0x5E, 0x47, 0xBA, 0x1D, 0xC3, 0x91, 0x3E, 0xB2,
 | 
			
		||||
        0xCB, 0xF2, 0xD6, 0x4C, 0xE4, 0xF2, 0x3D, 0x8B,
 | 
			
		||||
        0xFE, 0x53, 0x91, 0xBF, 0xAB, 0xE5, 0xC4, 0x3C,
 | 
			
		||||
        0x5B, 0xAD, 0x13, 0xF0, 0xA4, 0x14, 0xCD, 0x77,
 | 
			
		||||
    },
 | 
			
		||||
#endif  // USE_TEST_NETWORK
 | 
			
		||||
    { nullptr, 0, 0 },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -332,7 +315,7 @@ static void bootstrap_autotoxes(struct Tox_Options *options, uint32_t tox_count,
 | 
			
		||||
    for (uint32_t i = 1; i < tox_count; ++i) {
 | 
			
		||||
        Tox_Err_Bootstrap err;
 | 
			
		||||
        tox_bootstrap(autotoxes[i].tox, "localhost", dht_port, dht_key, &err);
 | 
			
		||||
        ck_assert(err == TOX_ERR_BOOTSTRAP_OK);
 | 
			
		||||
        ck_assert_msg(err == TOX_ERR_BOOTSTRAP_OK, "bootstrap error for port %d: %d", dht_port, err);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!udp_enabled) {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,6 @@
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
#include <sodium.h>
 | 
			
		||||
 | 
			
		||||
#include "../testing/misc_tools.h"
 | 
			
		||||
@@ -232,9 +231,3 @@ int main(void)
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#else  // VANILLA_NACL
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "auto_test_support.h"
 | 
			
		||||
#include "../toxcore/tox_private.h"
 | 
			
		||||
 | 
			
		||||
typedef struct State {
 | 
			
		||||
    size_t   peer_joined_count;
 | 
			
		||||
@@ -42,6 +43,22 @@ typedef struct State {
 | 
			
		||||
 | 
			
		||||
#define PEER_LIMIT 20
 | 
			
		||||
 | 
			
		||||
static void print_ip(Tox *tox, uint32_t groupnumber, uint32_t peer_id)
 | 
			
		||||
{
 | 
			
		||||
    Tox_Err_Group_Peer_Query err;
 | 
			
		||||
    size_t length = tox_group_peer_get_ip_address_size(tox, groupnumber, peer_id, &err);
 | 
			
		||||
 | 
			
		||||
    ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address size: error %d", err);
 | 
			
		||||
 | 
			
		||||
    uint8_t ip_str[TOX_GROUP_PEER_IP_STRING_MAX_LENGTH];
 | 
			
		||||
    tox_group_peer_get_ip_address(tox, groupnumber, peer_id, ip_str, &err);
 | 
			
		||||
    ip_str[length] = '\0';
 | 
			
		||||
 | 
			
		||||
    ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address: error %d", err);
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "%s\n", ip_str);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool all_group_peers_connected(AutoTox *autotoxes, uint32_t tox_count, uint32_t groupnumber, size_t name_length)
 | 
			
		||||
{
 | 
			
		||||
    for (size_t i = 0; i < tox_count; ++i) {
 | 
			
		||||
@@ -119,6 +136,9 @@ static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t pee
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "%s joined with IP: ", peer_name);
 | 
			
		||||
    print_ip(tox, groupnumber, peer_id);
 | 
			
		||||
 | 
			
		||||
    state->peer_id = peer_id;
 | 
			
		||||
    ++state->peer_joined_count;
 | 
			
		||||
}
 | 
			
		||||
@@ -178,6 +198,11 @@ static void group_peer_self_join_handler(Tox *tox, uint32_t groupnumber, void *u
 | 
			
		||||
    ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", query_err);
 | 
			
		||||
    ck_assert(memcmp(topic, TOPIC, TOPIC_LEN) == 0);
 | 
			
		||||
 | 
			
		||||
    uint32_t peer_id = tox_group_self_get_peer_id(tox, groupnumber, nullptr);
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "self joined with IP: ");
 | 
			
		||||
    print_ip(tox, groupnumber, peer_id);
 | 
			
		||||
 | 
			
		||||
    ++state->self_joined_count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -234,7 +259,6 @@ static void group_peer_status_handler(Tox *tox, uint32_t groupnumber, uint32_t p
 | 
			
		||||
 | 
			
		||||
static void group_announce_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES == 2, "NUM_GROUP_TOXES needs to be 2");
 | 
			
		||||
 | 
			
		||||
    Tox *tox0 = autotoxes[0].tox;
 | 
			
		||||
@@ -341,6 +365,7 @@ static void group_announce_test(AutoTox *autotoxes)
 | 
			
		||||
    ck_assert(memcmp(tox0_pk_query, tox0_self_pk, TOX_GROUP_PEER_PUBLIC_KEY_SIZE) == 0);
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "Peer 0 disconnecting...\n");
 | 
			
		||||
 | 
			
		||||
    // tox 0 disconnects then reconnects
 | 
			
		||||
    Tox_Err_Group_Disconnect d_err;
 | 
			
		||||
    tox_group_disconnect(tox0, groupnumber, &d_err);
 | 
			
		||||
@@ -410,7 +435,6 @@ static void group_announce_test(AutoTox *autotoxes)
 | 
			
		||||
    ck_assert(num_groups1 == num_groups2 && num_groups2 == 0);
 | 
			
		||||
 | 
			
		||||
    printf("All tests passed!\n");
 | 
			
		||||
#endif  // VANILLA_NACL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -102,7 +102,6 @@ static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t pe
 | 
			
		||||
 | 
			
		||||
static void group_invite_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES > 7, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
 | 
			
		||||
 | 
			
		||||
    for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
 | 
			
		||||
@@ -260,8 +259,6 @@ static void group_invite_test(AutoTox *autotoxes)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printf("All tests passed!\n");
 | 
			
		||||
 | 
			
		||||
#endif // VANILLA_NACL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -350,7 +350,6 @@ static void group_message_handler_wraparound_test(Tox *tox, uint32_t groupnumber
 | 
			
		||||
 | 
			
		||||
static void group_message_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES >= 2, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
 | 
			
		||||
 | 
			
		||||
    const Random *rng = system_random();
 | 
			
		||||
@@ -544,7 +543,6 @@ static void group_message_test(AutoTox *autotoxes)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "All tests passed!\n");
 | 
			
		||||
#endif  // VANILLA_NACL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -432,7 +432,6 @@ static void check_voice_state(AutoTox *autotoxes, uint32_t num_toxes)
 | 
			
		||||
 | 
			
		||||
static void group_moderation_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES >= 4, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES < 10, "NUM_GROUP_TOXES is too big: %d", NUM_GROUP_TOXES);
 | 
			
		||||
 | 
			
		||||
@@ -634,7 +633,6 @@ static void group_moderation_test(AutoTox *autotoxes)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "All tests passed!\n");
 | 
			
		||||
#endif  // VANILLA_NACL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -148,7 +148,6 @@ static int has_correct_self_state(const Tox *tox, uint32_t group_number, const u
 | 
			
		||||
 | 
			
		||||
static void group_save_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES > 1, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
 | 
			
		||||
 | 
			
		||||
    for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
 | 
			
		||||
@@ -270,8 +269,6 @@ static void group_save_test(AutoTox *autotoxes)
 | 
			
		||||
    tox_kill(new_tox);
 | 
			
		||||
 | 
			
		||||
    printf("All tests passed!\n");
 | 
			
		||||
 | 
			
		||||
#endif  // VANILLA_NACL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -238,7 +238,6 @@ static void set_group_state(Tox *tox, uint32_t groupnumber, uint32_t peer_limit,
 | 
			
		||||
 | 
			
		||||
static void group_state_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
 | 
			
		||||
 | 
			
		||||
    for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
 | 
			
		||||
@@ -318,8 +317,6 @@ static void group_state_test(AutoTox *autotoxes)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "All tests passed!\n");
 | 
			
		||||
 | 
			
		||||
#endif /* VANILLA_NACL */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -330,7 +330,6 @@ static void topic_spam(const Random *rng, AutoTox *autotoxes, uint32_t num_peers
 | 
			
		||||
 | 
			
		||||
static void group_sync_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert(NUM_GROUP_TOXES >= 5);
 | 
			
		||||
    const Random *rng = system_random();
 | 
			
		||||
    ck_assert(rng != nullptr);
 | 
			
		||||
@@ -443,8 +442,6 @@ static void group_sync_test(AutoTox *autotoxes)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "All tests passed!\n");
 | 
			
		||||
 | 
			
		||||
#endif  // VANILLA_NACL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -8,8 +8,6 @@
 | 
			
		||||
 | 
			
		||||
#include "auto_test_support.h"
 | 
			
		||||
 | 
			
		||||
#ifdef USE_TEST_NETWORK
 | 
			
		||||
 | 
			
		||||
#define NUM_GROUP_TOXES 2
 | 
			
		||||
#define CODEWORD "RONALD MCDONALD"
 | 
			
		||||
#define CODEWORD_LEN (sizeof(CODEWORD) - 1)
 | 
			
		||||
@@ -129,7 +127,6 @@ static bool all_peers_got_code(AutoTox *autotoxes)
 | 
			
		||||
 | 
			
		||||
static void group_tcp_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert(NUM_GROUP_TOXES >= 2);
 | 
			
		||||
 | 
			
		||||
    State *state0 = (State *)autotoxes[0].state;
 | 
			
		||||
@@ -222,34 +219,29 @@ static void group_tcp_test(AutoTox *autotoxes)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printf("Test passed!\n");
 | 
			
		||||
 | 
			
		||||
#endif // VANILLA_NACL
 | 
			
		||||
}
 | 
			
		||||
#endif // USE_TEST_NETWORK
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
#ifdef USE_TEST_NETWORK  // TODO(Jfreegman): Enable this test when the mainnet works with DHT groupchats
 | 
			
		||||
    setvbuf(stdout, nullptr, _IONBF, 0);
 | 
			
		||||
 | 
			
		||||
    struct Tox_Options *options = (struct Tox_Options *)calloc(1, sizeof(struct Tox_Options));
 | 
			
		||||
    struct Tox_Options *options = tox_options_new(nullptr);
 | 
			
		||||
    ck_assert(options != nullptr);
 | 
			
		||||
 | 
			
		||||
    tox_options_default(options);
 | 
			
		||||
    tox_options_set_udp_enabled(options, false);
 | 
			
		||||
 | 
			
		||||
    Run_Auto_Options autotest_opts = default_run_auto_options();
 | 
			
		||||
    autotest_opts.graph = GRAPH_COMPLETE;
 | 
			
		||||
 | 
			
		||||
    run_auto_test(options, NUM_GROUP_TOXES, group_tcp_test, sizeof(State), &autotest_opts);
 | 
			
		||||
    // TODO(JFreegman): Fix this test and remove the "if".
 | 
			
		||||
    if (argc > 2) {
 | 
			
		||||
        run_auto_test(options, NUM_GROUP_TOXES, group_tcp_test, sizeof(State), &autotest_opts);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tox_options_free(options);
 | 
			
		||||
#endif
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef USE_TEST_NETWORK
 | 
			
		||||
#undef NUM_GROUP_TOXES
 | 
			
		||||
#undef CODEWORD_LEN
 | 
			
		||||
#undef CODEWORD
 | 
			
		||||
#endif // USE_TEST_NETWORK
 | 
			
		||||
#undef NUM_GROUP_TOXES
 | 
			
		||||
 
 | 
			
		||||
@@ -203,7 +203,6 @@ static uint32_t set_topic_all_peers(const Random *rng, AutoTox *autotoxes, size_
 | 
			
		||||
 | 
			
		||||
static void group_topic_test(AutoTox *autotoxes)
 | 
			
		||||
{
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
    ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
 | 
			
		||||
 | 
			
		||||
    const Random *rng = system_random();
 | 
			
		||||
@@ -318,8 +317,6 @@ static void group_topic_test(AutoTox *autotoxes)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "All tests passed!\n");
 | 
			
		||||
 | 
			
		||||
#endif /* VANILLA_NACL */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -7,15 +7,8 @@
 | 
			
		||||
#include "auto_test_support.h"
 | 
			
		||||
#include "check_compat.h"
 | 
			
		||||
 | 
			
		||||
static uint8_t const key[] = {
 | 
			
		||||
    0x15, 0xE9, 0xC3, 0x09, 0xCF, 0xCB, 0x79, 0xFD,
 | 
			
		||||
    0xDF, 0x0E, 0xBA, 0x05, 0x7D, 0xAB, 0xB4, 0x9F,
 | 
			
		||||
    0xE1, 0x5F, 0x38, 0x03, 0xB1, 0xBF, 0xF0, 0x65,
 | 
			
		||||
    0x36, 0xAE, 0x2E, 0x5B, 0xA5, 0xE4, 0x69, 0x0E,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Try to bootstrap for 30 seconds.
 | 
			
		||||
#define NUM_ITERATIONS (unsigned)(30.0 / (ITERATION_INTERVAL / 1000.0))
 | 
			
		||||
// Try to bootstrap for 20 seconds.
 | 
			
		||||
#define NUM_ITERATIONS (unsigned)(20.0 / (ITERATION_INTERVAL / 1000.0))
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
@@ -24,13 +17,12 @@ int main(void)
 | 
			
		||||
    struct Tox_Options *opts = tox_options_new(nullptr);
 | 
			
		||||
    tox_options_set_udp_enabled(opts, false);
 | 
			
		||||
    tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5);
 | 
			
		||||
    tox_options_set_proxy_host(opts, "localhost");
 | 
			
		||||
    tox_options_set_proxy_host(opts, "127.0.0.1");
 | 
			
		||||
    tox_options_set_proxy_port(opts, 51724);
 | 
			
		||||
    Tox *tox = tox_new_log(opts, nullptr, nullptr);
 | 
			
		||||
    tox_options_free(opts);
 | 
			
		||||
 | 
			
		||||
    tox_add_tcp_relay(tox, "tox.ngc.zone", 33445, key, nullptr);
 | 
			
		||||
    tox_bootstrap(tox, "tox.ngc.zone", 33445, key, nullptr);
 | 
			
		||||
    bootstrap_tox_live_network(tox, true);
 | 
			
		||||
 | 
			
		||||
    printf("Waiting for connection...\n");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,15 +7,8 @@
 | 
			
		||||
#include "auto_test_support.h"
 | 
			
		||||
#include "check_compat.h"
 | 
			
		||||
 | 
			
		||||
static uint8_t const key[] = {
 | 
			
		||||
    0x15, 0xE9, 0xC3, 0x09, 0xCF, 0xCB, 0x79, 0xFD,
 | 
			
		||||
    0xDF, 0x0E, 0xBA, 0x05, 0x7D, 0xAB, 0xB4, 0x9F,
 | 
			
		||||
    0xE1, 0x5F, 0x38, 0x03, 0xB1, 0xBF, 0xF0, 0x65,
 | 
			
		||||
    0x36, 0xAE, 0x2E, 0x5B, 0xA5, 0xE4, 0x69, 0x0E,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Try to bootstrap for 30 seconds.
 | 
			
		||||
#define NUM_ITERATIONS (unsigned)(30.0 / (ITERATION_INTERVAL / 1000.0))
 | 
			
		||||
// Try to bootstrap for 20 seconds.
 | 
			
		||||
#define NUM_ITERATIONS (unsigned)(20.0 / (ITERATION_INTERVAL / 1000.0))
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
@@ -24,13 +17,12 @@ int main(void)
 | 
			
		||||
    struct Tox_Options *opts = tox_options_new(nullptr);
 | 
			
		||||
    tox_options_set_udp_enabled(opts, true);
 | 
			
		||||
    tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5);
 | 
			
		||||
    tox_options_set_proxy_host(opts, "localhost");
 | 
			
		||||
    tox_options_set_proxy_host(opts, "127.0.0.1");
 | 
			
		||||
    tox_options_set_proxy_port(opts, 51724);
 | 
			
		||||
    Tox *tox = tox_new_log(opts, nullptr, nullptr);
 | 
			
		||||
    tox_options_free(opts);
 | 
			
		||||
 | 
			
		||||
    tox_add_tcp_relay(tox, "tox.ngc.zone", 33445, key, nullptr);
 | 
			
		||||
    tox_bootstrap(tox, "tox.ngc.zone", 33445, key, nullptr);
 | 
			
		||||
    bootstrap_tox_live_network(tox, true);
 | 
			
		||||
 | 
			
		||||
    printf("Waiting for connection...");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ static int handle_test_1(void *object, const IP_Port *source, const uint8_t *pac
 | 
			
		||||
    res_packet[0] = NET_PACKET_ANNOUNCE_RESPONSE;
 | 
			
		||||
    memcpy(res_packet + 1, res_message, sizeof(res_message));
 | 
			
		||||
 | 
			
		||||
    if (send_onion_response(onion->net, source, res_packet, sizeof(res_packet),
 | 
			
		||||
    if (send_onion_response(onion->log, onion->net, source, res_packet, sizeof(res_packet),
 | 
			
		||||
                            packet + sizeof(res_packet)) == -1) {
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
@@ -293,7 +293,7 @@ static void test_basic(void)
 | 
			
		||||
    uint64_t s;
 | 
			
		||||
    memcpy(&s, sb_data, sizeof(uint64_t));
 | 
			
		||||
    memcpy(test_3_pub_key, nodes[3].public_key, CRYPTO_PUBLIC_KEY_SIZE);
 | 
			
		||||
    int ret = send_announce_request(onion1->net, rng, &path, &nodes[3],
 | 
			
		||||
    int ret = send_announce_request(log1, onion1->net, rng, &path, &nodes[3],
 | 
			
		||||
                                    dht_get_self_public_key(onion1->dht),
 | 
			
		||||
                                    dht_get_self_secret_key(onion1->dht),
 | 
			
		||||
                                    zeroes,
 | 
			
		||||
@@ -315,7 +315,7 @@ static void test_basic(void)
 | 
			
		||||
    memcpy(onion_announce_entry_public_key(onion2_a, 1), dht_get_self_public_key(onion2->dht), CRYPTO_PUBLIC_KEY_SIZE);
 | 
			
		||||
    onion_announce_entry_set_time(onion2_a, 1, mono_time_get(mono_time2));
 | 
			
		||||
    networking_registerhandler(onion1->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_test_4, onion1);
 | 
			
		||||
    send_announce_request(onion1->net, rng, &path, &nodes[3],
 | 
			
		||||
    send_announce_request(log1, onion1->net, rng, &path, &nodes[3],
 | 
			
		||||
                          dht_get_self_public_key(onion1->dht),
 | 
			
		||||
                          dht_get_self_secret_key(onion1->dht),
 | 
			
		||||
                          test_3_ping_id,
 | 
			
		||||
@@ -340,7 +340,7 @@ static void test_basic(void)
 | 
			
		||||
    ck_assert_msg((onion3 != nullptr), "Onion failed initializing.");
 | 
			
		||||
 | 
			
		||||
    random_nonce(rng, nonce);
 | 
			
		||||
    ret = send_data_request(onion3->net, rng, &path, &nodes[3].ip_port,
 | 
			
		||||
    ret = send_data_request(log3, onion3->net, rng, &path, &nodes[3].ip_port,
 | 
			
		||||
                            dht_get_self_public_key(onion1->dht),
 | 
			
		||||
                            dht_get_self_public_key(onion1->dht),
 | 
			
		||||
                            nonce, (const uint8_t *)"Install gentoo", sizeof("Install gentoo"));
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,7 @@ static void send_message_test(AutoTox *autotoxes)
 | 
			
		||||
 | 
			
		||||
    const size_t msgs_len = tox_max_message_length() + 1;
 | 
			
		||||
    uint8_t *msgs = (uint8_t *)malloc(msgs_len);
 | 
			
		||||
    ck_assert(msgs != nullptr);
 | 
			
		||||
    memset(msgs, MESSAGE_FILLER, msgs_len);
 | 
			
		||||
 | 
			
		||||
    Tox_Err_Friend_Send_Message errm;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
#include "../toxcore/tox.h"
 | 
			
		||||
#include "../toxcore/tox_dispatch.h"
 | 
			
		||||
#include "../toxcore/tox_events.h"
 | 
			
		||||
#include "../toxcore/tox_unpack.h"
 | 
			
		||||
#include "auto_test_support.h"
 | 
			
		||||
#include "check_compat.h"
 | 
			
		||||
 | 
			
		||||
@@ -30,31 +31,36 @@ static void handle_events_friend_message(Tox *tox, const Tox_Event_Friend_Messag
 | 
			
		||||
 | 
			
		||||
static void dump_events(const char *path, const Tox_Events *events)
 | 
			
		||||
{
 | 
			
		||||
    if (want_dump_events) {
 | 
			
		||||
        FILE *fh = fopen(path, "w");
 | 
			
		||||
        ck_assert(fh != nullptr);
 | 
			
		||||
        const uint32_t len = tox_events_bytes_size(events);
 | 
			
		||||
        uint8_t *buf = (uint8_t *)malloc(len);
 | 
			
		||||
        ck_assert(buf != nullptr);
 | 
			
		||||
        tox_events_get_bytes(events, buf);
 | 
			
		||||
        fwrite(buf, 1, len, fh);
 | 
			
		||||
        free(buf);
 | 
			
		||||
        fclose(fh);
 | 
			
		||||
    }
 | 
			
		||||
    FILE *fh = fopen(path, "w");
 | 
			
		||||
    ck_assert(fh != nullptr);
 | 
			
		||||
    const uint32_t len = tox_events_bytes_size(events);
 | 
			
		||||
    uint8_t *buf = (uint8_t *)malloc(len);
 | 
			
		||||
    ck_assert(buf != nullptr);
 | 
			
		||||
    ck_assert(tox_events_get_bytes(events, buf));
 | 
			
		||||
    fwrite(buf, 1, len, fh);
 | 
			
		||||
    free(buf);
 | 
			
		||||
    fclose(fh);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void print_events(const Tox_System *sys, Tox_Events *events)
 | 
			
		||||
{
 | 
			
		||||
    const uint32_t size = tox_events_bytes_size(events);
 | 
			
		||||
 | 
			
		||||
    uint8_t *bytes = (uint8_t *)malloc(size);
 | 
			
		||||
    ck_assert(bytes != nullptr);
 | 
			
		||||
    uint8_t *bytes1 = (uint8_t *)malloc(size);
 | 
			
		||||
    uint8_t *bytes2 = (uint8_t *)malloc(size);
 | 
			
		||||
    ck_assert(bytes1 != nullptr);
 | 
			
		||||
    ck_assert(bytes2 != nullptr);
 | 
			
		||||
 | 
			
		||||
    tox_events_get_bytes(events, bytes);
 | 
			
		||||
    ck_assert(tox_events_get_bytes(events, bytes1));
 | 
			
		||||
    ck_assert(tox_events_get_bytes(events, bytes2));
 | 
			
		||||
 | 
			
		||||
    Tox_Events *events_copy = tox_events_load(sys, bytes, size);
 | 
			
		||||
    // Make sure get_bytes is deterministic.
 | 
			
		||||
    ck_assert(memcmp(bytes1, bytes2, size) == 0);
 | 
			
		||||
 | 
			
		||||
    Tox_Events *events_copy = tox_events_load(sys, bytes1, size);
 | 
			
		||||
    ck_assert(events_copy != nullptr);
 | 
			
		||||
    free(bytes);
 | 
			
		||||
    free(bytes1);
 | 
			
		||||
    free(bytes2);
 | 
			
		||||
 | 
			
		||||
    ck_assert(tox_events_equal(sys, events, events_copy));
 | 
			
		||||
 | 
			
		||||
@@ -72,7 +78,9 @@ static bool await_message(Tox **toxes, const Tox_Dispatch *dispatch)
 | 
			
		||||
        // Check if tox 2 got the message from tox 1.
 | 
			
		||||
        Tox_Events *events = tox_events_iterate(toxes[1], false, nullptr);
 | 
			
		||||
 | 
			
		||||
        dump_events("/tmp/test.mp", events);
 | 
			
		||||
        if (want_dump_events) {
 | 
			
		||||
            dump_events("/tmp/test.mp", events);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        bool success = false;
 | 
			
		||||
        tox_dispatch_invoke(dispatch, events, toxes[1], &success);
 | 
			
		||||
@@ -160,9 +168,22 @@ static void test_tox_events(void)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void fake_test_unpack(void)
 | 
			
		||||
{
 | 
			
		||||
    // TODO(Green-Sky): add proper unpack tests and/or implement ngc events
 | 
			
		||||
    (void)tox_group_privacy_state_unpack;
 | 
			
		||||
    (void)tox_group_privacy_state_unpack;
 | 
			
		||||
    (void)tox_group_voice_state_unpack;
 | 
			
		||||
    (void)tox_group_topic_lock_unpack;
 | 
			
		||||
    (void)tox_group_join_fail_unpack;
 | 
			
		||||
    (void)tox_group_mod_event_unpack;
 | 
			
		||||
    (void)tox_group_exit_type_unpack;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
    setvbuf(stdout, nullptr, _IONBF, 0);
 | 
			
		||||
    test_tox_events();
 | 
			
		||||
    fake_test_unpack();
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,15 @@ static bool await_message(Tox **toxes)
 | 
			
		||||
            const uint8_t *msg = tox_event_friend_message_get_message(msg_event);
 | 
			
		||||
            ck_assert_msg(memcmp(msg, "hello", sizeof("hello")) == 0,
 | 
			
		||||
                          "message was not expected 'hello' but '%s'", (const char *)msg);
 | 
			
		||||
 | 
			
		||||
            const uint32_t event_count = tox_events_get_size(events);
 | 
			
		||||
            for (uint32_t j = 0; j < event_count; ++j) {
 | 
			
		||||
                const Tox_Event *event = tox_events_get(events, j);
 | 
			
		||||
                if (tox_event_get_type(event) == TOX_EVENT_FRIEND_MESSAGE) {
 | 
			
		||||
                    ck_assert(tox_event_get_friend_message(event) == msg_event);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            tox_events_free(events);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,62 +0,0 @@
 | 
			
		||||
# Find and compile the GTest library.
 | 
			
		||||
 | 
			
		||||
include(CheckCXXCompilerFlag)
 | 
			
		||||
include(CheckIncludeFileCXX)
 | 
			
		||||
 | 
			
		||||
message(STATUS "Checking for gtest")
 | 
			
		||||
 | 
			
		||||
# Look for the sources.
 | 
			
		||||
find_file(GTEST_ALL_CC gtest-all.cc PATHS
 | 
			
		||||
  ${CMAKE_SOURCE_DIR}/third_party/googletest/googletest/src
 | 
			
		||||
  /usr/src/gtest/src
 | 
			
		||||
  NO_DEFAULT_PATH
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if(GTEST_ALL_CC)
 | 
			
		||||
  # ../.. from the source file is the source root.
 | 
			
		||||
  get_filename_component(GTEST_SRC_DIR ${GTEST_ALL_CC} DIRECTORY)
 | 
			
		||||
  get_filename_component(GTEST_SRC_ROOT ${GTEST_SRC_DIR} DIRECTORY)
 | 
			
		||||
 | 
			
		||||
  # Look for the header file.
 | 
			
		||||
  include(CheckIncludeFileCXX)
 | 
			
		||||
  include_directories(SYSTEM ${GTEST_SRC_ROOT}/include)
 | 
			
		||||
  check_include_file_cxx("gtest/gtest.h" HAVE_GTEST_GTEST_H)
 | 
			
		||||
 | 
			
		||||
  if(HAVE_GTEST_GTEST_H)
 | 
			
		||||
    message(STATUS "Found gtest: ${GTEST_SRC_ROOT}")
 | 
			
		||||
 | 
			
		||||
    add_library(gtest
 | 
			
		||||
      ${GTEST_SRC_DIR}/gtest-all.cc
 | 
			
		||||
      ${GTEST_SRC_DIR}/gtest_main.cc)
 | 
			
		||||
    target_include_directories(gtest PRIVATE ${GTEST_SRC_ROOT})
 | 
			
		||||
 | 
			
		||||
    # Ignore all warnings for gtest. We don't care about their implementation.
 | 
			
		||||
    check_cxx_compiler_flag("-w" HAVE_CXX_W QUIET)
 | 
			
		||||
    if(HAVE_CXX_W)
 | 
			
		||||
      set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
    set(HAVE_GTEST TRUE)
 | 
			
		||||
    set(TEST_CXX_FLAGS "")
 | 
			
		||||
 | 
			
		||||
    check_cxx_compiler_flag("-Wno-global-constructors" HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS QUIET)
 | 
			
		||||
    if(HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS)
 | 
			
		||||
      set(TEST_CXX_FLAGS "${TEST_CXX_FLAGS} -Wno-global-constructors")
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
    check_cxx_compiler_flag("-Wno-zero-as-null-pointer-constant" HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT QUIET)
 | 
			
		||||
    if(HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT)
 | 
			
		||||
      set(TEST_CXX_FLAGS "${TEST_CXX_FLAGS} -Wno-zero-as-null-pointer-constant")
 | 
			
		||||
    endif()
 | 
			
		||||
  endif()
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
function(unit_test subdir target)
 | 
			
		||||
  if(HAVE_GTEST)
 | 
			
		||||
    add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
 | 
			
		||||
    target_link_modules(unit_${target}_test toxcore gtest)
 | 
			
		||||
    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")
 | 
			
		||||
  endif()
 | 
			
		||||
endfunction()
 | 
			
		||||
@@ -8,19 +8,25 @@ include(ModulePackage)
 | 
			
		||||
 | 
			
		||||
find_package(Threads REQUIRED)
 | 
			
		||||
 | 
			
		||||
find_library(NSL_LIBRARIES          nsl          )
 | 
			
		||||
find_library(RT_LIBRARIES           rt           )
 | 
			
		||||
find_library(SOCKET_LIBRARIES       socket       )
 | 
			
		||||
find_library(NSL_LIBRARIES    nsl   )
 | 
			
		||||
find_library(RT_LIBRARIES     rt    )
 | 
			
		||||
find_library(SOCKET_LIBRARIES socket)
 | 
			
		||||
 | 
			
		||||
# For toxcore.
 | 
			
		||||
pkg_use_module(LIBSODIUM            libsodium    )
 | 
			
		||||
pkg_search_module(LIBSODIUM   libsodium IMPORTED_TARGET)
 | 
			
		||||
 | 
			
		||||
# For toxav.
 | 
			
		||||
pkg_use_module(OPUS                 "opus;Opus"  )
 | 
			
		||||
pkg_use_module(VPX                  "vpx;libvpx" )
 | 
			
		||||
pkg_search_module(OPUS        opus      IMPORTED_TARGET)
 | 
			
		||||
if(NOT OPUS_FOUND)
 | 
			
		||||
  pkg_search_module(OPUS      Opus      IMPORTED_TARGET)
 | 
			
		||||
endif()
 | 
			
		||||
pkg_search_module(VPX         vpx       IMPORTED_TARGET)
 | 
			
		||||
if(NOT VPX_FOUND)
 | 
			
		||||
  pkg_search_module(VPX       libvpx    IMPORTED_TARGET)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
# For tox-bootstrapd.
 | 
			
		||||
pkg_use_module(LIBCONFIG            libconfig    )
 | 
			
		||||
pkg_search_module(LIBCONFIG   libconfig IMPORTED_TARGET)
 | 
			
		||||
 | 
			
		||||
###############################################################################
 | 
			
		||||
#
 | 
			
		||||
 
 | 
			
		||||
@@ -21,41 +21,6 @@ endif()
 | 
			
		||||
 | 
			
		||||
find_package(PkgConfig)
 | 
			
		||||
 | 
			
		||||
function(pkg_use_module mod pkgs)
 | 
			
		||||
  foreach(pkg IN ITEMS ${pkgs})
 | 
			
		||||
    if(PKG_CONFIG_FOUND)
 | 
			
		||||
      pkg_search_module(${mod} ${pkg})
 | 
			
		||||
    endif()
 | 
			
		||||
    if(NOT ${mod}_FOUND)
 | 
			
		||||
      find_package(${pkg} QUIET)
 | 
			
		||||
      # This is very very ugly, but the variables are sometimes used in this scope
 | 
			
		||||
      # and sometimes in the parent scope, so we have to set them to both places.
 | 
			
		||||
      set(${mod}_FOUND ${${pkg}_FOUND})
 | 
			
		||||
      set(${mod}_FOUND ${${pkg}_FOUND} PARENT_SCOPE)
 | 
			
		||||
      set(${mod}_LIBRARIES ${${pkg}_LIBS})
 | 
			
		||||
      set(${mod}_LIBRARIES ${${pkg}_LIBS} PARENT_SCOPE)
 | 
			
		||||
      set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS})
 | 
			
		||||
      set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS} PARENT_SCOPE)
 | 
			
		||||
      set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS})
 | 
			
		||||
      set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS} PARENT_SCOPE)
 | 
			
		||||
    endif()
 | 
			
		||||
    if(${mod}_FOUND)
 | 
			
		||||
      link_directories(${${mod}_LIBRARY_DIRS})
 | 
			
		||||
      include_directories(${${mod}_INCLUDE_DIRS})
 | 
			
		||||
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE)
 | 
			
		||||
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE)
 | 
			
		||||
 | 
			
		||||
      if(NOT MSVC)
 | 
			
		||||
        foreach(dir ${${mod}_INCLUDE_DIRS})
 | 
			
		||||
          set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE)
 | 
			
		||||
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE)
 | 
			
		||||
        endforeach()
 | 
			
		||||
      endif()
 | 
			
		||||
      break()
 | 
			
		||||
    endif()
 | 
			
		||||
  endforeach()
 | 
			
		||||
endfunction()
 | 
			
		||||
 | 
			
		||||
function(add_module lib)
 | 
			
		||||
  set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
 | 
			
		||||
 | 
			
		||||
@@ -70,7 +35,7 @@ function(add_module lib)
 | 
			
		||||
endfunction()
 | 
			
		||||
 | 
			
		||||
function(install_module lib)
 | 
			
		||||
  if(ENABLE_SHARED)
 | 
			
		||||
  if(TARGET ${lib}_shared)
 | 
			
		||||
    set_target_properties(${lib}_shared PROPERTIES
 | 
			
		||||
      VERSION ${SOVERSION}
 | 
			
		||||
      SOVERSION ${SOVERSION_MAJOR}
 | 
			
		||||
@@ -80,7 +45,7 @@ function(install_module lib)
 | 
			
		||||
      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
 | 
			
		||||
      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
 | 
			
		||||
  endif()
 | 
			
		||||
  if(ENABLE_STATIC)
 | 
			
		||||
  if(TARGET ${lib}_static)
 | 
			
		||||
    install(TARGETS ${lib}_static
 | 
			
		||||
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
 | 
			
		||||
      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
 | 
			
		||||
@@ -113,59 +78,3 @@ function(install_module lib)
 | 
			
		||||
    install(FILES ${header} ${ARGN})
 | 
			
		||||
  endforeach()
 | 
			
		||||
endfunction()
 | 
			
		||||
 | 
			
		||||
function(target_link_modules target)
 | 
			
		||||
  # If the target we're adding dependencies to is a shared library, add it to
 | 
			
		||||
  # the set of targets.
 | 
			
		||||
  if(TARGET ${target}_shared)
 | 
			
		||||
    set(_targets ${_targets} ${target}_shared)
 | 
			
		||||
    # Shared libraries should first try to link against other shared libraries.
 | 
			
		||||
    set(${target}_shared_primary shared)
 | 
			
		||||
    # If that fails (because the shared target doesn't exist), try linking
 | 
			
		||||
    # against the static library. This requires the static library's objects to
 | 
			
		||||
    # be PIC.
 | 
			
		||||
    set(${target}_shared_secondary static)
 | 
			
		||||
  endif()
 | 
			
		||||
  # It can also be a static library at the same time.
 | 
			
		||||
  if(TARGET ${target}_static)
 | 
			
		||||
    set(_targets ${_targets} ${target}_static)
 | 
			
		||||
    # Static libraries aren't actually linked, but their dependencies are
 | 
			
		||||
    # recorded by "linking" them. If we link an executable to a static library,
 | 
			
		||||
    # we want to also link statically against its transitive dependencies.
 | 
			
		||||
    set(${target}_static_primary static)
 | 
			
		||||
    # If a dependency doesn't exist as static library, we link against the
 | 
			
		||||
    # shared one.
 | 
			
		||||
    set(${target}_static_secondary shared)
 | 
			
		||||
  endif()
 | 
			
		||||
  # If it's neither, then it's an executable.
 | 
			
		||||
  if(NOT _targets)
 | 
			
		||||
    set(_targets ${_targets} ${target})
 | 
			
		||||
    # Executables preferably link against static libraries, so they are
 | 
			
		||||
    # standalone and can be shipped without any external dependencies. As a
 | 
			
		||||
    # frame of reference: tests become roughly 600-800K binaries instead of
 | 
			
		||||
    # 50-100K on x86_64 Linux.
 | 
			
		||||
    set(${target}_primary static)
 | 
			
		||||
    set(${target}_secondary shared)
 | 
			
		||||
  endif()
 | 
			
		||||
 | 
			
		||||
  foreach(dep ${ARGN})
 | 
			
		||||
    foreach(_target ${_targets})
 | 
			
		||||
      if(TARGET ${dep}_${${_target}_primary})
 | 
			
		||||
        target_link_libraries(${_target} ${dep}_${${_target}_primary})
 | 
			
		||||
      elseif(TARGET ${dep}_${${_target}_secondary})
 | 
			
		||||
        target_link_libraries(${_target} ${dep}_${${_target}_secondary})
 | 
			
		||||
      else()
 | 
			
		||||
        # We record the modules linked to this target, so that we can collect
 | 
			
		||||
        # them later when linking a composed module.
 | 
			
		||||
        list(FIND LINK_MODULES ${dep} _index)
 | 
			
		||||
        if(_index EQUAL -1)
 | 
			
		||||
          set(LINK_MODULES ${LINK_MODULES} ${dep})
 | 
			
		||||
        endif()
 | 
			
		||||
 | 
			
		||||
        target_link_libraries(${_target} ${dep})
 | 
			
		||||
      endif()
 | 
			
		||||
    endforeach()
 | 
			
		||||
  endforeach()
 | 
			
		||||
 | 
			
		||||
  set(${target}_LINK_MODULES ${${target}_LINK_MODULES} ${LINK_MODULES} PARENT_SCOPE)
 | 
			
		||||
endfunction()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										130
									
								
								external/toxcore/c-toxcore/configure.ac
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										130
									
								
								external/toxcore/c-toxcore/configure.ac
									
									
									
									
										vendored
									
									
								
							@@ -22,8 +22,6 @@ BUILD_AV="yes"
 | 
			
		||||
BUILD_TESTING="yes"
 | 
			
		||||
 | 
			
		||||
LIBCONFIG_FOUND="no"
 | 
			
		||||
WANT_NACL="no"
 | 
			
		||||
ADD_NACL_OBJECTS_TO_PKGCONFIG="yes"
 | 
			
		||||
SET_SO_VERSION="yes"
 | 
			
		||||
 | 
			
		||||
AC_ARG_ENABLE([soname-versions],
 | 
			
		||||
@@ -38,26 +36,11 @@ AC_ARG_ENABLE([soname-versions],
 | 
			
		||||
)
 | 
			
		||||
AM_CONDITIONAL(SET_SO_VERSION, test "x$SET_SO_VERSION" = "xyes")
 | 
			
		||||
 | 
			
		||||
AC_ARG_ENABLE([nacl],
 | 
			
		||||
    [AC_HELP_STRING([--enable-nacl], [use nacl instead of libsodium (default: disabled)]) ],
 | 
			
		||||
    [
 | 
			
		||||
        if test "x$enableval" = "xno"; then
 | 
			
		||||
            WANT_NACL="no"
 | 
			
		||||
        elif test "x$enableval" = "xyes"; then
 | 
			
		||||
            WANT_NACL="yes"
 | 
			
		||||
        fi
 | 
			
		||||
    ]
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
AC_ARG_ENABLE([randombytes-stir],
 | 
			
		||||
    [AC_HELP_STRING([--enable-randombytes-stir], [use randombytes_stir() instead of sodium_init() for faster startup on android (default: disabled)]) ],
 | 
			
		||||
    [
 | 
			
		||||
        if test "x$enableval" = "xyes"; then
 | 
			
		||||
            if test "x$WANT_NACL" = "xyes"; then
 | 
			
		||||
                AC_MSG_WARN([randombytes_stir() is not available with NaCl library])
 | 
			
		||||
            else
 | 
			
		||||
                AC_DEFINE([USE_RANDOMBYTES_STIR], [1], [randombytes_stir() instead of sodium_init()])
 | 
			
		||||
            fi
 | 
			
		||||
            AC_DEFINE([USE_RANDOMBYTES_STIR], [1], [randombytes_stir() instead of sodium_init()])
 | 
			
		||||
        fi
 | 
			
		||||
    ]
 | 
			
		||||
)
 | 
			
		||||
@@ -171,16 +154,6 @@ if test "$use_ipv6" != "yes"; then
 | 
			
		||||
  AC_DEFINE([USE_IPV6],[0],[define to 0 to force ipv4])
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
AC_ARG_ENABLE([[test_network]],
 | 
			
		||||
  [AS_HELP_STRING([[--enable-test-network[=ARG]]], [build tox for a test network incompatible with the main DHT [no]])],
 | 
			
		||||
    [use_test_network=${enableval}],
 | 
			
		||||
    [use_test_network='no']
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
if test "$use_test_network" == "yes"; then
 | 
			
		||||
  AC_DEFINE([USE_TEST_NETWORK],[1],[define to 1 to enable the test network])
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
AX_HAVE_EPOLL
 | 
			
		||||
if test "$enable_epoll" != "no"; then
 | 
			
		||||
  if test "${ax_cv_have_epoll}" = "yes"; then
 | 
			
		||||
@@ -197,8 +170,6 @@ fi
 | 
			
		||||
DEPSEARCH=
 | 
			
		||||
LIBSODIUM_SEARCH_HEADERS=
 | 
			
		||||
LIBSODIUM_SEARCH_LIBS=
 | 
			
		||||
NACL_SEARCH_HEADERS=
 | 
			
		||||
NACL_SEARCH_LIBS=
 | 
			
		||||
 | 
			
		||||
AC_ARG_WITH(dependency-search,
 | 
			
		||||
    AC_HELP_STRING([--with-dependency-search=DIR],
 | 
			
		||||
@@ -216,24 +187,6 @@ if test -n "$DEPSEARCH"; then
 | 
			
		||||
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSEARCH/lib/pkgconfig
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
AC_ARG_WITH(nacl-headers,
 | 
			
		||||
        AC_HELP_STRING([--with-nacl-headers=DIR],
 | 
			
		||||
                       [search for nacl<F2> header files in DIR]),
 | 
			
		||||
        [
 | 
			
		||||
            NACL_SEARCH_HEADERS="$withval"
 | 
			
		||||
            AC_MSG_NOTICE([will search for nacl header files in $withval])
 | 
			
		||||
        ]
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
AC_ARG_WITH(nacl-libs,
 | 
			
		||||
        AC_HELP_STRING([--with-nacl-libs=DIR],
 | 
			
		||||
                       [search for nacl libraries in DIR]),
 | 
			
		||||
        [
 | 
			
		||||
            NACL_SEARCH_LIBS="$withval"
 | 
			
		||||
            AC_MSG_NOTICE([will search for nacl libraries in $withval])
 | 
			
		||||
        ]
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
AC_ARG_WITH(libsodium-headers,
 | 
			
		||||
        AC_HELP_STRING([--with-libsodium-headers=DIR],
 | 
			
		||||
                       [search for libsodium header files in DIR]),
 | 
			
		||||
@@ -252,11 +205,6 @@ AC_ARG_WITH(libsodium-libs,
 | 
			
		||||
        ]
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if test "x$WANT_NACL" = "xyes"; then
 | 
			
		||||
    enable_shared=no
 | 
			
		||||
    enable_static=yes
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Checks for programs.
 | 
			
		||||
AC_PROG_CC_C99
 | 
			
		||||
 | 
			
		||||
@@ -287,7 +235,6 @@ case $host_os in
 | 
			
		||||
        LDFLAGS="$LDFLAGS -L/usr/local/lib"
 | 
			
		||||
        CFLAGS="$CFLAGS -I/usr/local/include"
 | 
			
		||||
        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
 | 
			
		||||
        ADD_NACL_OBJECTS_TO_PKGCONFIG="no"
 | 
			
		||||
    ;;
 | 
			
		||||
    darwin*)
 | 
			
		||||
        MACH=yes
 | 
			
		||||
@@ -312,50 +259,7 @@ PKG_CHECK_MODULES([LIBSODIUM], [libsodium],
 | 
			
		||||
        LIBSODIUM_FOUND="no"
 | 
			
		||||
    ])
 | 
			
		||||
 | 
			
		||||
if test "x$WANT_NACL" = "xyes"; then
 | 
			
		||||
    NACL_LIBS=
 | 
			
		||||
    NACL_LDFLAGS=
 | 
			
		||||
    NACL_OBJECTS=
 | 
			
		||||
    NACL_OBJECTS_PKGCONFIG=
 | 
			
		||||
    LDFLAGS_SAVE="$LDFLAGS"
 | 
			
		||||
    if test -n "$NACL_SEARCH_LIBS"; then
 | 
			
		||||
        LDFLAGS="-L$NACL_SEARCH_LIBS $LDFLAGS"
 | 
			
		||||
        AC_CHECK_LIB(nacl, random,
 | 
			
		||||
            [
 | 
			
		||||
                NACL_LDFLAGS="-L$NACL_SEARCH_LIBS"
 | 
			
		||||
                NACL_LIBS="-lnacl"
 | 
			
		||||
            ],
 | 
			
		||||
            [
 | 
			
		||||
                AC_MSG_ERROR([library nacl was not found in requested location $NACL_SEARCH_LIBS])
 | 
			
		||||
            ]
 | 
			
		||||
        )
 | 
			
		||||
    else
 | 
			
		||||
        AC_CHECK_LIB(nacl, random,
 | 
			
		||||
            [],
 | 
			
		||||
            [
 | 
			
		||||
                AC_MSG_ERROR([you enabled nacl support, but library nacl was not found on your system])
 | 
			
		||||
            ]
 | 
			
		||||
        )
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    if (test -f "$NACL_SEARCH_LIBS/cpucycles.o") &&
 | 
			
		||||
       (test -f "$NACL_SEARCH_LIBS/randombytes.o"); then
 | 
			
		||||
        NACL_OBJECTS="$NACL_SEARCH_LIBS/cpucycles.o $NACL_SEARCH_LIBS/randombytes.o"
 | 
			
		||||
        AC_MSG_NOTICE([found extra NaCl objects: $NACL_OBJECTS])
 | 
			
		||||
        if test "x$ADD_NACL_OBJECTS_TO_PKGCONFIG" = "xyes"; then
 | 
			
		||||
            AC_MSG_NOTICE([adding extra NaCl objects to pkg-config file])
 | 
			
		||||
            NACL_OBJECTS_PKGCONFIG="$NACL_OBJECTS"
 | 
			
		||||
        fi
 | 
			
		||||
    else
 | 
			
		||||
        AC_MSG_ERROR([required NaCl object files cpucycles.o randombytes.o not found, please specify their location using the --with-nacl-libs parameter])
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    LDFLAGS="$LDFLAGS_SAVE"
 | 
			
		||||
    AC_SUBST(NACL_LIBS)
 | 
			
		||||
    AC_SUBST(NACL_LDFLAGS)
 | 
			
		||||
    AC_SUBST(NACL_OBJECTS)
 | 
			
		||||
    AC_SUBST(NACL_OBJECTS_PKGCONFIG)
 | 
			
		||||
elif test "x$LIBSODIUM_FOUND" = "xno"; then
 | 
			
		||||
if test "x$LIBSODIUM_FOUND" = "xno"; then
 | 
			
		||||
    LIBSODIUM_LIBS=
 | 
			
		||||
    LIBSODIUM_LDFLAGS=
 | 
			
		||||
    LDFLAGS_SAVE="$LDFLAGS"
 | 
			
		||||
@@ -388,34 +292,7 @@ fi
 | 
			
		||||
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if test "x$WANT_NACL" = "xyes"; then
 | 
			
		||||
    NACL_CFLAGS=
 | 
			
		||||
    CFLAGS_SAVE="$CFLAGS"
 | 
			
		||||
    CPPFLAGS_SAVE="$CPPFLAGS"
 | 
			
		||||
    if test -n "$NACL_SEARCH_HEADERS"; then
 | 
			
		||||
        CFLAGS="-I$NACL_SEARCH_HEADERS $CFLAGS"
 | 
			
		||||
        CPPFLAGS="-I$NACL_SEARCH_HEADERS $CPPFLAGS"
 | 
			
		||||
        AC_CHECK_HEADER(crypto_box.h,
 | 
			
		||||
            [
 | 
			
		||||
                NACL_CFLAGS="-I$NACL_SEARCH_HEADERS"
 | 
			
		||||
            ],
 | 
			
		||||
            [
 | 
			
		||||
                AC_MSG_ERROR([header files for library nacl were not found in requested location $NACL_SEARCH_HEADERS])
 | 
			
		||||
            ]
 | 
			
		||||
        )
 | 
			
		||||
    else
 | 
			
		||||
        AC_CHECK_HEADER(crypto_box.h,
 | 
			
		||||
            [],
 | 
			
		||||
            [
 | 
			
		||||
                AC_MSG_ERROR([you enabled nacl support, but nacl header files were not found on your system])
 | 
			
		||||
            ]
 | 
			
		||||
        )
 | 
			
		||||
    fi
 | 
			
		||||
    CFLAGS="$CFLAGS_SAVE"
 | 
			
		||||
    CPPFLAGS="$CPPFLAGS_SAVE"
 | 
			
		||||
    AC_SUBST(NACL_CFLAGS)
 | 
			
		||||
    AC_DEFINE([VANILLA_NACL], [1], [use nacl instead of libsodium])
 | 
			
		||||
elif test "x$LIBSODIUM_FOUND" = "xno"; then
 | 
			
		||||
if test "x$LIBSODIUM_FOUND" = "xno"; then
 | 
			
		||||
    LIBSODIUM_CFLAGS=
 | 
			
		||||
    CFLAGS_SAVE="$CFLAGS"
 | 
			
		||||
    CPPFLAGS_SAVE="$CPPFLAGS"
 | 
			
		||||
@@ -555,7 +432,6 @@ AM_CONDITIONAL(BUILD_DHT_BOOTSTRAP, test "x$BUILD_DHT_BOOTSTRAP" = "xyes")
 | 
			
		||||
AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = "xyes")
 | 
			
		||||
AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
 | 
			
		||||
AM_CONDITIONAL(BUILD_TESTING, test "x$BUILD_TESTING" = "xyes")
 | 
			
		||||
AM_CONDITIONAL(WITH_NACL, test "x$WANT_NACL" = "xyes")
 | 
			
		||||
AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
 | 
			
		||||
 | 
			
		||||
AC_CONFIG_FILES([Makefile
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										106
									
								
								external/toxcore/c-toxcore/docs/TCP_Network.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										106
									
								
								external/toxcore/c-toxcore/docs/TCP_Network.txt
									
									
									
									
										vendored
									
									
								
							@@ -1,100 +1,100 @@
 | 
			
		||||
It has come to our attention that to achieve decent market penetration Tox 
 | 
			
		||||
must work behind ALL internet connections, may they be behind enterprise NATs 
 | 
			
		||||
or any other bad network conditions. 
 | 
			
		||||
It has come to our attention that to achieve decent market penetration Tox
 | 
			
		||||
must work behind ALL internet connections, may they be behind enterprise NATs
 | 
			
		||||
or any other bad network conditions.
 | 
			
		||||
 | 
			
		||||
The people who have issues with the UDP direct connection approach seem to be a 
 | 
			
		||||
The people who have issues with the UDP direct connection approach seem to be a
 | 
			
		||||
small minority though it is hard to estimate how many.
 | 
			
		||||
 | 
			
		||||
This means that routing their packets using good nodes on the network will 
 | 
			
		||||
This means that routing their packets using good nodes on the network will
 | 
			
		||||
probably not take a huge toll on the network and will assure that people
 | 
			
		||||
can use Tox regardless of the quality of their internet connection.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
How it's going to work:
 | 
			
		||||
1. Alice, a Tox client on a TCP only network generates a temporary public key 
 | 
			
		||||
1. Alice, a Tox client on a TCP only network generates a temporary public key
 | 
			
		||||
and connects to a bootstrap node.
 | 
			
		||||
 | 
			
		||||
2. Using the bootstrap node she finds and connects to a couple (exact number 
 | 
			
		||||
2. Using the bootstrap node she finds and connects to a couple (exact number
 | 
			
		||||
to be determined later) number of random nodes that have TCP relay support.
 | 
			
		||||
 | 
			
		||||
3. She uses the onion through the TCP relay connections to send friend requests 
 | 
			
		||||
or tell online friends which TCP nodes she is connected to and her temporary 
 | 
			
		||||
3. She uses the onion through the TCP relay connections to send friend requests
 | 
			
		||||
or tell online friends which TCP nodes she is connected to and her temporary
 | 
			
		||||
public key.
 | 
			
		||||
 | 
			
		||||
4. Bob receives an onion packet from Alice telling him which nodes she is 
 | 
			
		||||
connected to. Bob connects to these nodes and establishes a routed connection 
 | 
			
		||||
4. Bob receives an onion packet from Alice telling him which nodes she is
 | 
			
		||||
connected to. Bob connects to these nodes and establishes a routed connection
 | 
			
		||||
with Alice using that temporary public key.
 | 
			
		||||
 | 
			
		||||
5. That connection is used by both to transmit encrypted Messenger and A/V 
 | 
			
		||||
5. That connection is used by both to transmit encrypted Messenger and A/V
 | 
			
		||||
packets.
 | 
			
		||||
 | 
			
		||||
6. If one of the nodes shuts down while it is currently routing traffic, Alice 
 | 
			
		||||
6. If one of the nodes shuts down while it is currently routing traffic, Alice
 | 
			
		||||
and bob just switch to one of the other nodes they are both connected to.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Detailed implementation details:
 | 
			
		||||
 | 
			
		||||
There are two distinct parts for TCP relays, the client part and the server 
 | 
			
		||||
There are two distinct parts for TCP relays, the client part and the server
 | 
			
		||||
part.
 | 
			
		||||
 | 
			
		||||
The server acts as the actual relay. Servers must have fully forwarded TCP 
 | 
			
		||||
ports (NAT-PMP and uPNP can help here). The first port the server will try 
 | 
			
		||||
binding to is 443 followed by port 3389 and possibly some others. Onion packets 
 | 
			
		||||
The server acts as the actual relay. Servers must have fully forwarded TCP
 | 
			
		||||
ports (NAT-PMP and uPNP can help here). The first port the server will try
 | 
			
		||||
binding to is 443 followed by port 3389 and possibly some others. Onion packets
 | 
			
		||||
can be sent/received through the TCP servers.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Server:
 | 
			
		||||
 | 
			
		||||
The public/private key pair the TCP server uses is the same one he uses for the 
 | 
			
		||||
DHT. 
 | 
			
		||||
The public/private key pair the TCP server uses is the same one he uses for the
 | 
			
		||||
DHT.
 | 
			
		||||
 | 
			
		||||
all crypto for communication with the server uses the crypto_box() function of 
 | 
			
		||||
NaCl.
 | 
			
		||||
all crypto for communication with the server uses the crypto_box() function of
 | 
			
		||||
libsodium.
 | 
			
		||||
 | 
			
		||||
TCP doesn't have packets so what we will refer to as packets are sent this way: 
 | 
			
		||||
TCP doesn't have packets so what we will refer to as packets are sent this way:
 | 
			
		||||
[[uint16_t (length of data)][data]]
 | 
			
		||||
 | 
			
		||||
So if you would inspect the TCP stream you would see:
 | 
			
		||||
[[uint16_t (length of data)][data]][[uint16_t (length of 
 | 
			
		||||
[[uint16_t (length of data)][data]][[uint16_t (length of
 | 
			
		||||
data)][data]][[uint16_t (length of data)][data]]
 | 
			
		||||
 | 
			
		||||
Note that both handshake packets don't have this format (the length for them is 
 | 
			
		||||
Note that both handshake packets don't have this format (the length for them is
 | 
			
		||||
always the same so we don't need to specify it.)
 | 
			
		||||
 | 
			
		||||
When the client connects to the server, he sends this packet:
 | 
			
		||||
[public key of client (32 bytes)][nonce for the encrypted data [24 
 | 
			
		||||
bytes]][encrypted with the private key of the client and public key of the 
 | 
			
		||||
server and the nonce:[public key (32 bytes) and][base nonce we want the server 
 | 
			
		||||
[public key of client (32 bytes)][nonce for the encrypted data [24
 | 
			
		||||
bytes]][encrypted with the private key of the client and public key of the
 | 
			
		||||
server and the nonce:[public key (32 bytes) and][base nonce we want the server
 | 
			
		||||
to use to encrypt the packets sent to us (24 bytes)]]
 | 
			
		||||
 | 
			
		||||
The server responds with:
 | 
			
		||||
[nonce for the encrypted data [24 bytes]][encrypted with the public key of the 
 | 
			
		||||
client and private key of the server and the nonce:[public key (32 bytes) 
 | 
			
		||||
and][base nonce we want the client to use to encrypt the packets sent to us (24 
 | 
			
		||||
[nonce for the encrypted data [24 bytes]][encrypted with the public key of the
 | 
			
		||||
client and private key of the server and the nonce:[public key (32 bytes)
 | 
			
		||||
and][base nonce we want the client to use to encrypt the packets sent to us (24
 | 
			
		||||
bytes)]]
 | 
			
		||||
 | 
			
		||||
All packets to the server are end to end encrypted with the information 
 | 
			
		||||
received 
 | 
			
		||||
All packets to the server are end to end encrypted with the information
 | 
			
		||||
received
 | 
			
		||||
(and sent) in the handshake.
 | 
			
		||||
 | 
			
		||||
(first packet is encrypted with the base nonce the private key for which the 
 | 
			
		||||
client sent the server the public key and the public key we sent to the client, 
 | 
			
		||||
(first packet is encrypted with the base nonce the private key for which the
 | 
			
		||||
client sent the server the public key and the public key we sent to the client,
 | 
			
		||||
the next with base nonce + 1...)
 | 
			
		||||
 | 
			
		||||
The connection is set to an unconfirmed state until a packet is received and 
 | 
			
		||||
The connection is set to an unconfirmed state until a packet is received and
 | 
			
		||||
decrypted correctly using the information in the handshake.
 | 
			
		||||
 | 
			
		||||
each packet sent to/from the server has an id (the first byte of the plain text 
 | 
			
		||||
each packet sent to/from the server has an id (the first byte of the plain text
 | 
			
		||||
data of the packet.)
 | 
			
		||||
 | 
			
		||||
ids 0 to 15 are reserved for special packets, ids 16 to 255 are used to denote 
 | 
			
		||||
ids 0 to 15 are reserved for special packets, ids 16 to 255 are used to denote
 | 
			
		||||
who we want the data to be routed to/who the packet is from.
 | 
			
		||||
 | 
			
		||||
special ids and packets:
 | 
			
		||||
0 - Routing request.
 | 
			
		||||
[uint8_t id (0)][public key (32 bytes)]
 | 
			
		||||
1 - Routing request response.
 | 
			
		||||
[uint8_t id (1)][uint8_t (rpid) 0 if refused, packet id if accepted][public key 
 | 
			
		||||
[uint8_t id (1)][uint8_t (rpid) 0 if refused, packet id if accepted][public key
 | 
			
		||||
(32 bytes)]
 | 
			
		||||
2 - Connect notification:
 | 
			
		||||
[uint8_t id (2)][uint8_t (packet id of connection that got connected)]
 | 
			
		||||
@@ -108,44 +108,44 @@ special ids and packets:
 | 
			
		||||
[uint8_t id (6)][destination public key (32 bytes)][data]
 | 
			
		||||
7 - OOB recv
 | 
			
		||||
[uint8_t id (7)][senders public key (32 bytes)][data]
 | 
			
		||||
8 - onion packet (same format as initial onion packet (See: Prevent 
 | 
			
		||||
8 - onion packet (same format as initial onion packet (See: Prevent
 | 
			
		||||
tracking.txt) but packet id is 8 instead of 128)
 | 
			
		||||
9 - onion packet response (same format as onion packet with id 142 but id is 9 
 | 
			
		||||
9 - onion packet response (same format as onion packet with id 142 but id is 9
 | 
			
		||||
instead.)
 | 
			
		||||
 | 
			
		||||
The rest of the special ids are reserved for possible future usage.
 | 
			
		||||
 | 
			
		||||
If the server receives a routing request he stores server side that the client 
 | 
			
		||||
wants to connect to the person with that public key and sends back a Routing 
 | 
			
		||||
If the server receives a routing request he stores server side that the client
 | 
			
		||||
wants to connect to the person with that public key and sends back a Routing
 | 
			
		||||
request response with the rpid along with the public key sent in the request.
 | 
			
		||||
 | 
			
		||||
If for some reason the server must refuse the routing request (too many) he 
 | 
			
		||||
If for some reason the server must refuse the routing request (too many) he
 | 
			
		||||
sends the response with a rpid of 0.
 | 
			
		||||
 | 
			
		||||
If the person who the client wants to connect to is also online and wants to 
 | 
			
		||||
connect to the client a connect notification is sent to both with the 
 | 
			
		||||
If the person who the client wants to connect to is also online and wants to
 | 
			
		||||
connect to the client a connect notification is sent to both with the
 | 
			
		||||
appropriate packet id.
 | 
			
		||||
 | 
			
		||||
If either one disconnects, a disconnect notification is sent to the other with 
 | 
			
		||||
If either one disconnects, a disconnect notification is sent to the other with
 | 
			
		||||
appropriate packet id.
 | 
			
		||||
 | 
			
		||||
If a client sends a disconnect notification, the entry on the server for that 
 | 
			
		||||
routed connection is cleared and a disconnect notification is sent to the peer 
 | 
			
		||||
If a client sends a disconnect notification, the entry on the server for that
 | 
			
		||||
routed connection is cleared and a disconnect notification is sent to the peer
 | 
			
		||||
(if he was online)
 | 
			
		||||
 | 
			
		||||
If the server receives an onion packet he handles it the same as he would if it 
 | 
			
		||||
was one received normally via UDP, he must also assure himself that any 
 | 
			
		||||
If the server receives an onion packet he handles it the same as he would if it
 | 
			
		||||
was one received normally via UDP, he must also assure himself that any
 | 
			
		||||
responses must be sent to the proper client.
 | 
			
		||||
 | 
			
		||||
Ping responses must have the same ping_id as the request.
 | 
			
		||||
 | 
			
		||||
If the server receives a ping packet he must respond with a ping response.
 | 
			
		||||
 | 
			
		||||
The server will send a ping packet to clients every 30 seconds, they have 30 
 | 
			
		||||
The server will send a ping packet to clients every 30 seconds, they have 30
 | 
			
		||||
seconds to respond, if they don't the connection is deleted.
 | 
			
		||||
 | 
			
		||||
OOB send packets will be sent to the peer connected to the TCP server with the 
 | 
			
		||||
destination public key as a OOB recv packet. The client sending this packet has 
 | 
			
		||||
OOB send packets will be sent to the peer connected to the TCP server with the
 | 
			
		||||
destination public key as a OOB recv packet. The client sending this packet has
 | 
			
		||||
no way of knowing if the packet reached its destination.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
Encryption library used: http://nacl.cr.yp.to/
 | 
			
		||||
Encryption library used: https://doc.libsodium.org/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
When running the program for the first time the crypto_box_keypair() function is used to 
 | 
			
		||||
When running the program for the first time the crypto_box_keypair() function is used to
 | 
			
		||||
generate the users public-private key pair. (32 bytes each)
 | 
			
		||||
 | 
			
		||||
The generated public key is set as the client_id of the peer.
 | 
			
		||||
@@ -9,13 +9,13 @@ The generated public key is set as the client_id of the peer.
 | 
			
		||||
Adding a friend
 | 
			
		||||
---------------
 | 
			
		||||
 | 
			
		||||
Alice adds Bob to her friend list by adding his 32 byte public key (client_id) to her friend list.  
 | 
			
		||||
2 cases:  
 | 
			
		||||
case 1: Alice adds the public key of Bob, then Bob waits for Alice to attempt to connect to him.  
 | 
			
		||||
case 2: Bob and Alice add their respective public keys to their friend lists at the same time.  
 | 
			
		||||
    
 | 
			
		||||
case 1:  
 | 
			
		||||
Alice sends an onion data (see: Prevent_tracking.txt) packet to Bob with the encrypted part containing the friend request like so:  
 | 
			
		||||
Alice adds Bob to her friend list by adding his 32 byte public key (client_id) to her friend list.
 | 
			
		||||
2 cases:
 | 
			
		||||
case 1: Alice adds the public key of Bob, then Bob waits for Alice to attempt to connect to him.
 | 
			
		||||
case 2: Bob and Alice add their respective public keys to their friend lists at the same time.
 | 
			
		||||
 | 
			
		||||
case 1:
 | 
			
		||||
Alice sends an onion data (see: Prevent_tracking.txt) packet to Bob with the encrypted part containing the friend request like so:
 | 
			
		||||
```
 | 
			
		||||
[char with a value of 32][nospam number (4 bytes)][Message]
 | 
			
		||||
```
 | 
			
		||||
@@ -23,15 +23,15 @@ Alice sends an onion data (see: Prevent_tracking.txt) packet to Bob with the enc
 | 
			
		||||
Ex message: hello Bob it's me Alice -_- add me pl0x.
 | 
			
		||||
 | 
			
		||||
For more info on the nospam see: Spam_Prevention.txt
 | 
			
		||||
        
 | 
			
		||||
Bob receives the request and decrypts the message using the function crypto_box_open()
 | 
			
		||||
        
 | 
			
		||||
If the message decrypts successfully:   
 | 
			
		||||
If Alice is already in Bob's friend list: case 2  
 | 
			
		||||
If Alice is not in Bob's friend list and the nospam is good: Bob is prompt to add Alice and is shown the message from her.  
 | 
			
		||||
If Bob accepts Alice friend request he adds her public key to his friend list.  
 | 
			
		||||
 | 
			
		||||
case 2:  
 | 
			
		||||
Bob receives the request and decrypts the message using the function crypto_box_open()
 | 
			
		||||
 | 
			
		||||
If the message decrypts successfully:
 | 
			
		||||
If Alice is already in Bob's friend list: case 2
 | 
			
		||||
If Alice is not in Bob's friend list and the nospam is good: Bob is prompt to add Alice and is shown the message from her.
 | 
			
		||||
If Bob accepts Alice friend request he adds her public key to his friend list.
 | 
			
		||||
 | 
			
		||||
case 2:
 | 
			
		||||
Bob and Alice both have the others public key in their friend list, they are ready for the next step:   Connecting to an already added friend
 | 
			
		||||
 | 
			
		||||
In the next step only crypto_box() is used for encryption and only crypto_box_open() for decryption (just like in the last step.)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								external/toxcore/c-toxcore/libtoxcore.pc.in
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/toxcore/c-toxcore/libtoxcore.pc.in
									
									
									
									
										vendored
									
									
								
							@@ -7,5 +7,5 @@ Name: libtoxcore
 | 
			
		||||
Description: Tox protocol library
 | 
			
		||||
Requires:
 | 
			
		||||
Version: @PACKAGE_VERSION@
 | 
			
		||||
Libs: @NACL_OBJECTS_PKGCONFIG@ -L${libdir} -ltoxcore @NACL_LDFLAGS@ -ltoxencryptsave @NACL_LIBS@ @LIBS@ @MATH_LDFLAGS@ @PTHREAD_LDFLAGS@
 | 
			
		||||
Libs: -L${libdir} -ltoxcore -ltoxencryptsave @LIBS@ @MATH_LDFLAGS@ @PTHREAD_LDFLAGS@
 | 
			
		||||
Cflags: -I${includedir}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,16 +9,12 @@ DHT_bootstrap_SOURCES = ../other/DHT_bootstrap.c \
 | 
			
		||||
                        ../other/bootstrap_node_packets.c
 | 
			
		||||
 | 
			
		||||
DHT_bootstrap_CFLAGS = -I$(top_srcdir)/other \
 | 
			
		||||
                        $(LIBSODIUM_CFLAGS) \
 | 
			
		||||
                        $(NACL_CFLAGS)
 | 
			
		||||
                        $(LIBSODIUM_CFLAGS)
 | 
			
		||||
 | 
			
		||||
DHT_bootstrap_LDADD =   $(LIBSODIUM_LDFLAGS) \
 | 
			
		||||
                        $(NACL_LDFLAGS) \
 | 
			
		||||
                        libmisc_tools.la \
 | 
			
		||||
                        libtoxcore.la \
 | 
			
		||||
                        $(LIBSODIUM_LIBS) \
 | 
			
		||||
                        $(NACL_OBJECTS) \
 | 
			
		||||
                        $(NACL_LIBS) \
 | 
			
		||||
                        $(WINSOCK2_LIBS)
 | 
			
		||||
 | 
			
		||||
endif
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,12 @@ set -e
 | 
			
		||||
 | 
			
		||||
CPPCHECK=("--enable=all")
 | 
			
		||||
CPPCHECK+=("--inconclusive")
 | 
			
		||||
CPPCHECK+=("--check-level=exhaustive")
 | 
			
		||||
CPPCHECK+=("--inline-suppr")
 | 
			
		||||
CPPCHECK+=("--library=other/docker/cppcheck/toxcore.cfg")
 | 
			
		||||
CPPCHECK+=("--error-exitcode=1")
 | 
			
		||||
# Used for VLA.
 | 
			
		||||
CPPCHECK+=("--suppress=allocaCalled")
 | 
			
		||||
# We don't cast function pointers, which cppcheck suggests here.
 | 
			
		||||
CPPCHECK+=("--suppress=constParameterCallback")
 | 
			
		||||
# False positives in switch statements.
 | 
			
		||||
CPPCHECK+=("--suppress=knownConditionTrueFalse")
 | 
			
		||||
# Cppcheck does not need standard library headers to get proper results.
 | 
			
		||||
@@ -19,27 +22,22 @@ CPPCHECK+=("--suppress=missingIncludeSystem")
 | 
			
		||||
CPPCHECK+=("--suppress=signConversion")
 | 
			
		||||
# TODO(iphydf): Fixed in the toxav refactor PR.
 | 
			
		||||
CPPCHECK+=("--suppress=redundantAssignment")
 | 
			
		||||
# We have some redundant nullptr checks in assertions
 | 
			
		||||
CPPCHECK+=("--suppress=nullPointerRedundantCheck")
 | 
			
		||||
# Triggers a false warning in group.c
 | 
			
		||||
CPPCHECK+=("--suppress=AssignmentAddressToInteger")
 | 
			
		||||
# TODO(sudden6): This triggers a false positive, check again later to enable it
 | 
			
		||||
CPPCHECK+=("--suppress=arrayIndexOutOfBoundsCond")
 | 
			
		||||
 | 
			
		||||
# We're a library. This only works on whole programs.
 | 
			
		||||
CPPCHECK_C=("--suppress=unusedFunction")
 | 
			
		||||
 | 
			
		||||
# We use this for VLAs.
 | 
			
		||||
CPPCHECK_CXX+=("--suppress=allocaCalled")
 | 
			
		||||
# False positive in auto_tests.
 | 
			
		||||
CPPCHECK_CXX+=("--suppress=shadowArgument")
 | 
			
		||||
CPPCHECK_CXX+=("--suppress=shadowFunction")
 | 
			
		||||
# False positive for callback functions
 | 
			
		||||
CPPCHECK_CXX+=("--suppress=constParameter")
 | 
			
		||||
# False positive in group.c.
 | 
			
		||||
# Using cppcheck-suppress claims the suppression is unused.
 | 
			
		||||
CPPCHECK_CXX+=("--suppress=AssignmentAddressToInteger")
 | 
			
		||||
# We use C style casts because we write C code.
 | 
			
		||||
CPPCHECK_CXX+=("--suppress=cstyleCast")
 | 
			
		||||
# Used in Messenger.c for a static_assert(...)
 | 
			
		||||
CPPCHECK_CXX+=("--suppress=sizeofFunctionCall")
 | 
			
		||||
 | 
			
		||||
run() {
 | 
			
		||||
  echo "Running cppcheck in variant '$*'"
 | 
			
		||||
  cppcheck "${CPPCHECK[@]}" "${CPPCHECK_C[@]}" tox*/*.[ch] tox*/*/*.[ch] "${CPPFLAGS[@]}" "$@"
 | 
			
		||||
  cppcheck -j8 "${CPPCHECK[@]}" "${CPPCHECK_C[@]}" tox*/*.[ch] tox*/*/*.[ch] "${CPPFLAGS[@]}" "$@"
 | 
			
		||||
  cppcheck "${CPPCHECK[@]}" "${CPPCHECK_CXX[@]}" amalgamation.cc "${CPPFLAGS[@]}" "$@"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,14 @@ add_executable(tox-bootstrapd
 | 
			
		||||
  src/tox-bootstrapd.c
 | 
			
		||||
  ../bootstrap_node_packets.c
 | 
			
		||||
  ../bootstrap_node_packets.h)
 | 
			
		||||
target_link_modules(tox-bootstrapd toxcore ${LIBCONFIG_LIBRARIES})
 | 
			
		||||
target_link_libraries(tox-bootstrapd PRIVATE ${LIBCONFIG_LIBRARIES})
 | 
			
		||||
target_link_directories(tox-bootstrapd PRIVATE ${LIBCONFIG_LIBRARY_DIRS})
 | 
			
		||||
target_include_directories(tox-bootstrapd SYSTEM PRIVATE ${LIBCONFIG_INCLUDE_DIRS})
 | 
			
		||||
target_compile_options(tox-bootstrapd PRIVATE ${LIBCONFIG_CFLAGS_OTHER})
 | 
			
		||||
if(TARGET toxcore_static)
 | 
			
		||||
  target_link_libraries(tox-bootstrapd PRIVATE toxcore_static)
 | 
			
		||||
else()
 | 
			
		||||
  target_link_libraries(tox-bootstrapd PRIVATE toxcore_shared)
 | 
			
		||||
endif()
 | 
			
		||||
install(TARGETS tox-bootstrapd RUNTIME DESTINATION bin)
 | 
			
		||||
install(FILES bash-completion/completions/tox-bootstrapd DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions")
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,16 @@
 | 
			
		||||
###########################################################
 | 
			
		||||
# Builder image: we compile the code here (static build)
 | 
			
		||||
FROM alpine:3.18.5 AS build
 | 
			
		||||
FROM alpine:3.19.0 AS build
 | 
			
		||||
 | 
			
		||||
RUN ["apk", "--no-cache", "add",\
 | 
			
		||||
 "build-base",\
 | 
			
		||||
 "clang",\
 | 
			
		||||
 "cmake",\
 | 
			
		||||
 "linux-headers",\
 | 
			
		||||
 "libconfig-dev",\
 | 
			
		||||
 "libconfig-static",\
 | 
			
		||||
 "libsodium-dev",\
 | 
			
		||||
 "libsodium-static",\
 | 
			
		||||
 "musl-dev",\
 | 
			
		||||
 "ninja",\
 | 
			
		||||
 "python3"\
 | 
			
		||||
]
 | 
			
		||||
@@ -34,9 +35,9 @@ COPY CMakeLists.txt so.version ./
 | 
			
		||||
COPY other/bootstrap_daemon/CMakeLists.txt other/bootstrap_daemon/CMakeLists.txt
 | 
			
		||||
COPY testing/CMakeLists.txt testing/CMakeLists.txt
 | 
			
		||||
 | 
			
		||||
RUN cmake -B_build -H. \
 | 
			
		||||
RUN CC=clang cmake -B_build -H. \
 | 
			
		||||
      -GNinja \
 | 
			
		||||
      -DCMAKE_C_FLAGS="-DTCP_SERVER_USE_EPOLL -fstack-protector-all -fisolate-erroneous-paths-attribute" \
 | 
			
		||||
      -DCMAKE_C_FLAGS="-DTCP_SERVER_USE_EPOLL -fsanitize=alignment,return,returns-nonnull-attribute,vla-bound,unreachable,float-cast-overflow,null -fsanitize-trap=all -fstack-protector-all" \
 | 
			
		||||
      -DCMAKE_UNITY_BUILD=ON \
 | 
			
		||||
      -DCMAKE_BUILD_TYPE=Release \
 | 
			
		||||
      -DFULLY_STATIC=ON \
 | 
			
		||||
 
 | 
			
		||||
@@ -1 +1 @@
 | 
			
		||||
5aac1df4d6c1de289e8e9f646d06099c84fd4d9b80d19f45e3254eec3ece2bff  /usr/local/bin/tox-bootstrapd
 | 
			
		||||
b0bd5099f2f77fbd540a5a929a23cece39ff95e3a66702a5381342d01775cbd3  /usr/local/bin/tox-bootstrapd
 | 
			
		||||
 
 | 
			
		||||
@@ -24,17 +24,13 @@ tox_bootstrapd_SOURCES = \
 | 
			
		||||
tox_bootstrapd_CFLAGS = \
 | 
			
		||||
                        -I$(top_srcdir)/other/bootstrap_daemon \
 | 
			
		||||
                        $(LIBSODIUM_CFLAGS) \
 | 
			
		||||
                        $(NACL_CFLAGS) \
 | 
			
		||||
                        $(LIBCONFIG_CFLAGS)
 | 
			
		||||
 | 
			
		||||
tox_bootstrapd_LDADD = \
 | 
			
		||||
                        $(LIBSODIUM_LDFLAGS) \
 | 
			
		||||
                        $(NACL_LDFLAGS) \
 | 
			
		||||
                        libtoxcore.la \
 | 
			
		||||
                        $(LIBCONFIG_LIBS) \
 | 
			
		||||
                        $(LIBSODIUM_LIBS) \
 | 
			
		||||
                        $(NACL_OBJECTS) \
 | 
			
		||||
                        $(NACL_LIBS)
 | 
			
		||||
                        $(LIBSODIUM_LIBS)
 | 
			
		||||
 | 
			
		||||
bashcompdir = $(datarootdir)/bash-completion/completions
 | 
			
		||||
dist_bashcomp_DATA = $(top_builddir)/other/bootstrap_daemon/bash-completion/completions/tox-bootstrapd
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,7 @@ static void sleep_milliseconds(uint32_t ms)
 | 
			
		||||
// returns 1 on success
 | 
			
		||||
//         0 on failure - no keys were read or stored
 | 
			
		||||
 | 
			
		||||
static int manage_keys(DHT *dht, char *keys_file_path)
 | 
			
		||||
static int manage_keys(DHT *dht, const char *keys_file_path)
 | 
			
		||||
{
 | 
			
		||||
    enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
 | 
			
		||||
    uint8_t keys[KEYS_SIZE];
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,27 @@
 | 
			
		||||
################################################
 | 
			
		||||
# autotools-linux
 | 
			
		||||
FROM toxchat/nacl:latest
 | 
			
		||||
FROM ubuntu:22.04
 | 
			
		||||
 | 
			
		||||
RUN apt-get update && apt-get install --no-install-recommends -y \
 | 
			
		||||
 autoconf \
 | 
			
		||||
 automake \
 | 
			
		||||
 ca-certificates \
 | 
			
		||||
 curl \
 | 
			
		||||
 libconfig-dev \
 | 
			
		||||
 libopus-dev \
 | 
			
		||||
 libsodium-dev \
 | 
			
		||||
 libtool \
 | 
			
		||||
 libvpx-dev \
 | 
			
		||||
 make \
 | 
			
		||||
 pkg-config \
 | 
			
		||||
 && apt-get clean \
 | 
			
		||||
 && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
RUN groupadd -r -g 1000 builder \
 | 
			
		||||
 && useradd -m --no-log-init -r -g builder -u 1000 builder
 | 
			
		||||
USER builder
 | 
			
		||||
 | 
			
		||||
WORKDIR /home/builder
 | 
			
		||||
 | 
			
		||||
# Copy the sources and run the build.
 | 
			
		||||
COPY --chown=builder:builder . /home/builder/c-toxcore/
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,15 @@
 | 
			
		||||
FROM toxchat/c-toxcore:sources AS src
 | 
			
		||||
FROM ubuntu:22.04 AS build
 | 
			
		||||
FROM ubuntu:20.04 AS build
 | 
			
		||||
 | 
			
		||||
RUN apt-get update && \
 | 
			
		||||
 DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
 | 
			
		||||
 ca-certificates \
 | 
			
		||||
 clang \
 | 
			
		||||
 cmake \
 | 
			
		||||
 curl \
 | 
			
		||||
 gcc \
 | 
			
		||||
 git \
 | 
			
		||||
 golang \
 | 
			
		||||
 golang-1.18 \
 | 
			
		||||
 libconfig-dev \
 | 
			
		||||
 libgtest-dev \
 | 
			
		||||
 libopus-dev \
 | 
			
		||||
@@ -22,10 +24,16 @@ RUN apt-get update && \
 | 
			
		||||
 && apt-get clean \
 | 
			
		||||
 && rm -rf /var/lib/apt/lists/* \
 | 
			
		||||
 && pip3 install --no-cache-dir gcovr
 | 
			
		||||
RUN ["strip", "-g",\
 | 
			
		||||
 "/usr/lib/x86_64-linux-gnu/libgtest.a",\
 | 
			
		||||
 "/usr/lib/x86_64-linux-gnu/libgtest_main.a"]
 | 
			
		||||
RUN ["curl", "-s", "https://codecov.io/bash", "-o", "/usr/local/bin/codecov"]
 | 
			
		||||
RUN ["chmod", "+x", "/usr/local/bin/codecov"]
 | 
			
		||||
 | 
			
		||||
ENV CC=clang \
 | 
			
		||||
    CXX=clang++ \
 | 
			
		||||
    PYTHONUNBUFFERED=1
 | 
			
		||||
    PYTHONUNBUFFERED=1 \
 | 
			
		||||
    PATH=$PATH:/usr/lib/go-1.18/bin
 | 
			
		||||
SHELL ["/bin/bash", "-c"]
 | 
			
		||||
 | 
			
		||||
WORKDIR /work
 | 
			
		||||
@@ -41,26 +49,27 @@ RUN source .github/scripts/flags-coverage.sh \
 | 
			
		||||
 -DENABLE_SHARED=OFF \
 | 
			
		||||
 -DMIN_LOGGER_LEVEL=TRACE \
 | 
			
		||||
 -DMUST_BUILD_TOXAV=ON \
 | 
			
		||||
 -DNON_HERMETIC_TESTS=ON \
 | 
			
		||||
 -DNON_HERMETIC_TESTS=OFF \
 | 
			
		||||
 -DSTRICT_ABI=ON \
 | 
			
		||||
 -DAUTOTEST=ON \
 | 
			
		||||
 -DPROXY_TEST=ON \
 | 
			
		||||
 -DUSE_IPV6=OFF \
 | 
			
		||||
 -DTEST_TIMEOUT_SECONDS=30 \
 | 
			
		||||
 -DTEST_TIMEOUT_SECONDS=40 \
 | 
			
		||||
 && cmake --build _build --parallel 8 --target install
 | 
			
		||||
 | 
			
		||||
WORKDIR /work/_build
 | 
			
		||||
RUN /work/proxy_server \
 | 
			
		||||
 & ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
 | 
			
		||||
RUN /work/other/proxy/proxy_server \
 | 
			
		||||
 & (ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 || \
 | 
			
		||||
    ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6)
 | 
			
		||||
 | 
			
		||||
WORKDIR /work/mallocfail
 | 
			
		||||
RUN ["git", "clone", "--depth=1", "https://github.com/ralight/mallocfail", "/work/mallocfail"]
 | 
			
		||||
COPY run_mallocfail /usr/local/bin/
 | 
			
		||||
COPY syscall_funcs.c src/
 | 
			
		||||
COPY other/docker/coverage/syscall_funcs.c src/
 | 
			
		||||
RUN gcc -fPIC -shared -O2 -g3 -Wall -Ideps/uthash -Ideps/sha3 deps/*/*.c src/*.c -o mallocfail.so -ldl -lbacktrace \
 | 
			
		||||
 && install mallocfail.so /usr/local/lib/mallocfail.so
 | 
			
		||||
 | 
			
		||||
WORKDIR /work/_build
 | 
			
		||||
COPY other/docker/coverage/run_mallocfail /usr/local/bin/
 | 
			
		||||
RUN ["run_mallocfail", "--ctest=2", "--jobs=8"]
 | 
			
		||||
RUN ["gcovr", \
 | 
			
		||||
 "--sort-percentage", \
 | 
			
		||||
@@ -74,6 +83,4 @@ RUN ["gcovr", \
 | 
			
		||||
 "--exclude=(.+/)?other/", \
 | 
			
		||||
 "--exclude=(.+/)?testing/"]
 | 
			
		||||
 | 
			
		||||
FROM nginx:alpine
 | 
			
		||||
COPY --from=build /work/_build/html/coverage_details.html /usr/share/nginx/html/index.html
 | 
			
		||||
COPY --from=build /work/_build/html/ /usr/share/nginx/html/
 | 
			
		||||
WORKDIR /work
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								external/toxcore/c-toxcore/other/docker/coverage/Dockerfile.nginx
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								external/toxcore/c-toxcore/other/docker/coverage/Dockerfile.nginx
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
# vim:ft=dockerfile
 | 
			
		||||
FROM toxchat/c-toxcore:coverage AS build
 | 
			
		||||
FROM nginx:alpine
 | 
			
		||||
COPY --from=build /work/_build/html/coverage_details.html /usr/share/nginx/html/index.html
 | 
			
		||||
COPY --from=build /work/_build/html/ /usr/share/nginx/html/
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
set -eux
 | 
			
		||||
 | 
			
		||||
read -a ci_env <<<"$(bash <(curl -s https://codecov.io/env))"
 | 
			
		||||
 | 
			
		||||
docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
 | 
			
		||||
docker build -t toxchat/c-toxcore:coverage other/docker/coverage
 | 
			
		||||
docker run --name toxcore-coverage --rm -it -p "28192:80" toxchat/c-toxcore:coverage
 | 
			
		||||
docker build -t toxchat/c-toxcore:coverage -f other/docker/coverage/Dockerfile .
 | 
			
		||||
docker run "${ci_env[@]}" -e CI=true --name toxcore-coverage --rm -t toxchat/c-toxcore:coverage /usr/local/bin/codecov -x "llvm-cov gcov"
 | 
			
		||||
 
 | 
			
		||||
@@ -39,8 +39,8 @@ _ENV = {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def run_mallocfail(tmpdir: str, timeout: float, exe: str,
 | 
			
		||||
                   iteration: int) -> bool:
 | 
			
		||||
def run_mallocfail(tmpdir: str, timeout: float, exe: str, iteration: int,
 | 
			
		||||
                   keep_going: bool) -> bool:
 | 
			
		||||
    """Run a program with mallocfail."""
 | 
			
		||||
    print(f"\x1b[1;33mmallocfail '{exe}' run #{iteration}\x1b[0m")
 | 
			
		||||
    hashes = os.path.join(tmpdir, _HASHES)
 | 
			
		||||
@@ -73,7 +73,8 @@ def run_mallocfail(tmpdir: str, timeout: float, exe: str,
 | 
			
		||||
        print(
 | 
			
		||||
            f"\x1b[1;32mProgram '{exe}' failed to handle OOM situation cleanly\x1b[0m"
 | 
			
		||||
        )
 | 
			
		||||
        raise Exception("Aborting test")
 | 
			
		||||
        if not keep_going:
 | 
			
		||||
            raise Exception("Aborting test")
 | 
			
		||||
 | 
			
		||||
    return True
 | 
			
		||||
 | 
			
		||||
@@ -95,7 +96,8 @@ def find_prog(name: str) -> Tuple[Optional[str], ...]:
 | 
			
		||||
            return path
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
    return (attempt(f"./unit_{name}_test"), attempt(f"./auto_{name}_test"))
 | 
			
		||||
    return (attempt(f"./unit_{name}_test"),
 | 
			
		||||
            attempt(f"auto_tests/auto_{name}_test"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
 | 
			
		||||
@@ -110,15 +112,19 @@ def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
 | 
			
		||||
    return flags, exes
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def loop_mallocfail(tmpdir: str, timeout: float, exe: str) -> None:
 | 
			
		||||
def loop_mallocfail(tmpdir: str,
 | 
			
		||||
                    timeout: float,
 | 
			
		||||
                    exe: str,
 | 
			
		||||
                    keep_going: bool = False) -> None:
 | 
			
		||||
    i = 1
 | 
			
		||||
    while run_mallocfail(tmpdir, timeout, exe, i):
 | 
			
		||||
    while run_mallocfail(tmpdir, timeout, exe, i, keep_going):
 | 
			
		||||
        i += 1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def isolated_mallocfail(timeout: int, exe: str) -> None:
 | 
			
		||||
    with tempfile.TemporaryDirectory(prefix="mallocfail") as tmpdir:
 | 
			
		||||
        print(f"\x1b[1;33mRunning for {exe} in isolated path {tmpdir}\x1b[0m")
 | 
			
		||||
        os.mkdir(os.path.join(tmpdir, "auto_tests"))
 | 
			
		||||
        shutil.copy(exe, os.path.join(tmpdir, exe))
 | 
			
		||||
        shutil.copy(_HASHES, os.path.join(tmpdir, _HASHES))
 | 
			
		||||
        loop_mallocfail(tmpdir, timeout, exe)
 | 
			
		||||
@@ -149,7 +155,7 @@ def main(args: List[str]) -> None:
 | 
			
		||||
    # such as llvm_gcov_init fail.
 | 
			
		||||
    if os.path.exists(_PRIMER):
 | 
			
		||||
        print(f"\x1b[1;33mPriming hashes with unit_util_test\x1b[0m")
 | 
			
		||||
        loop_mallocfail(".", timeout, _PRIMER)
 | 
			
		||||
        loop_mallocfail(".", timeout, _PRIMER, keep_going=True)
 | 
			
		||||
 | 
			
		||||
    print(f"\x1b[1;33m--------------------------------\x1b[0m")
 | 
			
		||||
    print(f"\x1b[1;33mStarting mallocfail for {len(exes)} programs:\x1b[0m")
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								external/toxcore/c-toxcore/other/docker/coverage/serve
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								external/toxcore/c-toxcore/other/docker/coverage/serve
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
set -eux
 | 
			
		||||
 | 
			
		||||
docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
 | 
			
		||||
docker build -t toxchat/c-toxcore:coverage -f other/docker/coverage/Dockerfile .
 | 
			
		||||
docker build -t toxchat/c-toxcore:coverage-nginx -f other/docker/coverage/Dockerfile.nginx other/docker/coverage
 | 
			
		||||
docker run --name toxcore-coverage --rm -it -p "28192:80" toxchat/c-toxcore:coverage-nginx
 | 
			
		||||
							
								
								
									
										30
									
								
								external/toxcore/c-toxcore/other/docker/cppcheck/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								external/toxcore/c-toxcore/other/docker/cppcheck/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
FROM alpine:3.19.0
 | 
			
		||||
 | 
			
		||||
RUN ["apk", "add", "--no-cache", \
 | 
			
		||||
 "bash", \
 | 
			
		||||
 "cppcheck", \
 | 
			
		||||
 "findutils", \
 | 
			
		||||
 "libconfig-dev", \
 | 
			
		||||
 "libsodium-dev", \
 | 
			
		||||
 "libvpx-dev", \
 | 
			
		||||
 "linux-headers", \
 | 
			
		||||
 "make", \
 | 
			
		||||
 "opus-dev"]
 | 
			
		||||
 | 
			
		||||
COPY other/bootstrap_daemon/ /src/workspace/c-toxcore/other/bootstrap_daemon/
 | 
			
		||||
COPY other/bootstrap_node_packets.* /src/workspace/c-toxcore/other/
 | 
			
		||||
COPY other/fun/ /src/workspace/c-toxcore/other/fun/
 | 
			
		||||
COPY auto_tests/check_compat.h /src/workspace/c-toxcore/auto_tests/
 | 
			
		||||
COPY testing/ /src/workspace/c-toxcore/testing/
 | 
			
		||||
COPY toxav/ /src/workspace/c-toxcore/toxav/
 | 
			
		||||
COPY toxcore/ /src/workspace/c-toxcore/toxcore/
 | 
			
		||||
COPY toxencryptsave/ /src/workspace/c-toxcore/toxencryptsave/
 | 
			
		||||
COPY third_party/cmp/cmp.h /src/workspace/c-toxcore/third_party/cmp/
 | 
			
		||||
COPY other/analysis/run-cppcheck \
 | 
			
		||||
     other/analysis/gen-file.sh \
 | 
			
		||||
     other/analysis/variants.sh \
 | 
			
		||||
     /src/workspace/c-toxcore/other/analysis/
 | 
			
		||||
COPY other/docker/cppcheck/toxcore.cfg \
 | 
			
		||||
     /src/workspace/c-toxcore/other/docker/cppcheck/
 | 
			
		||||
WORKDIR /src/workspace/c-toxcore
 | 
			
		||||
RUN ["other/analysis/run-cppcheck"]
 | 
			
		||||
							
								
								
									
										5
									
								
								external/toxcore/c-toxcore/other/docker/cppcheck/run
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										5
									
								
								external/toxcore/c-toxcore/other/docker/cppcheck/run
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
set -eux
 | 
			
		||||
BUILD=cppcheck
 | 
			
		||||
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
 | 
			
		||||
							
								
								
									
										117
									
								
								external/toxcore/c-toxcore/other/docker/cppcheck/toxcore.cfg
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								external/toxcore/c-toxcore/other/docker/cppcheck/toxcore.cfg
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,117 @@
 | 
			
		||||
<?xml version="1.0"?>
 | 
			
		||||
<def format="2">
 | 
			
		||||
  <memory>
 | 
			
		||||
    <alloc init="false" buffer-size="malloc:2">mem_balloc</alloc>
 | 
			
		||||
    <alloc init="true" buffer-size="malloc:2">mem_alloc</alloc>
 | 
			
		||||
    <alloc init="true" buffer-size="calloc:2,3">mem_valloc</alloc>
 | 
			
		||||
    <realloc init="false" buffer-size="calloc:3,4">mem_vrealloc</realloc>
 | 
			
		||||
    <dealloc arg="2">mem_delete</dealloc>
 | 
			
		||||
  </memory>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">bin_pack_new</alloc>
 | 
			
		||||
    <dealloc arg="1">bin_pack_free</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">bin_unpack_new</alloc>
 | 
			
		||||
    <dealloc arg="1">bin_unpack_free</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">friendreq_new</alloc>
 | 
			
		||||
    <dealloc arg="1">friendreq_kill</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">logger_new</alloc>
 | 
			
		||||
    <dealloc arg="1">logger_kill</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">mono_time_new</alloc>
 | 
			
		||||
    <dealloc arg="1">mono_time_free</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">ping_array_new</alloc>
 | 
			
		||||
    <dealloc arg="1">ping_array_kill</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">ping_new</alloc>
 | 
			
		||||
    <dealloc arg="1">ping_kill</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">shared_key_cache_new</alloc>
 | 
			
		||||
    <dealloc arg="1">shared_key_cache_free</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">tox_dispatch_new</alloc>
 | 
			
		||||
    <dealloc arg="1">tox_dispatch_free</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">tox_new</alloc>
 | 
			
		||||
    <dealloc arg="1">tox_kill</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">tox_options_new</alloc>
 | 
			
		||||
    <dealloc arg="1">tox_options_free</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_announcements</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_announcements</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_dht</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_dht</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_dht_groupchats</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_dht_groupchats</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_forwarding</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_forwarding</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_friend_connections</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_friend_connections</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_gca_list</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_gca_list</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_groupchats</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_groupchats</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_messenger</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_messenger</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_net_crypto</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_net_crypto</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_networking_ex</alloc>
 | 
			
		||||
    <alloc init="true">new_networking_no_udp</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_networking</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_onion</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_onion</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_onion_announce</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_onion_announce</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_onion_client</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_onion_client</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_tcp_connections</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_tcp_connections</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
  <resource>
 | 
			
		||||
    <alloc init="true">new_tcp_server</alloc>
 | 
			
		||||
    <dealloc arg="1">kill_tcp_server</dealloc>
 | 
			
		||||
  </resource>
 | 
			
		||||
</def>
 | 
			
		||||
<!-- vim:ft=xml
 | 
			
		||||
 -->
 | 
			
		||||
							
								
								
									
										15
									
								
								external/toxcore/c-toxcore/other/docker/esp32/BUILD.bazel
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								external/toxcore/c-toxcore/other/docker/esp32/BUILD.bazel
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
load("@rules_cc//cc:defs.bzl", "cc_binary")
 | 
			
		||||
 | 
			
		||||
cc_binary(
 | 
			
		||||
    name = "host_main",
 | 
			
		||||
    testonly = 1,
 | 
			
		||||
    srcs = [
 | 
			
		||||
        "host_main.cc",
 | 
			
		||||
        "main/tox_main.cc",
 | 
			
		||||
        "main/tox_main.h",
 | 
			
		||||
    ],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//c-toxcore/toxcore:tox",
 | 
			
		||||
        "//c-toxcore/toxcore:tox_events",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
@@ -1,48 +1,32 @@
 | 
			
		||||
FROM toxchat/c-toxcore:sources AS src
 | 
			
		||||
FROM ubuntu:18.04
 | 
			
		||||
FROM mluis/qemu-esp32:latest
 | 
			
		||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
 | 
			
		||||
ENV IDF_TARGET=esp32
 | 
			
		||||
 | 
			
		||||
RUN apt-get update && \
 | 
			
		||||
 DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
 | 
			
		||||
 bison \
 | 
			
		||||
 ccache \
 | 
			
		||||
 cmake \
 | 
			
		||||
 flex \
 | 
			
		||||
 git \
 | 
			
		||||
 gperf \
 | 
			
		||||
 libncurses-dev \
 | 
			
		||||
 ninja-build \
 | 
			
		||||
 python \
 | 
			
		||||
 python-cryptography \
 | 
			
		||||
 python-future \
 | 
			
		||||
 python-pip \
 | 
			
		||||
 python-pyparsing \
 | 
			
		||||
 python-serial \
 | 
			
		||||
 python-setuptools \
 | 
			
		||||
 wget \
 | 
			
		||||
 && apt-get clean \
 | 
			
		||||
 && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
WORKDIR /root/toxcore
 | 
			
		||||
 | 
			
		||||
ENV ESP32_TARBALL=xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0 \
 | 
			
		||||
    IDF_PATH="/root/esp/esp-idf" \
 | 
			
		||||
    PATH="/root/esp/esp-idf/tools:/root/esp/xtensa-esp32-elf/bin:$PATH"
 | 
			
		||||
WORKDIR /root/esp
 | 
			
		||||
RUN wget -q https://dl.espressif.com/dl/$ESP32_TARBALL.tar.gz \
 | 
			
		||||
 && tar zxf $ESP32_TARBALL.tar.gz \
 | 
			
		||||
 && rm -f $ESP32_TARBALL.tar.gz \
 | 
			
		||||
 && git clone -b v3.3 --recursive --depth=1 --shallow-submodules https://github.com/espressif/esp-idf
 | 
			
		||||
# Build an initial bootstrap hello world just to compile libsodium and other
 | 
			
		||||
# system level dependencies.
 | 
			
		||||
COPY other/docker/esp32/sdkconfig \
 | 
			
		||||
     other/docker/esp32/CMakeLists.txt \
 | 
			
		||||
     /root/toxcore/
 | 
			
		||||
COPY other/docker/esp32/bootstrap/ \
 | 
			
		||||
     /root/toxcore/main/
 | 
			
		||||
RUN . /root/esp/esp-idf/export.sh && idf.py build
 | 
			
		||||
 | 
			
		||||
# Build a hello world first, so the OS and libsodium etc. are compiled.
 | 
			
		||||
WORKDIR /root/esp/toxcore
 | 
			
		||||
COPY other/docker/esp32/CMakeLists.txt /root/esp/toxcore/
 | 
			
		||||
COPY other/docker/esp32/hello/ /root/esp/toxcore/main/
 | 
			
		||||
RUN idf.py build
 | 
			
		||||
 | 
			
		||||
# Then copy over the actual toxcore sources and build those.
 | 
			
		||||
COPY --from=src /src/third_party/cmp/ /root/esp/toxcore/main/third_party/cmp/
 | 
			
		||||
COPY --from=src /src/toxencryptsave/defines.h /root/esp/toxcore/main/toxencryptsave/
 | 
			
		||||
COPY --from=src /src/toxcore/ /root/esp/toxcore/main/toxcore/
 | 
			
		||||
COPY other/docker/esp32/toxcore/CMakeLists.txt /root/esp/toxcore/main/
 | 
			
		||||
COPY other/docker/esp32/toxcore/toxcore_main.cc /root/esp/toxcore/main/other/docker/esp32/main/
 | 
			
		||||
RUN idf.py build
 | 
			
		||||
# Copy over toxcore sources and build those.
 | 
			
		||||
COPY third_party/cmp/ /root/toxcore/main/third_party/cmp/
 | 
			
		||||
COPY toxencryptsave/defines.h /root/toxcore/main/toxencryptsave/
 | 
			
		||||
COPY toxcore/ /root/toxcore/main/toxcore/
 | 
			
		||||
COPY other/docker/esp32/main/CMakeLists.txt \
 | 
			
		||||
     /root/toxcore/main/
 | 
			
		||||
COPY other/docker/esp32/main/*.cc \
 | 
			
		||||
     other/docker/esp32/main/*.h \
 | 
			
		||||
     /root/toxcore/main/other/docker/esp32/main/
 | 
			
		||||
RUN touch /root/toxcore/main/CMakeLists.txt \
 | 
			
		||||
 && . /root/esp/esp-idf/export.sh && idf.py build
 | 
			
		||||
RUN ls -lh build/toxcore.bin \
 | 
			
		||||
 && shasum build/toxcore.bin
 | 
			
		||||
 && sha512sum build/toxcore.bin
 | 
			
		||||
RUN /root/flash.sh build/toxcore.bin
 | 
			
		||||
 | 
			
		||||
COPY other/docker/esp32/qemu-test /root/toxcore/
 | 
			
		||||
RUN ["/root/toxcore/qemu-test"]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								external/toxcore/c-toxcore/other/docker/esp32/bootstrap/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								external/toxcore/c-toxcore/other/docker/esp32/bootstrap/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
idf_component_register(
 | 
			
		||||
  SRCS hello_main.cc
 | 
			
		||||
  INCLUDE_DIRS "."
 | 
			
		||||
  REQUIRES esp_netif lwip)
 | 
			
		||||
							
								
								
									
										4
									
								
								external/toxcore/c-toxcore/other/docker/esp32/bootstrap/hello_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								external/toxcore/c-toxcore/other/docker/esp32/bootstrap/hello_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
// Bootstrap main. Only writes hello world. See ../main/ for the real thing.
 | 
			
		||||
extern "C" void app_main(void) { printf("Hello world!\n"); }
 | 
			
		||||
							
								
								
									
										2
									
								
								external/toxcore/c-toxcore/other/docker/esp32/bootstrap/idf_component.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								external/toxcore/c-toxcore/other/docker/esp32/bootstrap/idf_component.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
dependencies:
 | 
			
		||||
  espressif/libsodium: "==1.0.20"
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
set(COMPONENT_SRCS "hello_main.c")
 | 
			
		||||
set(COMPONENT_ADD_INCLUDEDIRS "")
 | 
			
		||||
 | 
			
		||||
register_component()
 | 
			
		||||
@@ -1,6 +0,0 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
void app_main(void)
 | 
			
		||||
{
 | 
			
		||||
    printf("Hello world!\n");
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								external/toxcore/c-toxcore/other/docker/esp32/host_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								external/toxcore/c-toxcore/other/docker/esp32/host_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
#include "main/tox_main.h"
 | 
			
		||||
 | 
			
		||||
int main() { tox_main(); }
 | 
			
		||||
							
								
								
									
										16
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-format -DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE")
 | 
			
		||||
 | 
			
		||||
file(GLOB toxcore_SRCS "toxcore/*.[ch]" "toxcore/*/*.[ch]")
 | 
			
		||||
set(COMPONENT_SRCS
 | 
			
		||||
  ${toxcore_SRCS}
 | 
			
		||||
  other/docker/esp32/main/app_main.cc
 | 
			
		||||
  other/docker/esp32/main/tox_main.cc
 | 
			
		||||
  other/docker/esp32/main/tox_main.h
 | 
			
		||||
  third_party/cmp/cmp.c
 | 
			
		||||
  third_party/cmp/cmp.h
 | 
			
		||||
  toxencryptsave/defines.h)
 | 
			
		||||
 | 
			
		||||
idf_component_register(
 | 
			
		||||
  SRCS ${COMPONENT_SRCS}
 | 
			
		||||
  INCLUDE_DIRS "."
 | 
			
		||||
  REQUIRES esp_eth esp_netif lwip)
 | 
			
		||||
							
								
								
									
										73
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/app_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/app_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
#include <esp_eth.h>
 | 
			
		||||
#include <esp_event.h>
 | 
			
		||||
#include <esp_log.h>
 | 
			
		||||
#include <esp_netif.h>
 | 
			
		||||
#include <esp_netif_sntp.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
#include "tox_main.h"
 | 
			
		||||
 | 
			
		||||
static const char *MAIN_TAG = "app_main";
 | 
			
		||||
static constexpr int NTP_TIMEOUT = 60;  // 1 minute
 | 
			
		||||
 | 
			
		||||
static esp_eth_handle_t eth_handle = nullptr;
 | 
			
		||||
static esp_netif_t *eth_netif = nullptr;
 | 
			
		||||
 | 
			
		||||
static void event_handler(
 | 
			
		||||
    void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
 | 
			
		||||
{
 | 
			
		||||
    if (event_base == ETH_EVENT) {
 | 
			
		||||
        if (event_id == ETHERNET_EVENT_START) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (event_id == ETHERNET_EVENT_STOP) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (event_base == IP_EVENT) {
 | 
			
		||||
        if (event_id == IP_EVENT_ETH_GOT_IP) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void register_ethernet(void)
 | 
			
		||||
{
 | 
			
		||||
    ESP_ERROR_CHECK(esp_netif_init());
 | 
			
		||||
    ESP_ERROR_CHECK(esp_event_loop_create_default());
 | 
			
		||||
    esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
 | 
			
		||||
    eth_netif = esp_netif_new(&cfg);
 | 
			
		||||
 | 
			
		||||
    eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
 | 
			
		||||
    eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
 | 
			
		||||
    esp_eth_mac_t *mac = esp_eth_mac_new_openeth(&mac_config);
 | 
			
		||||
 | 
			
		||||
    esp_eth_phy_t *phy = esp_eth_phy_new_dp83848(&phy_config);
 | 
			
		||||
 | 
			
		||||
    esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
 | 
			
		||||
    ESP_ERROR_CHECK(esp_eth_driver_install(&config, ð_handle));
 | 
			
		||||
    ESP_ERROR_CHECK(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)));
 | 
			
		||||
    ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
 | 
			
		||||
    ESP_ERROR_CHECK(
 | 
			
		||||
        esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &event_handler, NULL));
 | 
			
		||||
    ESP_ERROR_CHECK(esp_eth_start(eth_handle));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Does all the esp32-specific init before running generic tox code.
 | 
			
		||||
extern "C" void app_main(void)
 | 
			
		||||
{
 | 
			
		||||
    register_ethernet();
 | 
			
		||||
 | 
			
		||||
    esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG("pool.ntp.org");
 | 
			
		||||
    ESP_ERROR_CHECK(esp_netif_sntp_init(&config));
 | 
			
		||||
 | 
			
		||||
    if (esp_netif_sntp_sync_wait(pdMS_TO_TICKS(NTP_TIMEOUT * 1000)) != ESP_OK) {
 | 
			
		||||
        ESP_LOGE(MAIN_TAG, "failed to update system time within %ds timeout", NTP_TIMEOUT);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ESP_LOGI(MAIN_TAG, "time is updated: %lld", time(nullptr));
 | 
			
		||||
 | 
			
		||||
    tox_main();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										98
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/tox_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/tox_main.cc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,98 @@
 | 
			
		||||
#include "../main/tox_main.h"
 | 
			
		||||
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
#include "../../../../toxcore/ccompat.h"
 | 
			
		||||
#include "../../../../toxcore/tox.h"
 | 
			
		||||
#include "../../../../toxcore/tox_events.h"
 | 
			
		||||
 | 
			
		||||
static const char *color(int index)
 | 
			
		||||
{
 | 
			
		||||
    switch (index) {
 | 
			
		||||
    case 0:
 | 
			
		||||
        return "\033"
 | 
			
		||||
               "[35m";
 | 
			
		||||
    case 1:
 | 
			
		||||
        return "\033"
 | 
			
		||||
               "[36m";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return "\033"
 | 
			
		||||
           "[0m";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static tox_log_cb log_handler;
 | 
			
		||||
static void log_handler(Tox *tox, Tox_Log_Level level, const char *file, uint32_t line,
 | 
			
		||||
    const char *func, const char *msg, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
    const int *index = static_cast<const int *>(user_data);
 | 
			
		||||
    const uint16_t udp_port = tox_self_get_udp_port(tox, nullptr);
 | 
			
		||||
    printf("%s#%d (:%d) [%c] %s:%u(%s): %s\n", color(*index), *index, udp_port,
 | 
			
		||||
        tox_log_level_to_string(level)[0], file, static_cast<unsigned int>(line), func, msg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
using Tox_Options_Ptr = std::unique_ptr<Tox_Options, void (*)(Tox_Options *)>;
 | 
			
		||||
using Tox_Ptr = std::unique_ptr<Tox, void (*)(Tox *)>;
 | 
			
		||||
 | 
			
		||||
void tox_main()
 | 
			
		||||
{
 | 
			
		||||
    printf("Hello Tox!\n");
 | 
			
		||||
 | 
			
		||||
    Tox_Options_Ptr opts(tox_options_new(nullptr), tox_options_free);
 | 
			
		||||
    assert(opts != nullptr);
 | 
			
		||||
 | 
			
		||||
    tox_options_set_ipv6_enabled(opts.get(), false);
 | 
			
		||||
    tox_options_set_local_discovery_enabled(opts.get(), false);
 | 
			
		||||
 | 
			
		||||
    tox_options_set_log_callback(opts.get(), log_handler);
 | 
			
		||||
 | 
			
		||||
    Tox_Err_New err;
 | 
			
		||||
 | 
			
		||||
    int index[] = {0, 1};
 | 
			
		||||
 | 
			
		||||
    tox_options_set_log_user_data(opts.get(), &index[0]);
 | 
			
		||||
    Tox_Ptr tox0(tox_new(opts.get(), &err), tox_kill);
 | 
			
		||||
    printf("tox_new(#0): %p\n", static_cast<void *>(tox0.get()));
 | 
			
		||||
 | 
			
		||||
    if (err != TOX_ERR_NEW_OK) {
 | 
			
		||||
        printf("tox_new(#0): %s\n", tox_err_new_to_string(err));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tox_options_set_log_user_data(opts.get(), &index[1]);
 | 
			
		||||
    Tox_Ptr tox1(tox_new(opts.get(), &err), tox_kill);
 | 
			
		||||
    printf("tox_new(#1): %p\n", static_cast<void *>(tox0.get()));
 | 
			
		||||
 | 
			
		||||
    if (err != TOX_ERR_NEW_OK) {
 | 
			
		||||
        printf("tox_new(#1): %s\n", tox_err_new_to_string(err));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    uint8_t pk[TOX_PUBLIC_KEY_SIZE];
 | 
			
		||||
    tox_self_get_dht_id(tox0.get(), pk);
 | 
			
		||||
    tox_bootstrap(tox1.get(), "localhost", tox_self_get_udp_port(tox0.get(), nullptr), pk, nullptr);
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    tox_self_get_public_key(tox0.get(), pk);
 | 
			
		||||
    tox_friend_add_norequest(tox1.get(), pk, nullptr);
 | 
			
		||||
 | 
			
		||||
    tox_self_get_public_key(tox1.get(), pk);
 | 
			
		||||
    tox_friend_add_norequest(tox0.get(), pk, nullptr);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    printf("bootstrapping and connecting 2 toxes\n");
 | 
			
		||||
 | 
			
		||||
    while (tox_self_get_connection_status(tox1.get()) == TOX_CONNECTION_NONE
 | 
			
		||||
        || tox_self_get_connection_status(tox0.get()) == TOX_CONNECTION_NONE) {
 | 
			
		||||
        tox_events_free(tox_events_iterate(tox0.get(), true, nullptr));
 | 
			
		||||
        tox_events_free(tox_events_iterate(tox1.get(), true, nullptr));
 | 
			
		||||
 | 
			
		||||
        usleep(tox_iteration_interval(tox0.get()) * 1000);
 | 
			
		||||
        usleep(250);  // a bit less noise in the log
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/tox_main.h
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								external/toxcore/c-toxcore/other/docker/esp32/main/tox_main.h
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
#ifndef TOX_MAIN_H
 | 
			
		||||
#define TOX_MAIN_H
 | 
			
		||||
 | 
			
		||||
void tox_main();
 | 
			
		||||
 | 
			
		||||
#endif // TOX_MAIN_H
 | 
			
		||||
							
								
								
									
										17
									
								
								external/toxcore/c-toxcore/other/docker/esp32/qemu-test
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										17
									
								
								external/toxcore/c-toxcore/other/docker/esp32/qemu-test
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
set -eu
 | 
			
		||||
 | 
			
		||||
qemu-system-xtensa \
 | 
			
		||||
  -nographic \
 | 
			
		||||
  -M esp32 \
 | 
			
		||||
  -m 4 \
 | 
			
		||||
  -drive file=flash.bin,if=mtd,format=raw \
 | 
			
		||||
  -nic user,model=open_eth,hostfwd=tcp::80-:80 \
 | 
			
		||||
  -s |
 | 
			
		||||
  tee qemu.log &
 | 
			
		||||
 | 
			
		||||
echo "Waiting for program to complete"
 | 
			
		||||
while ! grep 'Returned from app_main' qemu.log >/dev/null; do
 | 
			
		||||
  sleep 1
 | 
			
		||||
done
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
 | 
			
		||||
docker build -t toxchat/c-toxcore:esp32 -f other/docker/esp32/Dockerfile .
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								external/toxcore/c-toxcore/other/docker/esp32/run-host
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										5
									
								
								external/toxcore/c-toxcore/other/docker/esp32/run-host
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
set -eux
 | 
			
		||||
 | 
			
		||||
bazel run //c-toxcore/other/docker/esp32:host_main
 | 
			
		||||
							
								
								
									
										1937
									
								
								external/toxcore/c-toxcore/other/docker/esp32/sdkconfig
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1937
									
								
								external/toxcore/c-toxcore/other/docker/esp32/sdkconfig
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,12 +0,0 @@
 | 
			
		||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
 | 
			
		||||
 | 
			
		||||
file(GLOB toxcore_SRCS "toxcore/*.[ch]" "toxcore/*/*.[ch]")
 | 
			
		||||
set(COMPONENT_SRCS
 | 
			
		||||
  ${toxcore_SRCS}
 | 
			
		||||
  other/docker/esp32/main/toxcore_main.cc
 | 
			
		||||
  third_party/cmp/cmp.c
 | 
			
		||||
  third_party/cmp/cmp.h
 | 
			
		||||
  toxencryptsave/defines.h)
 | 
			
		||||
set(COMPONENT_ADD_INCLUDEDIRS "")
 | 
			
		||||
 | 
			
		||||
register_component()
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
#include "../../../../toxcore/ccompat.h"
 | 
			
		||||
#include "../../../../toxcore/tox.h"
 | 
			
		||||
#include "../../../../toxcore/tox_events.h"
 | 
			
		||||
 | 
			
		||||
extern "C" void app_main(void)
 | 
			
		||||
{
 | 
			
		||||
    printf("Hello Tox!\n");
 | 
			
		||||
 | 
			
		||||
    Tox *tox = tox_new(nullptr, nullptr);
 | 
			
		||||
    tox_events_free(tox_events_iterate(tox, true, nullptr));
 | 
			
		||||
    tox_kill(tox);
 | 
			
		||||
}
 | 
			
		||||
@@ -39,7 +39,7 @@ RUN tcc \
 | 
			
		||||
 | 
			
		||||
COPY other/make_single_file /work/other/
 | 
			
		||||
RUN \
 | 
			
		||||
 other/make_single_file \
 | 
			
		||||
 other/make_single_file -core \
 | 
			
		||||
   auto_tests/auto_test_support.c \
 | 
			
		||||
   auto_tests/send_message_test.c \
 | 
			
		||||
   testing/misc_tools.c | \
 | 
			
		||||
@@ -47,5 +47,17 @@ RUN \
 | 
			
		||||
   -o send_message_test \
 | 
			
		||||
   -Wall -Werror \
 | 
			
		||||
   -bench -g \
 | 
			
		||||
   $(pkg-config --cflags --libs libsodium opus vpx) \
 | 
			
		||||
   $(pkg-config --cflags --libs libsodium) \
 | 
			
		||||
 && ./send_message_test | grep 'tox clients connected'
 | 
			
		||||
 | 
			
		||||
RUN \
 | 
			
		||||
 other/make_single_file \
 | 
			
		||||
   auto_tests/auto_test_support.c \
 | 
			
		||||
   auto_tests/toxav_basic_test.c \
 | 
			
		||||
   testing/misc_tools.c | \
 | 
			
		||||
 tcc - \
 | 
			
		||||
   -o toxav_basic_test \
 | 
			
		||||
   -Wall -Werror \
 | 
			
		||||
   -bench -g \
 | 
			
		||||
   $(pkg-config --cflags --libs libsodium opus vpx) \
 | 
			
		||||
 && ./toxav_basic_test | grep 'Test successful'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								external/toxcore/c-toxcore/other/event_tooling/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								external/toxcore/c-toxcore/other/event_tooling/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
FROM ubuntu:22.04
 | 
			
		||||
 | 
			
		||||
RUN apt-get update && apt-get install --no-install-recommends -y \
 | 
			
		||||
 build-essential \
 | 
			
		||||
 ca-certificates \
 | 
			
		||||
 && apt-get clean \
 | 
			
		||||
 && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
WORKDIR /src
 | 
			
		||||
COPY generate_event_c.cpp /src/
 | 
			
		||||
RUN ["g++", "generate_event_c.cpp", "-o", "generate_event_c"]
 | 
			
		||||
CMD ["./generate_event_c"]
 | 
			
		||||
@@ -80,27 +80,27 @@ std::string bin_unpack_name_from_type(const std::string& type) {
 | 
			
		||||
    } else if (type == "bool") {
 | 
			
		||||
        return "bin_unpack_bool";
 | 
			
		||||
    } else if (type == "Tox_User_Status") {
 | 
			
		||||
        return "tox_unpack_user_status";
 | 
			
		||||
        return "tox_user_status_unpack";
 | 
			
		||||
    } else if (type == "Tox_Conference_Type") {
 | 
			
		||||
        return "tox_unpack_conference_type";
 | 
			
		||||
        return "tox_conference_type_unpack";
 | 
			
		||||
    } else if (type == "Tox_Message_Type") {
 | 
			
		||||
        return "tox_unpack_message_type";
 | 
			
		||||
        return "tox_message_type_unpack";
 | 
			
		||||
    } else if (type == "Tox_File_Control") {
 | 
			
		||||
        return "tox_unpack_file_control";
 | 
			
		||||
        return "tox_file_control_unpack";
 | 
			
		||||
    } else if (type == "Tox_Connection") {
 | 
			
		||||
        return "tox_unpack_connection";
 | 
			
		||||
        return "tox_connection_unpack";
 | 
			
		||||
    } else if (type == "Tox_Group_Privacy_State") {
 | 
			
		||||
        return "tox_unpack_group_privacy_state";
 | 
			
		||||
        return "tox_group_privacy_state_unpack";
 | 
			
		||||
    } else if (type == "Tox_Group_Voice_State") {
 | 
			
		||||
        return "tox_unpack_group_voice_state";
 | 
			
		||||
        return "tox_group_voice_state_unpack";
 | 
			
		||||
    } else if (type == "Tox_Group_Topic_Lock") {
 | 
			
		||||
        return "tox_unpack_group_topic_lock";
 | 
			
		||||
        return "tox_group_topic_lock_unpack";
 | 
			
		||||
    } else if (type == "Tox_Group_Join_Fail") {
 | 
			
		||||
        return "tox_unpack_group_join_fail";
 | 
			
		||||
        return "tox_group_join_fail_unpack";
 | 
			
		||||
    } else if (type == "Tox_Group_Mod_Event") {
 | 
			
		||||
        return "tox_unpack_group_mod_event";
 | 
			
		||||
        return "tox_group_mod_event_unpack";
 | 
			
		||||
    } else if (type == "Tox_Group_Exit_Type") {
 | 
			
		||||
        return "tox_unpack_group_exit_type";
 | 
			
		||||
        return "tox_group_exit_type_unpack";
 | 
			
		||||
    } else {
 | 
			
		||||
        std::cerr << "unknown type " << type << "\n";
 | 
			
		||||
        exit(1);
 | 
			
		||||
@@ -109,7 +109,7 @@ std::string bin_unpack_name_from_type(const std::string& type) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void generate_event_impl(const std::string& event_name, std::vector<EventType> event_types) {
 | 
			
		||||
void generate_event_impl(const std::string& event_name, const std::vector<EventType>& event_types) {
 | 
			
		||||
    const std::string event_name_l = str_tolower(event_name);
 | 
			
		||||
    std::string file_name = output_folder + "/" + event_name_l + ".c";
 | 
			
		||||
 | 
			
		||||
@@ -164,35 +164,6 @@ void generate_event_impl(const std::string& event_name, std::vector<EventType> e
 | 
			
		||||
    }
 | 
			
		||||
    f << "};\n\n";
 | 
			
		||||
 | 
			
		||||
    // gen contruct
 | 
			
		||||
    f << "non_null()\n";
 | 
			
		||||
    f << "static void tox_event_" << event_name_l << "_construct(Tox_Event_" << event_name << " *" << event_name_l << ")\n{\n";
 | 
			
		||||
    // TODO: initialize all members properly
 | 
			
		||||
    // TODO: check if _NONE is universal
 | 
			
		||||
    // str_toupper(
 | 
			
		||||
    f << "    *" << event_name_l << " = (Tox_Event_" << event_name << ") {\n        0\n    };\n}\n";
 | 
			
		||||
 | 
			
		||||
    // gen destruct
 | 
			
		||||
    f << "non_null()\n";
 | 
			
		||||
    f << "static void tox_event_" << event_name_l << "_destruct(Tox_Event_" << event_name << " *" << event_name_l << ")\n{\n";
 | 
			
		||||
    size_t data_count = 0;
 | 
			
		||||
    for (const auto& t : event_types) {
 | 
			
		||||
        std::visit(
 | 
			
		||||
            overloaded{
 | 
			
		||||
                [&](const EventTypeTrivial&) {},
 | 
			
		||||
                [&](const EventTypeByteRange& t) {
 | 
			
		||||
                    f << "    free(" << event_name_l << "->" << t.name_data << ");\n";
 | 
			
		||||
                    data_count++;
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            t
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    if (data_count == 0) {
 | 
			
		||||
        f << "    return;\n";
 | 
			
		||||
    }
 | 
			
		||||
    f << "}\n\n";
 | 
			
		||||
 | 
			
		||||
    // gen setters and getters
 | 
			
		||||
    for (const auto& t : event_types) {
 | 
			
		||||
        // setter
 | 
			
		||||
@@ -258,7 +229,7 @@ void generate_event_impl(const std::string& event_name, std::vector<EventType> e
 | 
			
		||||
                },
 | 
			
		||||
                [&](const EventTypeByteRange& t) {
 | 
			
		||||
                    //f << "non_null()\n"; // TODO: is this missing in the original?
 | 
			
		||||
                    f << "size_t tox_event_" << event_name_l << "_get_" << t.name_length;
 | 
			
		||||
                    f << "uint32_t tox_event_" << event_name_l << "_get_" << t.name_length;
 | 
			
		||||
                    f << "(const Tox_Event_" << event_name << " *" << event_name_l << ")\n";
 | 
			
		||||
                    f << "{\n    assert(" << event_name_l << " != nullptr);\n";
 | 
			
		||||
                    f << "    return " << event_name_l << "->" << t.name_length << ";\n}\n";
 | 
			
		||||
@@ -272,15 +243,45 @@ void generate_event_impl(const std::string& event_name, std::vector<EventType> e
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // pack
 | 
			
		||||
 | 
			
		||||
    // gen contruct
 | 
			
		||||
    f << "non_null()\n";
 | 
			
		||||
    f << "static bool tox_event_" << event_name_l << "_pack(\n";
 | 
			
		||||
    f << "static void tox_event_" << event_name_l << "_construct(Tox_Event_" << event_name << " *" << event_name_l << ")\n{\n";
 | 
			
		||||
    // TODO: initialize all members properly
 | 
			
		||||
    // TODO: check if _NONE is universal
 | 
			
		||||
    // str_toupper(
 | 
			
		||||
    f << "    *" << event_name_l << " = (Tox_Event_" << event_name << ") {\n        0\n    };\n}\n";
 | 
			
		||||
 | 
			
		||||
    // gen destruct
 | 
			
		||||
    f << "non_null()\n";
 | 
			
		||||
    f << "static void tox_event_" << event_name_l << "_destruct(Tox_Event_" << event_name << " *" << event_name_l << ", const Memory *mem)\n{\n";
 | 
			
		||||
    size_t data_count = 0;
 | 
			
		||||
    for (const auto& t : event_types) {
 | 
			
		||||
        std::visit(
 | 
			
		||||
            overloaded{
 | 
			
		||||
                [&](const EventTypeTrivial&) {},
 | 
			
		||||
                [&](const EventTypeByteRange& t) {
 | 
			
		||||
                    f << "    free(" << event_name_l << "->" << t.name_data << ");\n";
 | 
			
		||||
                    //f << "    mem->funcs->free(mem->obj, " << event_name_l << "->" << t.name_data << ");\n";
 | 
			
		||||
                    data_count++;
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            t
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    if (data_count == 0) {
 | 
			
		||||
        f << "    return;\n";
 | 
			
		||||
    }
 | 
			
		||||
    f << "}\n\n";
 | 
			
		||||
 | 
			
		||||
    // pack
 | 
			
		||||
    f << "bool tox_event_" << event_name_l << "_pack(\n";
 | 
			
		||||
    f << "    const Tox_Event_" << event_name << " *event, Bin_Pack *bp)\n{\n";
 | 
			
		||||
    f << "    assert(event != nullptr);\n";
 | 
			
		||||
    f << "    return bin_pack_array(bp, 2)\n";
 | 
			
		||||
    f << "           && bin_pack_u32(bp, TOX_EVENT_" << str_toupper(event_name) << ")\n";
 | 
			
		||||
    f << "           && bin_pack_u32(bp, TOX_EVENT_" << str_toupper(event_name) << ")";
 | 
			
		||||
    if (event_types.size() > 1) {
 | 
			
		||||
        f << "           && bin_pack_array(bp, " << event_types.size() << ")";
 | 
			
		||||
        f << "\n           && bin_pack_array(bp, " << event_types.size() << ")";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (const auto& t : event_types) {
 | 
			
		||||
@@ -302,7 +303,7 @@ void generate_event_impl(const std::string& event_name, std::vector<EventType> e
 | 
			
		||||
 | 
			
		||||
    // unpack
 | 
			
		||||
    f << "non_null()\n";
 | 
			
		||||
    f << "static bool tox_event_" << event_name_l << "_unpack(\n";
 | 
			
		||||
    f << "static bool tox_event_" << event_name_l << "_unpack_into(\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *event, Bin_Unpack *bu)\n{\n";
 | 
			
		||||
    f << "    assert(event != nullptr);\n";
 | 
			
		||||
    if (event_types.size() > 1) {
 | 
			
		||||
@@ -335,71 +336,82 @@ void generate_event_impl(const std::string& event_name, std::vector<EventType> e
 | 
			
		||||
    f << R"(
 | 
			
		||||
/*****************************************************
 | 
			
		||||
 *
 | 
			
		||||
 * :: add/clear/get
 | 
			
		||||
 * :: new/free/add/get/size/unpack
 | 
			
		||||
 *
 | 
			
		||||
 *****************************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
)";
 | 
			
		||||
 | 
			
		||||
    f << "const Tox_Event_" << event_name << " *tox_event_get_" << event_name_l << "(const Tox_Event *event)\n{\n";
 | 
			
		||||
    f << "    return event->type == TOX_EVENT_" << str_toupper(event_name) << " ? event->data." << event_name_l << " : nullptr;\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // new
 | 
			
		||||
    f << "Tox_Event_" << event_name << " *tox_event_" << event_name_l << "_new(const Memory *mem)\n{\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *const " << event_name_l << " =\n";
 | 
			
		||||
    f << "        (Tox_Event_" << event_name << " *)mem_alloc(mem, sizeof(Tox_Event_" << event_name << "));\n\n";
 | 
			
		||||
    f << "    if (" << event_name_l << " == nullptr) {\n        return nullptr;\n    }\n\n";
 | 
			
		||||
    f << "    tox_event_" << event_name_l << "_construct(" << event_name_l << ");\n";
 | 
			
		||||
    f << "    return " << event_name_l << ";\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // free
 | 
			
		||||
    f << "void tox_event_" << event_name_l << "_free(Tox_Event_" << event_name << " *" << event_name_l << ", const Memory *mem)\n{\n";
 | 
			
		||||
    f << "    if (" << event_name_l << " != nullptr) {\n";
 | 
			
		||||
    f << "        tox_event_" << event_name_l << "_destruct(" << event_name_l << ", mem);\n    }\n";
 | 
			
		||||
    f << "    mem_delete(mem, " << event_name_l << ");\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // add
 | 
			
		||||
    f << "non_null()\n";
 | 
			
		||||
    f << "static Tox_Event_" << event_name << " *tox_events_add_" << event_name_l << "(Tox_Events *events)\n{\n";
 | 
			
		||||
    f << "    if (events->" << event_name_l << "_size == UINT32_MAX) {\n";
 | 
			
		||||
    f << "static Tox_Event_" << event_name << " *tox_events_add_" << event_name_l << "(Tox_Events *events, const Memory *mem)\n{\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *const " << event_name_l << " = tox_event_" << event_name_l << "_new(mem);\n\n";
 | 
			
		||||
    f << "    if (" << event_name_l << " == nullptr) {\n";
 | 
			
		||||
    f << "        return nullptr;\n    }\n\n";
 | 
			
		||||
    f << "    if (events->" << event_name_l << "_size == events->" << event_name_l << "_capacity) {\n";
 | 
			
		||||
    f << "        const uint32_t new_" << event_name_l << "_capacity = events->" << event_name_l << "_capacity * 2 + 1;\n";
 | 
			
		||||
 | 
			
		||||
    f << "        Tox_Event_" << event_name << " *new_" << event_name_l << " = (Tox_Event_" << event_name << " *)\n";
 | 
			
		||||
    f << "                realloc(\n";
 | 
			
		||||
 | 
			
		||||
    f << "                    events->" << event_name_l << ",\n";
 | 
			
		||||
    f << "                    new_" << event_name_l << "_capacity * sizeof(Tox_Event_" << event_name << "));\n\n";
 | 
			
		||||
    f << "        if (new_" << event_name_l << " == nullptr) {\n            return nullptr;\n        }\n\n";
 | 
			
		||||
    f << "        events->" << event_name_l << " = new_" << event_name_l << ";\n";
 | 
			
		||||
    f << "        events->" << event_name_l << "_capacity = new_" << event_name_l << "_capacity;\n";
 | 
			
		||||
    f << "    }\n\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *const " << event_name_l << " =\n";
 | 
			
		||||
    f << "        &events->" << event_name_l << "[events->" << event_name_l << "_size];\n";
 | 
			
		||||
    f << "    tox_event_" << event_name_l << "_construct(" << event_name_l << ");\n";
 | 
			
		||||
    f << "    ++events->" << event_name_l << "_size;\n";
 | 
			
		||||
    f << "    Tox_Event event;\n";
 | 
			
		||||
    f << "    event.type = TOX_EVENT_" << str_toupper(event_name) << ";\n";
 | 
			
		||||
    f << "    event.data." << event_name_l << " = " << event_name_l << ";\n\n";
 | 
			
		||||
    f << "    tox_events_add(events, &event);\n";
 | 
			
		||||
    f << "    return " << event_name_l << ";\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // clear
 | 
			
		||||
    f << "void tox_events_clear_" << event_name_l << "(Tox_Events *events)\n{\n";
 | 
			
		||||
    f << "    if (events == nullptr) {\n        return;\n    }\n\n";
 | 
			
		||||
    f << "    for (uint32_t i = 0; i < events->" << event_name_l << "_size; ++i) {\n";
 | 
			
		||||
    f << "        tox_event_" << event_name_l << "_destruct(&events->" << event_name_l << "[i]);\n    }\n\n";
 | 
			
		||||
    f << "    free(events->" << event_name_l << ");\n";
 | 
			
		||||
    f << "    events->" << event_name_l << " = nullptr;\n";
 | 
			
		||||
    f << "    events->" << event_name_l << "_size = 0;\n";
 | 
			
		||||
    f << "    events->" << event_name_l << "_capacity = 0;\n";
 | 
			
		||||
    f << "}\n\n";
 | 
			
		||||
 | 
			
		||||
    // get size
 | 
			
		||||
    f << "uint32_t tox_events_get_" << event_name_l << "_size(const Tox_Events *events)\n{\n";
 | 
			
		||||
    f << "    if (events == nullptr) {\n        return 0;\n    }\n\n";
 | 
			
		||||
    f << "    return events->" << event_name_l << "_size;\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // get
 | 
			
		||||
    f << "const Tox_Event_" << event_name << " *tox_events_get_" << event_name_l << "(const Tox_Events *events, uint32_t index)\n{\n";
 | 
			
		||||
    f << "    assert(index < events->" << event_name_l << "_size);\n";
 | 
			
		||||
    f << "    assert(events->" << event_name_l << " != nullptr);\n";
 | 
			
		||||
    f << "    return &events->" << event_name_l << "[index];\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // aux pack
 | 
			
		||||
    f << "bool tox_events_pack_" << event_name_l << "(const Tox_Events *events, Bin_Pack *bp)\n{\n";
 | 
			
		||||
    f << "    const uint32_t size = tox_events_get_" << event_name_l << "_size(events);\n\n";
 | 
			
		||||
    f << "    uint32_t " << event_name_l << "_index = 0;\n";
 | 
			
		||||
    f << "    const uint32_t size = tox_events_get_size(events);\n\n";
 | 
			
		||||
    f << "    for (uint32_t i = 0; i < size; ++i) {\n";
 | 
			
		||||
    f << "        if (!tox_event_" << event_name_l << "_pack(tox_events_get_" << event_name_l << "(events, i), bp)) {\n";
 | 
			
		||||
    f << "            return false;\n        }\n    }\n";
 | 
			
		||||
    f << "    return true;\n}\n\n";
 | 
			
		||||
    f << "        if (" << event_name_l << "_index > index) {\n";
 | 
			
		||||
    f << "            return nullptr;\n        }\n\n";
 | 
			
		||||
    f << "        if (events->events[i].type == TOX_EVENT_" << str_toupper(event_name) << ") {\n";
 | 
			
		||||
    f << "            const Tox_Event_" << event_name << " *" << event_name_l << " = events->events[i].data." << event_name_l << ";\n";
 | 
			
		||||
    f << "            if (" << event_name_l << "_index == index) {\n";
 | 
			
		||||
    f << "                return " << event_name_l << ";\n            }\n";
 | 
			
		||||
    f << "            ++" << event_name_l << "_index;\n        }\n    }\n\n    return nullptr;\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // get size
 | 
			
		||||
    f << "uint32_t tox_events_get_" << event_name_l << "_size(const Tox_Events *events)\n{\n";
 | 
			
		||||
    f << "    uint32_t " << event_name_l << "_size = 0;\n";
 | 
			
		||||
    f << "    const uint32_t size = tox_events_get_size(events);\n\n";
 | 
			
		||||
    f << "    for (uint32_t i = 0; i < size; ++i) {\n";
 | 
			
		||||
    f << "        if (events->events[i].type == TOX_EVENT_" << str_toupper(event_name) << ") {\n";
 | 
			
		||||
    f << "            ++" << event_name_l << "_size;\n        }\n    }\n\n";
 | 
			
		||||
    f << "    return " << event_name_l << "_size;\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // unpack
 | 
			
		||||
    f << "bool tox_event_" << event_name_l << "_unpack(\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " **event, Bin_Unpack *bu, const Memory *mem)\n{\n";
 | 
			
		||||
    f << "    assert(event != nullptr);\n";
 | 
			
		||||
    f << "    *event = tox_event_" << event_name_l << "_new(mem);\n\n";
 | 
			
		||||
    f << "    if (*event == nullptr) {\n        return false;\n    }\n\n";
 | 
			
		||||
    f << "    return tox_event_" << event_name_l << "_unpack_into(*event, bu);\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // alloc
 | 
			
		||||
    f << "non_null()\n";
 | 
			
		||||
    f << "static Tox_Event_" << event_name << " *tox_event_" << event_name_l << "_alloc(void *user_data)\n{\n";
 | 
			
		||||
    f << "    Tox_Events_State *state = tox_events_alloc(user_data);\n";
 | 
			
		||||
    f << "    assert(state != nullptr);\n\n";
 | 
			
		||||
    f << "    if (state->events == nullptr) {\n        return nullptr;\n    }\n\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *" << event_name_l << " = tox_events_add_" << event_name_l << "(state->events, state->mem);\n\n";
 | 
			
		||||
    f << "    if (" << event_name_l << " == nullptr) {\n";
 | 
			
		||||
    f << "        state->error = TOX_ERR_EVENTS_ITERATE_MALLOC;\n        return nullptr;\n    }\n\n";
 | 
			
		||||
    f << "    return " << event_name_l << ";\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    // aux unpack
 | 
			
		||||
    f << "bool tox_events_unpack_" << event_name_l << "(Tox_Events *events, Bin_Unpack *bu)\n{\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *event = tox_events_add_" << event_name_l << "(events);\n\n";
 | 
			
		||||
    f << "    if (event == nullptr) {\n        return false;\n    }\n\n";
 | 
			
		||||
    f << "    return tox_event_" << event_name_l << "_unpack(event, bu);\n}\n\n";
 | 
			
		||||
 | 
			
		||||
    f << R"(
 | 
			
		||||
/*****************************************************
 | 
			
		||||
@@ -427,12 +439,8 @@ void generate_event_impl(const std::string& event_name, std::vector<EventType> e
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    f << ",\n        void *user_data)\n{\n";
 | 
			
		||||
    f << "    Tox_Events_State *state = tox_events_alloc(user_data);\n";
 | 
			
		||||
    f << "    assert(state != nullptr);\n\n";
 | 
			
		||||
    f << "    if (state->events == nullptr) {\n        return;\n    }\n\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *" << event_name_l << " = tox_events_add_" << event_name_l << "(state->events);\n\n";
 | 
			
		||||
    f << "    if (" << event_name_l << " == nullptr) {\n";
 | 
			
		||||
    f << "        state->error = TOX_ERR_EVENTS_ITERATE_MALLOC;\n        return;\n    }\n\n";
 | 
			
		||||
    f << "    Tox_Event_" << event_name << " *" << event_name_l << " = tox_event_" << event_name_l << "_alloc(user_data);\n\n";
 | 
			
		||||
    f << "    if (" << event_name_l << " == nullptr) {\n        return;\n    }\n\n";
 | 
			
		||||
 | 
			
		||||
    for (const auto& t : event_types) {
 | 
			
		||||
        std::visit(
 | 
			
		||||
@@ -465,7 +473,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeTrivial{"Tox_Conference_Type", "type"},
 | 
			
		||||
                EventTypeByteRange{"cookie", "cookie_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"cookie", "cookie_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -474,7 +482,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "conference_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_number"},
 | 
			
		||||
                EventTypeTrivial{"Tox_Message_Type", "type"},
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -488,7 +496,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "conference_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_number"},
 | 
			
		||||
                EventTypeByteRange{"name", "name_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"name", "name_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -496,7 +504,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "conference_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_number"},
 | 
			
		||||
                EventTypeByteRange{"title", "title_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"title", "title_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
@@ -516,7 +524,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "file_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "kind"},
 | 
			
		||||
                EventTypeTrivial{"uint64_t", "file_size"},
 | 
			
		||||
                EventTypeByteRange{"filename", "filename_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"filename", "filename_length", "filename_length"},
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -525,7 +533,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "file_number"},
 | 
			
		||||
                EventTypeTrivial{"uint64_t", "position"},
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -548,14 +556,14 @@ int main(int argc, char** argv) {
 | 
			
		||||
            "Friend_Lossless_Packet",
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "Friend_Lossy_Packet",
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -563,14 +571,14 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeTrivial{"Tox_Message_Type", "type"},
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "Friend_Name",
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeByteRange{"name", "name_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"name", "name_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -585,7 +593,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            "Friend_Request",
 | 
			
		||||
            {
 | 
			
		||||
                //EventTypeTrivial{"uint32_t", "friend_number"}, // public_key ByteArray
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
#endif
 | 
			
		||||
@@ -600,7 +608,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            "Friend_Status_Message",
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -623,7 +631,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "group_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_id"},
 | 
			
		||||
                EventTypeByteRange{"name", "name_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"name", "name_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -639,7 +647,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "group_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_id"},
 | 
			
		||||
                EventTypeByteRange{"topic", "topic_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"topic", "topic_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -674,7 +682,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            "Group_Password",
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "group_number"},
 | 
			
		||||
                EventTypeByteRange{"password", "password_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"password", "password_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -683,7 +691,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "group_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_id"},
 | 
			
		||||
                EventTypeTrivial{"Tox_Message_Type", "type"},
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "message_id"},
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
@@ -693,7 +701,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "group_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_id"},
 | 
			
		||||
                EventTypeTrivial{"Tox_Message_Type", "type"},
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -701,7 +709,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "group_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_id"},
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -709,14 +717,14 @@ int main(int argc, char** argv) {
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "group_number"},
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "peer_id"},
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"data", "data_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "Group_Invite",
 | 
			
		||||
            {
 | 
			
		||||
                EventTypeTrivial{"uint32_t", "friend_number"},
 | 
			
		||||
                EventTypeByteRange{"invite_data", "invite_data_length", "length"}, // the later two are idealy the same
 | 
			
		||||
                EventTypeByteRange{"invite_data", "invite_data_length", "length"}, // the latter two are ideally the same
 | 
			
		||||
                EventTypeByteRange{"group_name", "group_name_length", "group_name_length"}, // they are :)
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								external/toxcore/c-toxcore/other/event_tooling/run
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								external/toxcore/c-toxcore/other/event_tooling/run
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
set -eux
 | 
			
		||||
BUILD=events
 | 
			
		||||
docker build -t "toxchat/c-toxcore:$BUILD" "other/event_tooling"
 | 
			
		||||
docker run --rm -v "$PWD/toxcore/events:/src/out" -t "toxchat/c-toxcore:$BUILD"
 | 
			
		||||
sed -i -e 's/, uint16_t length,/, size_t length,/' toxcore/events/file_chunk_request.c
 | 
			
		||||
sed -i -e 's/^        0/        TOX_CONNECTION_NONE/' toxcore/events/self_connection_status.c
 | 
			
		||||
@@ -1,30 +1,41 @@
 | 
			
		||||
function(target_link_toxcore target)
 | 
			
		||||
  if(TARGET toxcore_static)
 | 
			
		||||
    target_link_libraries(${target} PRIVATE toxcore_static)
 | 
			
		||||
  else()
 | 
			
		||||
    target_link_libraries(${target} PRIVATE toxcore_shared)
 | 
			
		||||
  endif()
 | 
			
		||||
endfunction()
 | 
			
		||||
 | 
			
		||||
add_executable(save-generator save-generator.c)
 | 
			
		||||
target_link_modules(save-generator toxcore misc_tools)
 | 
			
		||||
target_link_libraries(save-generator PRIVATE misc_tools)
 | 
			
		||||
target_link_toxcore(save-generator)
 | 
			
		||||
 | 
			
		||||
add_executable(strkey strkey.c)
 | 
			
		||||
target_link_modules(strkey toxcore ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_libraries(strkey PRIVATE ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_toxcore(strkey)
 | 
			
		||||
 | 
			
		||||
add_executable(create_bootstrap_keys create_bootstrap_keys.c)
 | 
			
		||||
target_link_modules(create_bootstrap_keys ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_libraries(create_bootstrap_keys PRIVATE ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_toxcore(create_bootstrap_keys)
 | 
			
		||||
 | 
			
		||||
add_executable(create_minimal_savedata create_minimal_savedata.c)
 | 
			
		||||
target_link_modules(create_minimal_savedata ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_libraries(create_minimal_savedata PRIVATE ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
 | 
			
		||||
add_executable(create_savedata create_savedata.c)
 | 
			
		||||
target_link_modules(create_savedata toxcore ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_libraries(create_savedata PRIVATE ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_toxcore(create_savedata)
 | 
			
		||||
 | 
			
		||||
add_executable(sign sign.c)
 | 
			
		||||
target_link_modules(sign ${LIBSODIUM_LIBRARIES} misc_tools)
 | 
			
		||||
target_link_libraries(sign PRIVATE ${LIBSODIUM_LIBRARIES} misc_tools)
 | 
			
		||||
 | 
			
		||||
add_executable(cracker_simple cracker_simple.c)
 | 
			
		||||
target_link_modules(cracker_simple ${LIBSODIUM_LIBRARIES} misc_tools)
 | 
			
		||||
target_link_libraries(cracker_simple ${LIBSODIUM_LIBRARIES} misc_tools)
 | 
			
		||||
 | 
			
		||||
# MSVC doesn't support OpenMP
 | 
			
		||||
if(NOT MSVC)
 | 
			
		||||
  find_package(OpenMP)
 | 
			
		||||
  if(OpenMP_C_FOUND)
 | 
			
		||||
    add_executable(cracker cracker.c)
 | 
			
		||||
    target_link_modules(cracker ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
    target_link_libraries(cracker OpenMP::OpenMP_C)
 | 
			
		||||
    target_link_libraries(cracker PRIVATE OpenMP::OpenMP_C ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
  endif()
 | 
			
		||||
endif()
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ static bool create_tox(const unsigned char *const secret_key, Tox **const tox)
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool print_savedata(Tox *const tox)
 | 
			
		||||
static bool print_savedata(const Tox *const tox)
 | 
			
		||||
{
 | 
			
		||||
    const size_t savedata_size = tox_get_savedata_size(tox);
 | 
			
		||||
    uint8_t *const savedata = (uint8_t *)malloc(savedata_size);
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ static void tox_connection_callback(Tox *tox, Tox_Connection connection, void *u
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void print_information(Tox *tox)
 | 
			
		||||
static void print_information(const Tox *tox)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t tox_id[TOX_ADDRESS_SIZE];
 | 
			
		||||
    char tox_id_str[TOX_ADDRESS_SIZE * 2];
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								external/toxcore/c-toxcore/other/fun/sign.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/toxcore/c-toxcore/other/fun/sign.c
									
									
									
									
										vendored
									
									
								
							@@ -21,7 +21,7 @@
 | 
			
		||||
#include "../../testing/misc_tools.h" // hex_string_to_bin
 | 
			
		||||
#include "../../toxcore/ccompat.h"
 | 
			
		||||
 | 
			
		||||
static int load_file(char *filename, unsigned char **result)
 | 
			
		||||
static int load_file(const char *filename, unsigned char **result)
 | 
			
		||||
{
 | 
			
		||||
    int size = 0;
 | 
			
		||||
    FILE *f = fopen(filename, "rb");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 *
 | 
			
		||||
 * Generates Tox's key pairs, checking if a certain string is in the public key.
 | 
			
		||||
 *
 | 
			
		||||
 * Requires sodium or nacl library.
 | 
			
		||||
 * Requires sodium library.
 | 
			
		||||
 *
 | 
			
		||||
 * There seem to be some problems with the code working on Windows -- it works
 | 
			
		||||
 * when built in debug mode with MinGW 4.8, but it doesn't work correctly when
 | 
			
		||||
@@ -45,7 +45,7 @@
 | 
			
		||||
 | 
			
		||||
#define PRINT_TRIES_COUNT
 | 
			
		||||
 | 
			
		||||
static void print_key(unsigned char *key)
 | 
			
		||||
static void print_key(const unsigned char *key)
 | 
			
		||||
{
 | 
			
		||||
    for (size_t i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) {
 | 
			
		||||
        if (key[i] < 16) {
 | 
			
		||||
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
 | 
			
		||||
            }
 | 
			
		||||
        } while (!found);
 | 
			
		||||
    } else {
 | 
			
		||||
        unsigned char *p = public_key + offset;
 | 
			
		||||
        const unsigned char *p = public_key + offset;
 | 
			
		||||
 | 
			
		||||
        do {
 | 
			
		||||
#ifdef PRINT_TRIES_COUNT
 | 
			
		||||
 
 | 
			
		||||
@@ -6,8 +6,11 @@
 | 
			
		||||
#
 | 
			
		||||
# Example:
 | 
			
		||||
#
 | 
			
		||||
#   other/make_single_file testing/misc_tools.c auto_tests/send_message_test.c | \
 | 
			
		||||
#     tcc -o send_message_test - $(pkg-config --cflags --libs libsodium opus vpx)
 | 
			
		||||
#   other/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 | \
 | 
			
		||||
#     tcc -o send_message_test - $(pkg-config --cflags --libs libsodium)
 | 
			
		||||
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
@@ -44,7 +47,7 @@ sub emit {
 | 
			
		||||
 | 
			
		||||
if (@ARGV and $ARGV[0] eq "-core") {
 | 
			
		||||
   shift @ARGV;
 | 
			
		||||
   for my $fn (<toxcore/*.c>, <third_party/cmp/*.c>) {
 | 
			
		||||
   for my $fn (<toxcore/*.c>, <toxcore/*/*.c>, <third_party/cmp/*.c>) {
 | 
			
		||||
      emit(abs_path $fn);
 | 
			
		||||
   }
 | 
			
		||||
} else {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										41
									
								
								external/toxcore/c-toxcore/testing/BUILD.bazel
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								external/toxcore/c-toxcore/testing/BUILD.bazel
									
									
									
									
										vendored
									
									
								
							@@ -15,11 +15,43 @@ sh_test(
 | 
			
		||||
        "-Wno-callback-names",
 | 
			
		||||
        "-Wno-enum-names",
 | 
			
		||||
        "+RTS",
 | 
			
		||||
        "-N3",
 | 
			
		||||
        "-N4",
 | 
			
		||||
        "-RTS",
 | 
			
		||||
    ],
 | 
			
		||||
    data = CIMPLE_FILES,
 | 
			
		||||
    tags = ["haskell"],
 | 
			
		||||
    tags = [
 | 
			
		||||
        "haskell",
 | 
			
		||||
        "no-cross",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
sh_test(
 | 
			
		||||
    name = "c_test",
 | 
			
		||||
    size = "small",
 | 
			
		||||
    srcs = ["//hs-tokstyle/tools:check-c"],
 | 
			
		||||
    args = [
 | 
			
		||||
        "--cc=$(CC)",
 | 
			
		||||
        "-Iexternal/libsodium/include",
 | 
			
		||||
        "-Iexternal/libvpx",
 | 
			
		||||
        "-Iexternal/opus/include",
 | 
			
		||||
        "-Ihs-tokstyle/include",
 | 
			
		||||
    ] + ["$(locations %s)" % f for f in CIMPLE_FILES] + [
 | 
			
		||||
        "+RTS",
 | 
			
		||||
        "-N4",
 | 
			
		||||
        "-RTS",
 | 
			
		||||
    ],
 | 
			
		||||
    data = CIMPLE_FILES + [
 | 
			
		||||
        "//c-toxcore/third_party:headers",
 | 
			
		||||
        "//hs-tokstyle:headers",
 | 
			
		||||
        "@libsodium//:headers",
 | 
			
		||||
        "@libvpx//:headers",
 | 
			
		||||
        "@opus//:headers",
 | 
			
		||||
    ],
 | 
			
		||||
    tags = [
 | 
			
		||||
        "haskell",
 | 
			
		||||
        "no-cross",
 | 
			
		||||
    ],
 | 
			
		||||
    toolchains = ["@rules_cc//cc:current_cc_toolchain"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
sh_test(
 | 
			
		||||
@@ -28,7 +60,10 @@ sh_test(
 | 
			
		||||
    srcs = ["//hs-cimple/tools:cimplefmt"],
 | 
			
		||||
    args = ["--reparse"] + ["$(locations %s)" % f for f in CIMPLE_FILES],
 | 
			
		||||
    data = CIMPLE_FILES,
 | 
			
		||||
    tags = ["haskell"],
 | 
			
		||||
    tags = [
 | 
			
		||||
        "haskell",
 | 
			
		||||
        "no-cross",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
cc_library(
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,15 @@ set(misc_tools_SOURCES
 | 
			
		||||
  misc_tools.c
 | 
			
		||||
  misc_tools.h)
 | 
			
		||||
add_library(misc_tools STATIC ${misc_tools_SOURCES})
 | 
			
		||||
target_link_modules(misc_tools toxcore)
 | 
			
		||||
if(TARGET toxcore_static)
 | 
			
		||||
  target_link_libraries(misc_tools PRIVATE toxcore_static)
 | 
			
		||||
else()
 | 
			
		||||
  target_link_libraries(misc_tools PRIVATE toxcore_shared)
 | 
			
		||||
endif()
 | 
			
		||||
target_link_libraries(misc_tools PRIVATE ${LIBSODIUM_LIBRARIES})
 | 
			
		||||
target_link_directories(misc_tools PUBLIC ${LIBSODIUM_LIBRARY_DIRS})
 | 
			
		||||
target_include_directories(misc_tools SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
 | 
			
		||||
target_compile_options(misc_tools PRIVATE ${LIBSODIUM_CFLAGS_OTHER})
 | 
			
		||||
 | 
			
		||||
################################################################################
 | 
			
		||||
#
 | 
			
		||||
@@ -11,7 +19,12 @@ target_link_modules(misc_tools toxcore)
 | 
			
		||||
#
 | 
			
		||||
################################################################################
 | 
			
		||||
 | 
			
		||||
if (BUILD_MISC_TESTS)
 | 
			
		||||
if(BUILD_MISC_TESTS)
 | 
			
		||||
  add_executable(Messenger_test Messenger_test.c)
 | 
			
		||||
  target_link_modules(Messenger_test toxcore misc_tools)
 | 
			
		||||
  target_link_libraries(Messenger_test PRIVATE misc_tools)
 | 
			
		||||
  if(TARGET toxcore_static)
 | 
			
		||||
    target_link_libraries(Messenger_test PRIVATE toxcore_static)
 | 
			
		||||
  else()
 | 
			
		||||
    target_link_libraries(Messenger_test PRIVATE toxcore_shared)
 | 
			
		||||
  endif()
 | 
			
		||||
endif()
 | 
			
		||||
 
 | 
			
		||||
@@ -19,16 +19,12 @@ noinst_PROGRAMS +=      Messenger_test
 | 
			
		||||
Messenger_test_SOURCES = \
 | 
			
		||||
                        ../testing/Messenger_test.c
 | 
			
		||||
 | 
			
		||||
Messenger_test_CFLAGS = $(LIBSODIUM_CFLAGS) \
 | 
			
		||||
                        $(NACL_CFLAGS)
 | 
			
		||||
Messenger_test_CFLAGS = $(LIBSODIUM_CFLAGS)
 | 
			
		||||
 | 
			
		||||
Messenger_test_LDADD =  $(LIBSODIUM_LDFLAGS) \
 | 
			
		||||
                        $(NACL_LDFLAGS) \
 | 
			
		||||
                        libmisc_tools.la \
 | 
			
		||||
                        libtoxcore.la \
 | 
			
		||||
                        $(LIBSODIUM_LIBS) \
 | 
			
		||||
                        $(NACL_OBJECTS) \
 | 
			
		||||
                        $(NACL_LIBS) \
 | 
			
		||||
                        $(WINSOCK2_LIBS)
 | 
			
		||||
 | 
			
		||||
endif
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@
 | 
			
		||||
 * If it receives a message from a friend it replies back.
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * This is how I compile it: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../core/DHT.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/{cpucycles.o,libnacl.a,randombytes.o} Messenger_test.c
 | 
			
		||||
 * This is how I compile it: gcc -O2 -Wall -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../core/DHT.c Messenger_test.c -lsodium
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * Command line arguments are the ip, port and public_key of a node (for bootstrapping).
 | 
			
		||||
 
 | 
			
		||||
@@ -13,14 +13,14 @@ endif()
 | 
			
		||||
 | 
			
		||||
# Fuzzes the toxsave API
 | 
			
		||||
add_executable(toxsave_fuzzer toxsave_harness.cc)
 | 
			
		||||
target_link_libraries(toxsave_fuzzer toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
target_link_libraries(toxsave_fuzzer PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
 | 
			
		||||
# Fuzzes the bootstrap process
 | 
			
		||||
add_executable(bootstrap_fuzzer bootstrap_harness.cc)
 | 
			
		||||
target_link_libraries(bootstrap_fuzzer toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
target_link_libraries(bootstrap_fuzzer PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
 | 
			
		||||
add_executable(DHT_fuzz_test ../../toxcore/DHT_fuzz_test.cc)
 | 
			
		||||
target_link_libraries(DHT_fuzz_test toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
target_link_libraries(DHT_fuzz_test PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
 | 
			
		||||
add_executable(tox_events_fuzz_test ../../toxcore/tox_events_fuzz_test.cc)
 | 
			
		||||
target_link_libraries(tox_events_fuzz_test toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
target_link_libraries(tox_events_fuzz_test PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								external/toxcore/c-toxcore/testing/misc_tools.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								external/toxcore/c-toxcore/testing/misc_tools.c
									
									
									
									
										vendored
									
									
								
							@@ -20,9 +20,7 @@
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
#include <sodium.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
@@ -141,7 +139,6 @@ int cmdline_parsefor_ipv46(int argc, char **argv, bool *ipv6enabled)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef VANILLA_NACL
 | 
			
		||||
static const char *test_rng_name(void)
 | 
			
		||||
{
 | 
			
		||||
    return "test_rng";
 | 
			
		||||
@@ -198,11 +195,3 @@ int use_test_rng(uint32_t seed)
 | 
			
		||||
 | 
			
		||||
    return randombytes_set_implementation(&test_rng);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
int use_test_rng(uint32_t seed)
 | 
			
		||||
{
 | 
			
		||||
    assert(!"libsodium required for use_test_rng");
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -7,3 +7,9 @@ cc_library(
 | 
			
		||||
    copts = ["-DCMP_NO_FLOAT"],
 | 
			
		||||
    visibility = ["//c-toxcore:__subpackages__"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "headers",
 | 
			
		||||
    srcs = ["cmp/cmp.h"],
 | 
			
		||||
    visibility = ["//c-toxcore:__subpackages__"],
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
@@ -25,19 +25,16 @@ libtoxav_la_SOURCES = ../toxav/rtp.h \
 | 
			
		||||
libtoxav_la_CFLAGS = -I../toxcore \
 | 
			
		||||
                    -I../toxav \
 | 
			
		||||
                    $(LIBSODIUM_CFLAGS) \
 | 
			
		||||
                    $(NACL_CFLAGS) \
 | 
			
		||||
                    $(AV_CFLAGS) \
 | 
			
		||||
                    $(PTHREAD_CFLAGS)
 | 
			
		||||
 | 
			
		||||
libtoxav_la_LDFLAGS = $(LT_LDFLAGS) \
 | 
			
		||||
                    $(LIBSODIUM_LDFLAGS) \
 | 
			
		||||
                    $(NACL_LDFLAGS) \
 | 
			
		||||
                    $(EXTRA_LT_LDFLAGS) \
 | 
			
		||||
                    $(WINSOCK2_LIBS)
 | 
			
		||||
 | 
			
		||||
libtoxav_la_LIBADD =  libtoxcore.la \
 | 
			
		||||
                    $(LIBSODIUM_LIBS) \
 | 
			
		||||
                    $(NACL_LIBS) \
 | 
			
		||||
                    $(PTHREAD_LIBS) \
 | 
			
		||||
                    $(AV_LIBS)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								external/toxcore/c-toxcore/toxav/groupav.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								external/toxcore/c-toxcore/toxav/groupav.c
									
									
									
									
										vendored
									
									
								
							@@ -434,7 +434,7 @@ static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    while (decode_audio_packet((Group_AV *)object, peer_av, groupnumber, friendgroupnumber) == 0) {
 | 
			
		||||
        continue;
 | 
			
		||||
        /* Continue. */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
@@ -612,7 +612,7 @@ static int send_audio_packet(const Group_Chats *g_c, uint32_t groupnumber, const
 | 
			
		||||
 * @retval 0 on success.
 | 
			
		||||
 * @retval -1 on failure.
 | 
			
		||||
 */
 | 
			
		||||
int group_send_audio(Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
 | 
			
		||||
int group_send_audio(const Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
 | 
			
		||||
                     uint32_t sample_rate)
 | 
			
		||||
{
 | 
			
		||||
    Group_AV *group_av = (Group_AV *)group_get_object(g_c, groupnumber);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								external/toxcore/c-toxcore/toxav/groupav.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/toxcore/c-toxcore/toxav/groupav.h
									
									
									
									
										vendored
									
									
								
							@@ -40,7 +40,7 @@ int join_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t fr
 | 
			
		||||
 * @retval 0 on success.
 | 
			
		||||
 * @retval -1 on failure.
 | 
			
		||||
 */
 | 
			
		||||
int group_send_audio(Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
 | 
			
		||||
int group_send_audio(const Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
 | 
			
		||||
                     uint32_t sample_rate);
 | 
			
		||||
 | 
			
		||||
/** @brief Enable A/V in a groupchat.
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user