From c3a1d894d7f3aea207a9b58c6d5d843cb4269b75 Mon Sep 17 00:00:00 2001 From: jfreegman Date: Fri, 29 Nov 2024 15:16:24 -0500 Subject: [PATCH] feat: disable toxcore DNS lookups when proxy is set with UDP disabled This requires an update to toxcore version used in the static build --- astylerc | 3 ++- script/build-minimal-static-toxic.sh | 4 ++-- src/main.c | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/astylerc b/astylerc index 249747aa3..86a867294 100644 --- a/astylerc +++ b/astylerc @@ -16,9 +16,10 @@ --align-reference=name # Formatting Options ---add-brackets +--add-braces --convert-tabs --max-code-length=120 +--attach-return-type # Other Options --preserve-date diff --git a/script/build-minimal-static-toxic.sh b/script/build-minimal-static-toxic.sh index 8d3f80124..f1b1b04b4 100755 --- a/script/build-minimal-static-toxic.sh +++ b/script/build-minimal-static-toxic.sh @@ -143,10 +143,10 @@ mkdir -p "$BUILD_DIR" cd "$BUILD_DIR" # The git hash of the c-toxcore version we're using -TOXCORE_VERSION="v0.2.20" +TOXCORE_VERSION="ac812871a2ec42c37dd7f73bf0f7a6734dfc0bf2" # The sha256sum of the c-toxcore tarball for TOXCORE_VERSION -TOXCORE_HASH="5c1bc37d24a1e37fc6c03580e2602019a09393cd2e8ae1f58e338438f14d5871" +TOXCORE_HASH="6ae79cb3020032297428846065579a843094a833a6eeb266620c9eed8e3bdedf" TOXCORE_FILENAME="c-toxcore-$TOXCORE_VERSION.tar.gz" diff --git a/src/main.c b/src/main.c index 444b53750..3e3e532e2 100644 --- a/src/main.c +++ b/src/main.c @@ -477,6 +477,7 @@ static void init_tox_options(const Run_Options *run_opts, Init_Queue *init_q, st tox_options_set_tcp_port(tox_opts, run_opts->tcp_port); tox_options_set_local_discovery_enabled(tox_opts, !run_opts->disable_local_discovery); tox_options_set_experimental_groups_persistence(tox_opts, true); + tox_options_set_experimental_disable_dns(tox_opts, false); if (run_opts->logging) { tox_options_set_log_callback(tox_opts, cb_toxcore_logger); @@ -494,7 +495,9 @@ static void init_tox_options(const Run_Options *run_opts, Init_Queue *init_q, st init_queue_add(init_q, "TCP relaying enabled on port %d", tox_options_get_tcp_port(tox_opts)); } - if (tox_options_get_proxy_type(tox_opts) != TOX_PROXY_TYPE_NONE) { + const bool proxy_set = tox_options_get_proxy_type(tox_opts) != TOX_PROXY_TYPE_NONE; + + if (proxy_set) { tox_options_set_proxy_port(tox_opts, run_opts->proxy_port); tox_options_set_proxy_host(tox_opts, run_opts->proxy_address); const char *ps = tox_options_get_proxy_type(tox_opts) == TOX_PROXY_TYPE_SOCKS5 ? "SOCKS5" : "HTTP"; @@ -505,8 +508,12 @@ static void init_tox_options(const Run_Options *run_opts, Init_Queue *init_q, st } if (!tox_options_get_udp_enabled(tox_opts)) { + if (proxy_set) { + tox_options_set_experimental_disable_dns(tox_opts, true); + } + init_queue_add(init_q, "UDP disabled"); - } else if (tox_options_get_proxy_type(tox_opts) != TOX_PROXY_TYPE_NONE) { + } else if (proxy_set) { const char *msg = "WARNING: Using a proxy without disabling UDP may leak your real IP address."; init_queue_add(init_q, "%s", msg); msg = "Use the -t option to disable UDP."; @@ -837,6 +844,7 @@ _Noreturn static void *thread_av(void *data) sleep_thread(sleep_duration); } } + #endif /* AUDIO */ static void print_usage(void)