Compare commits
18 Commits
613ae14530
...
master
Author | SHA1 | Date | |
---|---|---|---|
3567aba4db | |||
9b07cb4dce | |||
c89bba25a3 | |||
f9bc83811c | |||
5c4bb1aa42 | |||
2a143a4c2e | |||
3072d2936e | |||
7458841417 | |||
2b3ee3316a | |||
622c9d9d96 | |||
caa913fa51 | |||
261c487cf2 | |||
086fc52e92 | |||
cd6141ee00 | |||
5fa8dc712a | |||
e0d4c4d1e1 | |||
de247c9e91 | |||
20c41e1a02 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
github: Green-Sky
|
43
.github/workflows/cd.yml
vendored
Normal file
43
.github/workflows/cd.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: ContinuousDelivery
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
timeout-minutes: 15
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
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
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ github.event.repository.name }}-windows-msvc-x86_64
|
||||
# TODO: do propper packing
|
||||
path: |
|
||||
${{github.workspace}}/build/bin/
|
||||
|
@ -36,7 +36,7 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL
|
||||
)
|
||||
|
||||
if (NOT WIN32)
|
||||
link_libraries(-fsanitize=address,undefined)
|
||||
#link_libraries(-fsanitize=address,undefined)
|
||||
#link_libraries(-fsanitize=undefined)
|
||||
endif()
|
||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||
|
@ -13,7 +13,7 @@ this will print this tools tox_id and the generated info_hash
|
||||
|
||||
this will first download the info using the info_hash and then all the file chunks listed in the info
|
||||
while simultaneously resharing allready downloaded chunks and info (swarming)
|
||||
to increase the amount of parallel chunk down/up loads, you can increase the value with the -I and -O option. the default for -I is 32 and for -O 16, which are relatively low numbers, which in practice can get you up to ~400KiB/s.
|
||||
to increase the amount of parallel chunk down/up loads, you can increase the value with the -I and -O option. the default for -I is 32 and for -O 16, which are relatively low numbers, which in practice can get you up to ~700KiB/s.
|
||||
|
||||
## Usage
|
||||
|
||||
@ -54,9 +54,7 @@ $ tox_ngc_ft1_tool
|
||||
FT1:
|
||||
--ft_ack_per_packet
|
||||
--ft_init_retry_timeout_after
|
||||
--ft_sending_resend_without_ack_after
|
||||
--ft_sending_give_up_after
|
||||
--ft_packet_window_size
|
||||
|
||||
transfer logic:
|
||||
-I <max_incoming_transfers>
|
||||
|
2
external/tox_ngc_ext/tox_ngc_ext
vendored
2
external/tox_ngc_ext/tox_ngc_ext
vendored
Submodule external/tox_ngc_ext/tox_ngc_ext updated: 2b186a3071...026bf080c3
3
external/tox_ngc_ft1/CMakeLists.txt
vendored
3
external/tox_ngc_ft1/CMakeLists.txt
vendored
@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
add_library(tox_ngc_ft1 STATIC
|
||||
./tox_ngc_ft1/ngc_ft1.h
|
||||
./tox_ngc_ft1/ngc_ft1.cpp
|
||||
|
||||
./tox_ngc_ft1/ledbat.hpp
|
||||
./tox_ngc_ft1/ledbat.cpp
|
||||
)
|
||||
|
||||
target_include_directories(tox_ngc_ft1 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/tox_ngc_ft1")
|
||||
|
2
external/tox_ngc_ft1/tox_ngc_ft1
vendored
2
external/tox_ngc_ft1/tox_ngc_ft1
vendored
Submodule external/tox_ngc_ft1/tox_ngc_ft1 updated: a7b5c31369...08a083f346
194
external/toxcore/CMakeLists.txt
vendored
194
external/toxcore/CMakeLists.txt
vendored
@ -2,6 +2,198 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
include(./toxcore.cmake)
|
||||
set(TOX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/c-toxcore/")
|
||||
|
||||
# TODO: shared
|
||||
add_library(toxcore STATIC
|
||||
${TOX_DIR}third_party/cmp/cmp.c
|
||||
${TOX_DIR}third_party/cmp/cmp.h
|
||||
|
||||
${TOX_DIR}toxcore/announce.c
|
||||
${TOX_DIR}toxcore/announce.h
|
||||
${TOX_DIR}toxcore/bin_pack.c
|
||||
${TOX_DIR}toxcore/bin_pack.h
|
||||
${TOX_DIR}toxcore/bin_unpack.c
|
||||
${TOX_DIR}toxcore/bin_unpack.h
|
||||
${TOX_DIR}toxcore/ccompat.c
|
||||
${TOX_DIR}toxcore/ccompat.h
|
||||
${TOX_DIR}toxcore/crypto_core.c
|
||||
${TOX_DIR}toxcore/crypto_core.h
|
||||
${TOX_DIR}toxcore/DHT.c
|
||||
${TOX_DIR}toxcore/DHT.h
|
||||
${TOX_DIR}toxcore/events/conference_connected.c
|
||||
${TOX_DIR}toxcore/events/conference_invite.c
|
||||
${TOX_DIR}toxcore/events/conference_message.c
|
||||
${TOX_DIR}toxcore/events/conference_peer_list_changed.c
|
||||
${TOX_DIR}toxcore/events/conference_peer_name.c
|
||||
${TOX_DIR}toxcore/events/conference_title.c
|
||||
${TOX_DIR}toxcore/events/events_alloc.c
|
||||
${TOX_DIR}toxcore/events/events_alloc.h
|
||||
${TOX_DIR}toxcore/events/file_chunk_request.c
|
||||
${TOX_DIR}toxcore/events/file_recv.c
|
||||
${TOX_DIR}toxcore/events/file_recv_chunk.c
|
||||
${TOX_DIR}toxcore/events/file_recv_control.c
|
||||
${TOX_DIR}toxcore/events/friend_connection_status.c
|
||||
${TOX_DIR}toxcore/events/friend_lossless_packet.c
|
||||
${TOX_DIR}toxcore/events/friend_lossy_packet.c
|
||||
${TOX_DIR}toxcore/events/friend_message.c
|
||||
${TOX_DIR}toxcore/events/friend_name.c
|
||||
${TOX_DIR}toxcore/events/friend_read_receipt.c
|
||||
${TOX_DIR}toxcore/events/friend_request.c
|
||||
${TOX_DIR}toxcore/events/friend_status.c
|
||||
${TOX_DIR}toxcore/events/friend_status_message.c
|
||||
${TOX_DIR}toxcore/events/friend_typing.c
|
||||
${TOX_DIR}toxcore/events/self_connection_status.c
|
||||
#${TOX_DIR}toxcore/events/group_custom_packet.c
|
||||
#${TOX_DIR}toxcore/events/group_custom_private_packet.c
|
||||
#${TOX_DIR}toxcore/events/group_invite.c
|
||||
#${TOX_DIR}toxcore/events/group_join_fail.c
|
||||
#${TOX_DIR}toxcore/events/group_message.c
|
||||
#${TOX_DIR}toxcore/events/group_moderation.c
|
||||
#${TOX_DIR}toxcore/events/group_password.c
|
||||
#${TOX_DIR}toxcore/events/group_peer_exit.c
|
||||
#${TOX_DIR}toxcore/events/group_peer_join.c
|
||||
#${TOX_DIR}toxcore/events/group_peer_limit.c
|
||||
#${TOX_DIR}toxcore/events/group_peer_name.c
|
||||
#${TOX_DIR}toxcore/events/group_peer_status.c
|
||||
#${TOX_DIR}toxcore/events/group_privacy_state.c
|
||||
#${TOX_DIR}toxcore/events/group_private_message.c
|
||||
#${TOX_DIR}toxcore/events/group_self_join.c
|
||||
#${TOX_DIR}toxcore/events/group_topic.c
|
||||
#${TOX_DIR}toxcore/events/group_topic_lock.c
|
||||
#${TOX_DIR}toxcore/events/group_voice_state.c
|
||||
${TOX_DIR}toxcore/forwarding.c
|
||||
${TOX_DIR}toxcore/forwarding.h
|
||||
${TOX_DIR}toxcore/friend_connection.c
|
||||
${TOX_DIR}toxcore/friend_connection.h
|
||||
${TOX_DIR}toxcore/friend_requests.c
|
||||
${TOX_DIR}toxcore/friend_requests.h
|
||||
${TOX_DIR}toxcore/group.c
|
||||
${TOX_DIR}toxcore/group.h
|
||||
${TOX_DIR}toxcore/group_announce.c
|
||||
${TOX_DIR}toxcore/group_announce.h
|
||||
${TOX_DIR}toxcore/group_moderation.c
|
||||
${TOX_DIR}toxcore/group_moderation.h
|
||||
${TOX_DIR}toxcore/group_chats.c
|
||||
${TOX_DIR}toxcore/group_chats.h
|
||||
${TOX_DIR}toxcore/group_common.h
|
||||
${TOX_DIR}toxcore/group_connection.c
|
||||
${TOX_DIR}toxcore/group_connection.h
|
||||
${TOX_DIR}toxcore/group_onion_announce.c
|
||||
${TOX_DIR}toxcore/group_onion_announce.h
|
||||
${TOX_DIR}toxcore/group_pack.c
|
||||
${TOX_DIR}toxcore/group_pack.h
|
||||
${TOX_DIR}toxcore/LAN_discovery.c
|
||||
${TOX_DIR}toxcore/LAN_discovery.h
|
||||
${TOX_DIR}toxcore/list.c
|
||||
${TOX_DIR}toxcore/list.h
|
||||
${TOX_DIR}toxcore/logger.c
|
||||
${TOX_DIR}toxcore/logger.h
|
||||
${TOX_DIR}toxcore/Messenger.c
|
||||
${TOX_DIR}toxcore/Messenger.h
|
||||
${TOX_DIR}toxcore/mem.c
|
||||
${TOX_DIR}toxcore/mem.h
|
||||
${TOX_DIR}toxcore/mono_time.c
|
||||
${TOX_DIR}toxcore/mono_time.h
|
||||
${TOX_DIR}toxcore/net_crypto.c
|
||||
${TOX_DIR}toxcore/net_crypto.h
|
||||
${TOX_DIR}toxcore/network.c
|
||||
${TOX_DIR}toxcore/network.h
|
||||
${TOX_DIR}toxcore/onion_announce.c
|
||||
${TOX_DIR}toxcore/onion_announce.h
|
||||
${TOX_DIR}toxcore/onion.c
|
||||
${TOX_DIR}toxcore/onion_client.c
|
||||
${TOX_DIR}toxcore/onion_client.h
|
||||
${TOX_DIR}toxcore/onion.h
|
||||
${TOX_DIR}toxcore/ping_array.c
|
||||
${TOX_DIR}toxcore/ping_array.h
|
||||
${TOX_DIR}toxcore/ping.c
|
||||
${TOX_DIR}toxcore/ping.h
|
||||
${TOX_DIR}toxcore/shared_key_cache.c
|
||||
${TOX_DIR}toxcore/shared_key_cache.h
|
||||
${TOX_DIR}toxcore/state.c
|
||||
${TOX_DIR}toxcore/state.h
|
||||
${TOX_DIR}toxcore/TCP_client.c
|
||||
${TOX_DIR}toxcore/TCP_client.h
|
||||
${TOX_DIR}toxcore/TCP_common.c
|
||||
${TOX_DIR}toxcore/TCP_common.h
|
||||
${TOX_DIR}toxcore/TCP_connection.c
|
||||
${TOX_DIR}toxcore/TCP_connection.h
|
||||
${TOX_DIR}toxcore/TCP_server.c
|
||||
${TOX_DIR}toxcore/TCP_server.h
|
||||
${TOX_DIR}toxcore/timed_auth.c
|
||||
${TOX_DIR}toxcore/timed_auth.h
|
||||
${TOX_DIR}toxcore/tox_api.c
|
||||
${TOX_DIR}toxcore/tox.c
|
||||
${TOX_DIR}toxcore/tox_dispatch.c
|
||||
${TOX_DIR}toxcore/tox_dispatch.h
|
||||
${TOX_DIR}toxcore/tox_events.c
|
||||
${TOX_DIR}toxcore/tox_events.h
|
||||
${TOX_DIR}toxcore/tox.h
|
||||
${TOX_DIR}toxcore/tox_private.c
|
||||
${TOX_DIR}toxcore/tox_private.h
|
||||
${TOX_DIR}toxcore/tox_unpack.c
|
||||
${TOX_DIR}toxcore/tox_unpack.h
|
||||
${TOX_DIR}toxcore/util.c
|
||||
${TOX_DIR}toxcore/util.h
|
||||
)
|
||||
|
||||
# HACK: "install" api headers into self
|
||||
# this is dirty, should be binary dir
|
||||
# TODO: add the others
|
||||
configure_file(
|
||||
${TOX_DIR}toxcore/tox.h
|
||||
${TOX_DIR}tox/tox.h
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${TOX_DIR}toxcore/tox_events.h
|
||||
${TOX_DIR}tox/tox_events.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore")
|
||||
target_include_directories(toxcore PUBLIC "${TOX_DIR}")
|
||||
|
||||
target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
|
||||
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG)
|
||||
target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_INFO)
|
||||
|
||||
find_package(unofficial-sodium CONFIG QUIET)
|
||||
find_package(sodium QUIET)
|
||||
if(unofficial-sodium_FOUND) # vcpkg
|
||||
if(TARGET unofficial-sodium::sodium)
|
||||
target_link_libraries(toxcore unofficial-sodium::sodium)
|
||||
endif()
|
||||
if(TARGET unofficial-sodium::sodium_config_public)
|
||||
target_link_libraries(toxcore unofficial-sodium::sodium_config_public)
|
||||
endif()
|
||||
elseif(sodium_FOUND)
|
||||
target_link_libraries(toxcore sodium)
|
||||
else()
|
||||
message(SEND_ERROR "missing libsodium")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(toxcore ws2_32 iphlpapi)
|
||||
endif()
|
||||
|
||||
find_package(pthreads QUIET)
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
target_link_libraries(toxcore PThreads4W::PThreads4W)
|
||||
else()
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(toxcore Threads::Threads)
|
||||
endif()
|
||||
|
||||
add_executable(DHT_Bootstrap EXCLUDE_FROM_ALL
|
||||
${TOX_DIR}other/DHT_bootstrap.c
|
||||
${TOX_DIR}other/bootstrap_node_packets.h
|
||||
${TOX_DIR}other/bootstrap_node_packets.c
|
||||
${TOX_DIR}testing/misc_tools.h
|
||||
${TOX_DIR}testing/misc_tools.c
|
||||
)
|
||||
|
||||
target_link_libraries(DHT_Bootstrap toxcore)
|
||||
|
||||
|
2
external/toxcore/c-toxcore
vendored
2
external/toxcore/c-toxcore
vendored
Submodule external/toxcore/c-toxcore updated: 63f993a331...24b54722ae
159
external/toxcore/toxcore.cmake
vendored
159
external/toxcore/toxcore.cmake
vendored
@ -1,159 +0,0 @@
|
||||
set(TOX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/c-toxcore/")
|
||||
|
||||
# TODO: shared
|
||||
add_library(toxcore STATIC
|
||||
${TOX_DIR}third_party/cmp/cmp.c
|
||||
${TOX_DIR}third_party/cmp/cmp.h
|
||||
|
||||
${TOX_DIR}toxcore/announce.c
|
||||
${TOX_DIR}toxcore/announce.h
|
||||
${TOX_DIR}toxcore/bin_pack.c
|
||||
${TOX_DIR}toxcore/bin_pack.h
|
||||
${TOX_DIR}toxcore/bin_unpack.c
|
||||
${TOX_DIR}toxcore/bin_unpack.h
|
||||
${TOX_DIR}toxcore/ccompat.c
|
||||
${TOX_DIR}toxcore/ccompat.h
|
||||
${TOX_DIR}toxcore/crypto_core.c
|
||||
${TOX_DIR}toxcore/crypto_core.h
|
||||
${TOX_DIR}toxcore/DHT.c
|
||||
${TOX_DIR}toxcore/DHT.h
|
||||
${TOX_DIR}toxcore/events/conference_connected.c
|
||||
${TOX_DIR}toxcore/events/conference_invite.c
|
||||
${TOX_DIR}toxcore/events/conference_message.c
|
||||
${TOX_DIR}toxcore/events/conference_peer_list_changed.c
|
||||
${TOX_DIR}toxcore/events/conference_peer_name.c
|
||||
${TOX_DIR}toxcore/events/conference_title.c
|
||||
${TOX_DIR}toxcore/events/events_alloc.c
|
||||
${TOX_DIR}toxcore/events/events_alloc.h
|
||||
${TOX_DIR}toxcore/events/file_chunk_request.c
|
||||
${TOX_DIR}toxcore/events/file_recv.c
|
||||
${TOX_DIR}toxcore/events/file_recv_chunk.c
|
||||
${TOX_DIR}toxcore/events/file_recv_control.c
|
||||
${TOX_DIR}toxcore/events/friend_connection_status.c
|
||||
${TOX_DIR}toxcore/events/friend_lossless_packet.c
|
||||
${TOX_DIR}toxcore/events/friend_lossy_packet.c
|
||||
${TOX_DIR}toxcore/events/friend_message.c
|
||||
${TOX_DIR}toxcore/events/friend_name.c
|
||||
${TOX_DIR}toxcore/events/friend_read_receipt.c
|
||||
${TOX_DIR}toxcore/events/friend_request.c
|
||||
${TOX_DIR}toxcore/events/friend_status.c
|
||||
${TOX_DIR}toxcore/events/friend_status_message.c
|
||||
${TOX_DIR}toxcore/events/friend_typing.c
|
||||
${TOX_DIR}toxcore/events/self_connection_status.c
|
||||
${TOX_DIR}toxcore/forwarding.c
|
||||
${TOX_DIR}toxcore/forwarding.h
|
||||
${TOX_DIR}toxcore/friend_connection.c
|
||||
${TOX_DIR}toxcore/friend_connection.h
|
||||
${TOX_DIR}toxcore/friend_requests.c
|
||||
${TOX_DIR}toxcore/friend_requests.h
|
||||
${TOX_DIR}toxcore/group.c
|
||||
${TOX_DIR}toxcore/group.h
|
||||
${TOX_DIR}toxcore/group_announce.c
|
||||
${TOX_DIR}toxcore/group_announce.h
|
||||
${TOX_DIR}toxcore/group_moderation.c
|
||||
${TOX_DIR}toxcore/group_moderation.h
|
||||
${TOX_DIR}toxcore/group_chats.c
|
||||
${TOX_DIR}toxcore/group_chats.h
|
||||
${TOX_DIR}toxcore/group_common.h
|
||||
${TOX_DIR}toxcore/group_connection.c
|
||||
${TOX_DIR}toxcore/group_connection.h
|
||||
${TOX_DIR}toxcore/group_onion_announce.c
|
||||
${TOX_DIR}toxcore/group_onion_announce.h
|
||||
${TOX_DIR}toxcore/group_pack.c
|
||||
${TOX_DIR}toxcore/group_pack.h
|
||||
${TOX_DIR}toxcore/LAN_discovery.c
|
||||
${TOX_DIR}toxcore/LAN_discovery.h
|
||||
${TOX_DIR}toxcore/list.c
|
||||
${TOX_DIR}toxcore/list.h
|
||||
${TOX_DIR}toxcore/logger.c
|
||||
${TOX_DIR}toxcore/logger.h
|
||||
${TOX_DIR}toxcore/Messenger.c
|
||||
${TOX_DIR}toxcore/Messenger.h
|
||||
${TOX_DIR}toxcore/mono_time.c
|
||||
${TOX_DIR}toxcore/mono_time.h
|
||||
${TOX_DIR}toxcore/net_crypto.c
|
||||
${TOX_DIR}toxcore/net_crypto.h
|
||||
${TOX_DIR}toxcore/network.c
|
||||
${TOX_DIR}toxcore/network.h
|
||||
${TOX_DIR}toxcore/onion_announce.c
|
||||
${TOX_DIR}toxcore/onion_announce.h
|
||||
${TOX_DIR}toxcore/onion.c
|
||||
${TOX_DIR}toxcore/onion_client.c
|
||||
${TOX_DIR}toxcore/onion_client.h
|
||||
${TOX_DIR}toxcore/onion.h
|
||||
${TOX_DIR}toxcore/ping_array.c
|
||||
${TOX_DIR}toxcore/ping_array.h
|
||||
${TOX_DIR}toxcore/ping.c
|
||||
${TOX_DIR}toxcore/ping.h
|
||||
${TOX_DIR}toxcore/shared_key_cache.c
|
||||
${TOX_DIR}toxcore/shared_key_cache.h
|
||||
${TOX_DIR}toxcore/state.c
|
||||
${TOX_DIR}toxcore/state.h
|
||||
${TOX_DIR}toxcore/TCP_client.c
|
||||
${TOX_DIR}toxcore/TCP_client.h
|
||||
${TOX_DIR}toxcore/TCP_common.c
|
||||
${TOX_DIR}toxcore/TCP_common.h
|
||||
${TOX_DIR}toxcore/TCP_connection.c
|
||||
${TOX_DIR}toxcore/TCP_connection.h
|
||||
${TOX_DIR}toxcore/TCP_server.c
|
||||
${TOX_DIR}toxcore/TCP_server.h
|
||||
${TOX_DIR}toxcore/timed_auth.c
|
||||
${TOX_DIR}toxcore/timed_auth.h
|
||||
${TOX_DIR}toxcore/tox_api.c
|
||||
${TOX_DIR}toxcore/tox.c
|
||||
${TOX_DIR}toxcore/tox_dispatch.c
|
||||
${TOX_DIR}toxcore/tox_dispatch.h
|
||||
${TOX_DIR}toxcore/tox_events.c
|
||||
${TOX_DIR}toxcore/tox_events.h
|
||||
${TOX_DIR}toxcore/tox.h
|
||||
${TOX_DIR}toxcore/tox_private.c
|
||||
${TOX_DIR}toxcore/tox_private.h
|
||||
${TOX_DIR}toxcore/tox_unpack.c
|
||||
${TOX_DIR}toxcore/tox_unpack.h
|
||||
${TOX_DIR}toxcore/util.c
|
||||
${TOX_DIR}toxcore/util.h
|
||||
)
|
||||
|
||||
# HACK: "install" api headers into self
|
||||
# this is dirty, should be binary dir
|
||||
# TODO: add the others
|
||||
configure_file(
|
||||
${TOX_DIR}toxcore/tox.h
|
||||
${TOX_DIR}tox/tox.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore")
|
||||
target_include_directories(toxcore PUBLIC "${TOX_DIR}")
|
||||
|
||||
target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
|
||||
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG)
|
||||
target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_INFO)
|
||||
|
||||
find_package(unofficial-sodium CONFIG QUIET)
|
||||
find_package(sodium QUIET)
|
||||
if(unofficial-sodium_FOUND) # vcpkg
|
||||
target_link_libraries(toxcore unofficial-sodium::sodium unofficial-sodium::sodium_config_public)
|
||||
elseif(sodium_FOUND)
|
||||
target_link_libraries(toxcore sodium)
|
||||
else()
|
||||
message(SEND_ERROR "missing libsodium")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(toxcore ws2_32 iphlpapi)
|
||||
endif()
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(toxcore Threads::Threads)
|
||||
|
||||
add_executable(DHT_Bootstrap EXCLUDE_FROM_ALL
|
||||
${TOX_DIR}other/DHT_bootstrap.c
|
||||
${TOX_DIR}other/bootstrap_node_packets.h
|
||||
${TOX_DIR}other/bootstrap_node_packets.c
|
||||
${TOX_DIR}testing/misc_tools.h
|
||||
${TOX_DIR}testing/misc_tools.c
|
||||
)
|
||||
|
||||
target_link_libraries(DHT_Bootstrap toxcore)
|
||||
|
@ -119,9 +119,7 @@ CommandLine::CommandLine(int argc, char** argv) {
|
||||
std::cout << "CL set tox_port to " << tox_port << "\n";
|
||||
} else if (parser.parseParam("--ft_ack_per_packet", ft_acks_per_packet)) {
|
||||
} else if (parser.parseParam("--ft_init_retry_timeout_after", ft_init_retry_timeout_after)) {
|
||||
} else if (parser.parseParam("--ft_sending_resend_without_ack_after", ft_sending_resend_without_ack_after)) {
|
||||
} else if (parser.parseParam("--ft_sending_give_up_after", ft_sending_give_up_after)) {
|
||||
} else if (parser.parseParam("--ft_packet_window_size", ft_packet_window_size)) {
|
||||
} else if (parser.parseParam("-I", max_incoming_transfers)) {
|
||||
} else if (parser.parseParam("-O", max_outgoing_transfers)) {
|
||||
} else {
|
||||
@ -177,9 +175,7 @@ void CommandLine::printHelp(void) {
|
||||
<< " FT1:\n"
|
||||
<< " --ft_ack_per_packet\n"
|
||||
<< " --ft_init_retry_timeout_after\n"
|
||||
<< " --ft_sending_resend_without_ack_after\n"
|
||||
<< " --ft_sending_give_up_after\n"
|
||||
<< " --ft_packet_window_size\n"
|
||||
<< "\n"
|
||||
<< " transfer logic:\n"
|
||||
<< " -I <max_incoming_transfers>\n"
|
||||
|
@ -57,15 +57,11 @@ struct CommandLine {
|
||||
|
||||
// advanced FT1:
|
||||
// --ft_ack_per_packet
|
||||
size_t ft_acks_per_packet {5};
|
||||
size_t ft_acks_per_packet {3};
|
||||
// --ft_init_retry_timeout_after
|
||||
float ft_init_retry_timeout_after {10.f};
|
||||
// --ft_sending_resend_without_ack_after
|
||||
float ft_sending_resend_without_ack_after {5.f};
|
||||
float ft_init_retry_timeout_after {5.f};
|
||||
// --ft_sending_give_up_after
|
||||
float ft_sending_give_up_after {30.f};
|
||||
// --ft_packet_window_size
|
||||
size_t ft_packet_window_size {5};
|
||||
|
||||
// ---- TODO ----
|
||||
|
||||
@ -73,7 +69,7 @@ struct CommandLine {
|
||||
// -I max_incoming_transfers
|
||||
size_t max_incoming_transfers {32};
|
||||
// -O max_outgoing_transfers
|
||||
size_t max_outgoing_transfers {16};
|
||||
size_t max_outgoing_transfers {8};
|
||||
// -u request chunks only from UDP-direct peers
|
||||
bool request_only_from_udp_peer {false};
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
// returns the 20bytes sha1 hash
|
||||
|
@ -47,22 +47,25 @@ bool ReceiveStartSHA1::iterate(float delta) {
|
||||
}
|
||||
} else if (_time_since_last_request >= 15.f) { // blast ever 15sec
|
||||
_time_since_last_request = 0.f;
|
||||
// TODO: select random and try, not blas
|
||||
// ... and we are blasing
|
||||
|
||||
_tcl.forEachGroup([this](const uint32_t group_number) {
|
||||
_tcl.forEachGroupPeer(group_number, [this, group_number](uint32_t peer_number, Tox_Connection connection_status) {
|
||||
_tcl.forEachGroupPeer(group_number, [this, group_number](uint32_t peer_number) {
|
||||
_tcl.sendFT1RequestPrivate(
|
||||
group_number, peer_number,
|
||||
NGC_FT1_file_kind::HASH_SHA1_INFO,
|
||||
_sha1_info_hash.data.data(), _sha1_info_hash.size()
|
||||
);
|
||||
std::cout << "ReceiveStartSHA1 sendig info request to " << group_number << ":" << peer_number << " over " << (connection_status == Tox_Connection::TOX_CONNECTION_TCP ? "tcp" : "udp") <<"\n";
|
||||
std::cout
|
||||
<< "ReceiveStartSHA1 sendig info request to "
|
||||
<< group_number << ":" << peer_number
|
||||
<< " over " << (_tcl.getGroupPeerConnectionStatus(group_number, peer_number) == Tox_Connection::TOX_CONNECTION_TCP ? "tcp" : "udp")
|
||||
<< "\n"
|
||||
;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// if not transfer, request from random peer (equal dist!!)
|
||||
// TODO: return true if done
|
||||
return _done;
|
||||
}
|
||||
|
||||
@ -173,10 +176,10 @@ void ReceiveStartSHA1::onFT1ReceiveDataSHA1Info(uint32_t group_number, uint32_t
|
||||
std::cerr << "ReceiveStartSHA1 received info's hash does not match!, discarding\n";
|
||||
_transfer.reset();
|
||||
_sha1_info_data.clear();
|
||||
} else {
|
||||
std::cout << "ReceiveStartSHA1 info tansfer finished " << group_number << ":" << peer_number << "." << int(transfer_id) << "\n";
|
||||
_done = true;
|
||||
}
|
||||
|
||||
std::cout << "ReceiveStartSHA1 info tansfer finished " << group_number << ":" << peer_number << "." << int(transfer_id) << "\n";
|
||||
_done = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,9 @@ SHA1::SHA1(
|
||||
{
|
||||
assert(_have_chunk.size() == _sha1_info.chunks.size());
|
||||
|
||||
_udp_only = cl.request_only_from_udp_peer;
|
||||
_max_concurrent_in = cl.max_incoming_transfers;
|
||||
_max_concurrent_out = cl.max_incoming_transfers;
|
||||
_max_concurrent_out = cl.max_outgoing_transfers;
|
||||
|
||||
// build lookup table
|
||||
for (size_t i = _sha1_info.chunks.size(); i > 0; i--) {
|
||||
@ -144,46 +145,54 @@ bool SHA1::iterate(float delta) {
|
||||
// send init to _queue_requested_info
|
||||
const auto [group_number, peer_number] = _queue_requested_info.front();
|
||||
|
||||
uint8_t transfer_id {0};
|
||||
if (_tcl.getGroupPeerConnectionStatus(group_number, peer_number) != TOX_CONNECTION_NONE) {
|
||||
uint8_t transfer_id {0};
|
||||
|
||||
if (_tcl.sendFT1InitPrivate(
|
||||
group_number, peer_number,
|
||||
NGC_FT1_file_kind::HASH_SHA1_INFO,
|
||||
_sha1_info_hash.data.data(), _sha1_info_hash.size(), // id (info hash)
|
||||
_sha1_info_data.size(), // "file_size"
|
||||
transfer_id
|
||||
)) {
|
||||
_transfers_requested_info.push_back({
|
||||
if (_tcl.sendFT1InitPrivate(
|
||||
group_number, peer_number,
|
||||
transfer_id,
|
||||
0.f
|
||||
});
|
||||
NGC_FT1_file_kind::HASH_SHA1_INFO,
|
||||
_sha1_info_hash.data.data(), _sha1_info_hash.size(), // id (info hash)
|
||||
_sha1_info_data.size(), // "file_size"
|
||||
transfer_id
|
||||
)) {
|
||||
_transfers_requested_info.push_back({
|
||||
group_number, peer_number,
|
||||
transfer_id,
|
||||
0.f
|
||||
});
|
||||
|
||||
_queue_requested_info.pop_front();
|
||||
_queue_requested_info.pop_front();
|
||||
}
|
||||
}
|
||||
} else if (!_queue_requested_chunk.empty()) { // then check for chunk requests
|
||||
const auto [group_number, peer_number, chunk_hash, _] = _queue_requested_chunk.front();
|
||||
|
||||
size_t chunk_index = chunkIndex(chunk_hash).value();
|
||||
size_t chunk_file_size = chunkSize(chunk_index);
|
||||
if (_tcl.getGroupPeerConnectionStatus(group_number, peer_number) != TOX_CONNECTION_NONE) {
|
||||
if (!chunkIndex(chunk_hash).has_value()) {
|
||||
std::cerr << "!chunkIndex(chunk_hash).has_value()\n";
|
||||
exit(1);
|
||||
}
|
||||
size_t chunk_index = chunkIndex(chunk_hash).value();
|
||||
size_t chunk_file_size = chunkSize(chunk_index);
|
||||
|
||||
uint8_t transfer_id {0};
|
||||
uint8_t transfer_id {0};
|
||||
|
||||
if (_tcl.sendFT1InitPrivate(
|
||||
group_number, peer_number,
|
||||
NGC_FT1_file_kind::HASH_SHA1_CHUNK,
|
||||
chunk_hash.data.data(), chunk_hash.size(), // id (chunk hash)
|
||||
chunk_file_size,
|
||||
transfer_id
|
||||
)) {
|
||||
_transfers_sending_chunk.push_back({
|
||||
if (_tcl.sendFT1InitPrivate(
|
||||
group_number, peer_number,
|
||||
transfer_id,
|
||||
0.f,
|
||||
chunk_index
|
||||
});
|
||||
NGC_FT1_file_kind::HASH_SHA1_CHUNK,
|
||||
chunk_hash.data.data(), chunk_hash.size(), // id (chunk hash)
|
||||
chunk_file_size,
|
||||
transfer_id
|
||||
)) {
|
||||
_transfers_sending_chunk.push_back({
|
||||
group_number, peer_number,
|
||||
transfer_id,
|
||||
0.f,
|
||||
chunk_index
|
||||
});
|
||||
|
||||
_queue_requested_chunk.pop_front();
|
||||
_queue_requested_chunk.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,12 +203,21 @@ bool SHA1::iterate(float delta) {
|
||||
_peer_speed_mesurement_interval_timer = 0.f; // we lose some time here, but precision is not the issue
|
||||
|
||||
_peer_in_bytes_array_index = (_peer_in_bytes_array_index + 1) % _peer_speed_mesurement_interval_count;
|
||||
for (const auto& [peer, array] : _peer_in_bytes_array) {
|
||||
//for (const auto& [peer, array] : _peer_in_bytes_array) {
|
||||
for (auto it = _peer_in_bytes_array.begin(); it != _peer_in_bytes_array.end();) {
|
||||
const auto& [peer, array] = *it;
|
||||
|
||||
float avg {0.f};
|
||||
for (size_t i = 0; i < array.size(); i++) {
|
||||
avg += array[i];
|
||||
}
|
||||
|
||||
if (avg == 0.f || _tcl.getGroupPeerConnectionStatus(peer.first, peer.second) == Tox_Connection::TOX_CONNECTION_NONE) {
|
||||
_peer_in_speed.erase(peer);
|
||||
it = _peer_in_bytes_array.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
// if 6 mesurment every 0.5sec -> avg is over 3sec -> /3 for /s
|
||||
avg /= _peer_speed_mesurement_interval * _peer_speed_mesurement_interval_count;
|
||||
|
||||
@ -207,12 +225,14 @@ bool SHA1::iterate(float delta) {
|
||||
_peer_in_bytes_array[peer][_peer_in_bytes_array_index] = 0;
|
||||
|
||||
_peer_in_speed[peer] = avg;
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
_peer_in_targets.clear();
|
||||
_tcl.forEachGroup([this](uint32_t group_number) {
|
||||
_tcl.forEachGroupPeer(group_number, [group_number, this](uint32_t peer_number, Tox_Connection connection_status) {
|
||||
if (connection_status == Tox_Connection::TOX_CONNECTION_UDP || !_udp_only) {
|
||||
_tcl.forEachGroupPeer(group_number, [group_number, this](uint32_t peer_number) {
|
||||
if (!_udp_only || _tcl.getGroupPeerConnectionStatus(group_number, peer_number) == Tox_Connection::TOX_CONNECTION_UDP) {
|
||||
_peer_in_targets.push_back({group_number, peer_number});
|
||||
}
|
||||
});
|
||||
@ -272,14 +292,21 @@ bool SHA1::iterate(float delta) {
|
||||
float up_kibs {(bytes_up_since / 1024.f) / log_interval};
|
||||
float down_kibs {(bytes_down_since / 1024.f) / log_interval};
|
||||
|
||||
std::cout << std::string(40, '-') << "\n";
|
||||
std::cout << "SHA1 speed down: " << down_kibs << "KiB/s up: " << up_kibs << "KiB/s\n";
|
||||
std::cout << "SHA1 total down: " << _bytes_down / 1024 << "KiB up: " << _bytes_up / 1024 << "KiB\n";
|
||||
|
||||
std::cout << "SHA1 cwq:" << _chunk_want_queue.size() << " cwqr:" << _chunks_requested.size() << " trc:" << _transfers_receiving_chunk.size() << " tsc:" << _transfers_sending_chunk.size() << "\n";
|
||||
std::cout << "SHA1 peer down speeds:\n";
|
||||
for (const auto& [peer, speed] : _peer_in_speed) {
|
||||
std::cout << " " << peer.first << ":" << peer.second << "(" << _tcl.getGroupPeerName(peer.first, peer.second) << ")" << "\t" << speed / 1024.f << "KiB/s\n";
|
||||
std::cout
|
||||
<< " " << peer.first << ":" << peer.second
|
||||
<< " " << (_tcl.getGroupPeerConnectionStatus(peer.first, peer.second) == Tox_Connection::TOX_CONNECTION_TCP ? "tcp" : "udp")
|
||||
<< " (" << _tcl.getGroupPeerName(peer.first, peer.second) << ")"
|
||||
<< " " << speed / 1024.f << "KiB/s\n"
|
||||
;
|
||||
}
|
||||
std::cout << std::string(40, '-') << "\n";
|
||||
}
|
||||
|
||||
// TODO: unmap and remap the file every couple of minutes to keep ram usage down?
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <random>
|
||||
@ -57,9 +58,13 @@ struct SHA1 final : public StateI {
|
||||
size_t chunkSize(size_t chunk_index) const;
|
||||
bool haveChunk(const SHA1Digest& hash) const;
|
||||
|
||||
private:
|
||||
public: // config
|
||||
bool _udp_only {false};
|
||||
|
||||
size_t _max_concurrent_in {32};
|
||||
size_t _max_concurrent_out {16};
|
||||
|
||||
private:
|
||||
mio::mmap_sink _file_map; // writable if not all
|
||||
const FTInfoSHA1 _sha1_info;
|
||||
const std::vector<uint8_t> _sha1_info_data;
|
||||
@ -79,11 +84,7 @@ struct SHA1 final : public StateI {
|
||||
// chunk_index -> time since request
|
||||
std::map<size_t, float> _chunks_requested;
|
||||
|
||||
size_t _max_concurrent_in {32};
|
||||
size_t _max_concurrent_out {16};
|
||||
|
||||
std::minstd_rand _rng {1337};
|
||||
std::uniform_int_distribution<size_t> _distrib;
|
||||
|
||||
std::unordered_map<SHA1Digest, size_t> _chunk_hash_to_index;
|
||||
|
||||
@ -114,7 +115,6 @@ struct SHA1 final : public StateI {
|
||||
// _peer_in_speed feeds directly into _peer_in_targets_dist
|
||||
std::vector<std::pair<uint32_t, uint32_t>> _peer_in_targets;
|
||||
std::discrete_distribution<size_t> _peer_in_targets_dist;
|
||||
|
||||
};
|
||||
|
||||
} // States
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include <tox/tox.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
// logging
|
||||
void log_cb(Tox *tox, TOX_LOG_LEVEL level, const char *file, uint32_t line, const char *func, const char *message, void *user_data);
|
||||
|
||||
@ -52,3 +54,5 @@ bool ft1_recv_init_sha1_chunk_cb(Tox *tox, uint32_t group_number, uint32_t peer_
|
||||
void ft1_recv_data_sha1_chunk_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, uint8_t transfer_id, size_t data_offset, const uint8_t* data, size_t data_size, void* user_data);
|
||||
void ft1_send_data_sha1_chunk_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, uint8_t transfer_id, size_t data_offset, uint8_t* data, size_t data_size, void* user_data);
|
||||
|
||||
} // extern C
|
||||
|
||||
|
@ -122,11 +122,9 @@ ToxClient::ToxClient(const CommandLine& cl) :
|
||||
_ext_ctx = NGC_EXT_new();
|
||||
|
||||
NGC_FT1_options ft1_options {};
|
||||
ft1_options.acks_per_packet = 5;
|
||||
ft1_options.init_retry_timeout_after = 10.f;
|
||||
ft1_options.sending_resend_without_ack_after = 5.f;
|
||||
ft1_options.sending_give_up_after = 30.f;
|
||||
ft1_options.packet_window_size = 10;
|
||||
ft1_options.acks_per_packet = cl.ft_acks_per_packet;
|
||||
ft1_options.init_retry_timeout_after = cl.ft_init_retry_timeout_after;
|
||||
ft1_options.sending_give_up_after = cl.ft_sending_give_up_after;
|
||||
_ft1_ctx = NGC_FT1_new(&ft1_options);
|
||||
NGC_FT1_register_ext(_ft1_ctx, _ext_ctx);
|
||||
|
||||
@ -214,6 +212,25 @@ bool ToxClient::iterate(void) {
|
||||
}
|
||||
}
|
||||
|
||||
_rejoin_group_timer -= time_delta;
|
||||
if (_rejoin_group_timer <= 0.f) {
|
||||
_rejoin_group_timer = 6.f * 60.f;
|
||||
|
||||
forEachGroup([this](const uint32_t group_number) {
|
||||
// is connected or trying to connect
|
||||
if (!tox_group_is_connected(_tox, group_number, nullptr)) {
|
||||
std::cerr << "TCL disconnected group " << group_number << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// never seen another peer
|
||||
if (_groups.at(group_number).empty()) {
|
||||
tox_group_reconnect(_tox, group_number, nullptr);
|
||||
std::cerr << "TCL reconnecting empty group " << group_number << "\n";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (_tox_profile_dirty) {
|
||||
saveToxProfile();
|
||||
}
|
||||
@ -238,6 +255,10 @@ std::string_view ToxClient::getGroupPeerName(uint32_t group_number, uint32_t pee
|
||||
}
|
||||
}
|
||||
|
||||
TOX_CONNECTION ToxClient::getGroupPeerConnectionStatus(uint32_t group_number, uint32_t peer_number) const {
|
||||
return tox_group_peer_get_connection_status(_tox, group_number, peer_number, nullptr);
|
||||
}
|
||||
|
||||
void ToxClient::onToxSelfConnectionStatus(TOX_CONNECTION connection_status) {
|
||||
std::cout << "TCL self status: ";
|
||||
switch (connection_status) {
|
||||
@ -247,9 +268,20 @@ void ToxClient::onToxSelfConnectionStatus(TOX_CONNECTION connection_status) {
|
||||
}
|
||||
|
||||
if (connection_status != TOX_CONNECTION::TOX_CONNECTION_NONE && !_join_group_after_dht_connect.empty()) {
|
||||
// TODO: error checking
|
||||
tox_group_join(_tox, _join_group_after_dht_connect.data(), nullptr, 0, nullptr, 0, nullptr);
|
||||
std::cout << "TCL joining group " << bin2hex(_join_group_after_dht_connect) << "\n";
|
||||
Tox_Err_Group_Join err;
|
||||
uint32_t new_group_number = tox_group_join(
|
||||
_tox,
|
||||
_join_group_after_dht_connect.data(),
|
||||
reinterpret_cast<const uint8_t*>(_self_name.data()), _self_name.size(),
|
||||
nullptr, 0,
|
||||
&err
|
||||
);
|
||||
if (err == TOX_ERR_GROUP_JOIN_OK) {
|
||||
std::cout << "TCL joining group " << bin2hex(_join_group_after_dht_connect) << "\n";
|
||||
_groups[new_group_number] = {};
|
||||
} else {
|
||||
std::cerr << "TCL error joining group failed " << err << "\n";
|
||||
}
|
||||
_join_group_after_dht_connect.clear();
|
||||
}
|
||||
|
||||
@ -269,14 +301,14 @@ void ToxClient::onToxGroupPeerName(uint32_t group_number, uint32_t peer_id, std:
|
||||
_groups[group_number][peer_id].name = name;
|
||||
}
|
||||
|
||||
void ToxClient::onToxGroupPeerConnection(uint32_t group_number, uint32_t peer_id, TOX_CONNECTION connection_status) {
|
||||
std::cout << "TCL peer " << group_number << ":" << peer_id << " status: ";
|
||||
switch (connection_status) {
|
||||
case TOX_CONNECTION::TOX_CONNECTION_NONE: std::cout << "offline\n"; break;
|
||||
case TOX_CONNECTION::TOX_CONNECTION_TCP: std::cout << "TCP-relayed\n"; break;
|
||||
case TOX_CONNECTION::TOX_CONNECTION_UDP: std::cout << "UDP-direct\n"; break;
|
||||
}
|
||||
}
|
||||
//void ToxClient::onToxGroupPeerConnection(uint32_t group_number, uint32_t peer_id, TOX_CONNECTION connection_status) {
|
||||
//std::cout << "TCL peer " << group_number << ":" << peer_id << " status: ";
|
||||
//switch (connection_status) {
|
||||
//case TOX_CONNECTION::TOX_CONNECTION_NONE: std::cout << "offline\n"; break;
|
||||
//case TOX_CONNECTION::TOX_CONNECTION_TCP: std::cout << "TCP-relayed\n"; break;
|
||||
//case TOX_CONNECTION::TOX_CONNECTION_UDP: std::cout << "UDP-direct\n"; break;
|
||||
//}
|
||||
//}
|
||||
|
||||
void ToxClient::onToxGroupCustomPacket(uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length) {
|
||||
// TODO: signal private?
|
||||
@ -310,7 +342,7 @@ void ToxClient::onToxGroupPeerJoin(uint32_t group_number, uint32_t peer_id) {
|
||||
tmp_name.push_back('\0'); // make sure its null terminated
|
||||
|
||||
_groups[group_number][peer_id] = {
|
||||
tox_group_peer_get_connection_status(_tox, group_number, peer_id, nullptr),
|
||||
//tox_group_peer_get_connection_status(_tox, group_number, peer_id, nullptr),
|
||||
reinterpret_cast<const char*>(tmp_name.data())
|
||||
};
|
||||
|
||||
@ -325,6 +357,7 @@ void ToxClient::onToxGroupPeerExit(uint32_t group_number, uint32_t peer_id, Tox_
|
||||
|
||||
void ToxClient::onToxGroupSelfJoin(uint32_t group_number) {
|
||||
std::cout << "TCL group self join " << group_number << "\n";
|
||||
tox_group_self_set_name(_tox, group_number, reinterpret_cast<const uint8_t*>(_self_name.data()), _self_name.size(), nullptr);
|
||||
// ???
|
||||
// can be triggered after other peers already joined o.o
|
||||
_tox_profile_dirty = true;
|
||||
|
@ -34,6 +34,7 @@ struct ToxClient {
|
||||
std::string getOwnAddress(void) const;
|
||||
|
||||
std::string_view getGroupPeerName(uint32_t group_number, uint32_t peer_number) const;
|
||||
TOX_CONNECTION getGroupPeerConnectionStatus(uint32_t group_number, uint32_t peer_number) const;
|
||||
|
||||
template<typename FN>
|
||||
void forEachGroup(FN&& fn) const {
|
||||
@ -46,8 +47,7 @@ struct ToxClient {
|
||||
void forEachGroupPeer(uint32_t group_number, FN&& fn) const {
|
||||
if (_groups.count(group_number)) {
|
||||
for (const auto& [peer_number, peer] : _groups.at(group_number)) {
|
||||
const auto& [connection_status, name] = peer;
|
||||
fn(peer_number, connection_status);
|
||||
fn(peer_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,7 @@ struct ToxClient {
|
||||
void onToxSelfConnectionStatus(TOX_CONNECTION connection_status);
|
||||
void onToxFriendRequest(const uint8_t* public_key, std::string_view message);
|
||||
void onToxGroupPeerName(uint32_t group_number, uint32_t peer_id, std::string_view name);
|
||||
void onToxGroupPeerConnection(uint32_t group_number, uint32_t peer_id, TOX_CONNECTION connection_status);
|
||||
//void onToxGroupPeerConnection(uint32_t group_number, uint32_t peer_id, TOX_CONNECTION connection_status);
|
||||
void onToxGroupCustomPacket(uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length);
|
||||
void onToxGroupCustomPrivatePacket(uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length);
|
||||
void onToxGroupInvite(uint32_t friend_number, const uint8_t* invite_data, size_t invite_length, std::string_view group_name);
|
||||
@ -87,15 +87,14 @@ struct ToxClient {
|
||||
bool _tox_profile_dirty {false}; // set in callbacks
|
||||
|
||||
std::vector<uint8_t> _join_group_after_dht_connect;
|
||||
float _rejoin_group_timer {4.f * 60.f};
|
||||
|
||||
std::unique_ptr<StateI> _state;
|
||||
|
||||
// key groupid, value set of peer ids
|
||||
//std::map<uint32_t, std::set<uint32_t>> _groups;
|
||||
struct Peer {
|
||||
Tox_Connection connection_status {Tox_Connection::TOX_CONNECTION_NONE};
|
||||
std::string name;
|
||||
};
|
||||
// key groupid, key peerid
|
||||
std::map<uint32_t, std::map<uint32_t, Peer>> _groups;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user