From 68ec484a584379f6b1b23ec822f41d891941aa33 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 15 Aug 2014 15:13:35 -0400 Subject: [PATCH] don't allow DNS lookups when using a proxy + forced TCP & fix arg parsing --- src/dns.c | 5 +++++ src/toxic.c | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/dns.c b/src/dns.c index 52e35d7..dff54c9 100644 --- a/src/dns.c +++ b/src/dns.c @@ -377,6 +377,11 @@ void *dns3_lookup_thread(void *data) /* creates new thread for dns3 lookup. Only allows one lookup at a time. */ void dns3_lookup(ToxWindow *self, Tox *m, const char *id_bin, const char *addr, const char *msg) { + if (arg_opts.use_proxy && arg_opts.force_tcp) { + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "DNS lookups are disabled."); + return; + } + if (t_data.busy) { const char *err = "Please wait for previous user lookup to finish."; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, err); diff --git a/src/toxic.c b/src/toxic.c index 7a43f29..08590d9 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -203,7 +203,7 @@ static Tox *init_tox(void) fprintf(stderr, "UDP disabled\n"); if (tox_opts.proxy_enabled && m == NULL) - exit_toxic_err("Proxy failed to connect", FATALERR_PROXY); + exit_toxic_err("Proxy error", FATALERR_PROXY); if (m == NULL) return NULL; @@ -599,7 +599,11 @@ static void parse_args(int argc, char *argv[]) case 'p': arg_opts.use_proxy = 1; snprintf(arg_opts.proxy_address, sizeof(arg_opts.proxy_address), "%s", optarg); - arg_opts.proxy_port = (uint16_t) atoi(argv[optind++]); + + if (++optind > argc || argv[optind-1][0] == '-') + exit_toxic_err("Proxy error", FATALERR_PROXY); + + arg_opts.proxy_port = (uint16_t) atoi(argv[optind-1]); break; case 'r': @@ -750,10 +754,10 @@ int main(int argc, char *argv[]) line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to load user settings"); if (arg_opts.use_proxy && !arg_opts.force_tcp) { - msg = "WARNING: Using a proxy without disabling UDP may leak your real IP address."; - line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", msg); - msg = "Use the -t option to disable UDP"; - line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", msg); + msg = "* WARNING: Using a proxy without disabling UDP may leak your real IP address."; + line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, "%s", msg); + msg = " Use the -t option to disable UDP."; + line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, "%s", msg); } uint64_t last_save = (uint64_t) time(NULL);