Compare commits

..

16 Commits

Author SHA1 Message Date
3567aba4db change cd output name 2023-10-15 16:40:48 +02:00
9b07cb4dce compile fixes for toxcore and gcc12 2023-10-15 16:34:07 +02:00
c89bba25a3 update toxcore dep, so clone works again 2023-10-15 15:57:26 +02:00
f9bc83811c properly handle broken info 2023-08-10 01:32:24 +02:00
5c4bb1aa42 update packet ids 2023-08-06 18:36:21 +02:00
2a143a4c2e remove extra include 2023-06-17 15:47:59 +02:00
3072d2936e fix connecting via chatid 2023-06-16 22:31:00 +02:00
7458841417 cd: switch to static deps 2023-06-16 20:21:10 +02:00
2b3ee3316a msvc fixes 2023-06-16 17:16:50 +02:00
622c9d9d96 add github cd 2023-06-16 16:55:26 +02:00
caa913fa51 small update 2023-06-16 02:05:27 +02:00
261c487cf2 update deps 2023-03-12 18:49:26 +01:00
086fc52e92 dynamic timeouts and minor cleanups 2023-03-12 01:26:23 +01:00
cd6141ee00 updated ft with experimental cca 2023-01-31 02:02:01 +01:00
5fa8dc712a actually use --ft_ options *facepalm* 2023-01-22 22:07:22 +01:00
e0d4c4d1e1 more strict sending 2023-01-22 17:21:03 +01:00
19 changed files with 331 additions and 216 deletions

1
.github/FUNDING.yml vendored Normal file
View File

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

43
.github/workflows/cd.yml vendored Normal file
View 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/

View File

@ -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")

View File

@ -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>

View File

@ -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")

View File

@ -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)

View File

@ -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)

View File

@ -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"

View File

@ -60,12 +60,8 @@ struct CommandLine {
size_t ft_acks_per_packet {3};
// --ft_init_retry_timeout_after
float ft_init_retry_timeout_after {5.f};
// --ft_sending_resend_without_ack_after
float ft_sending_resend_without_ack_after {3.f};
// --ft_sending_give_up_after
float ft_sending_give_up_after {30.f};
// --ft_packet_window_size
size_t ft_packet_window_size {8};
// ---- 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};

View File

@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <cstddef>
#include <vector>
// returns the 20bytes sha1 hash

View File

@ -176,11 +176,11 @@ 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;
}
}
}
void ReceiveStartSHA1::onFT1SendDataSHA1Info(uint32_t, uint32_t, uint8_t, size_t, uint8_t*, size_t) {

View File

@ -32,7 +32,7 @@ SHA1::SHA1(
_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--) {
@ -145,6 +145,7 @@ bool SHA1::iterate(float delta) {
// send init to _queue_requested_info
const auto [group_number, peer_number] = _queue_requested_info.front();
if (_tcl.getGroupPeerConnectionStatus(group_number, peer_number) != TOX_CONNECTION_NONE) {
uint8_t transfer_id {0};
if (_tcl.sendFT1InitPrivate(
@ -162,9 +163,15 @@ bool SHA1::iterate(float delta) {
_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();
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);
@ -188,6 +195,7 @@ bool SHA1::iterate(float delta) {
}
}
}
}
// update speeds and targets
_peer_speed_mesurement_interval_timer += delta;
@ -284,6 +292,7 @@ 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";
@ -297,6 +306,7 @@ bool SHA1::iterate(float delta) {
<< " " << 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?

View File

@ -9,6 +9,7 @@
#include <unordered_map>
#include <map>
#include <optional>
#include <vector>
#include <deque>
#include <random>

View File

@ -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

View File

@ -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();
}
@ -251,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);
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();
}

View File

@ -87,6 +87,7 @@ 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;