Skip to content

Commit

Permalink
feat: disable toxcore DNS lookups when proxy is set with UDP disabled
Browse files Browse the repository at this point in the history
This requires an update to toxcore version used in the static build
  • Loading branch information
JFreegman committed Nov 29, 2024
1 parent cd94814 commit c3a1d89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion astylerc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions script/build-minimal-static-toxic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
12 changes: 10 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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";
Expand All @@ -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.";
Expand Down Expand Up @@ -837,6 +844,7 @@ _Noreturn static void *thread_av(void *data)
sleep_thread(sleep_duration);
}
}

#endif /* AUDIO */

static void print_usage(void)
Expand Down

0 comments on commit c3a1d89

Please sign in to comment.