From 9686e552151a9382238ab01b3632f5ce3402ee3a Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 23 Jul 2015 04:17:15 +0200 Subject: SOCKS: fix "on_connecting" callback --- common.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common.c b/common.c index 10db329..7a9d2cc 100644 --- a/common.c +++ b/common.c @@ -364,6 +364,7 @@ struct socks_target { LIST_HEADER (struct socks_target) + char *address_str; ///< Target address as a string struct socks_addr address; ///< Target address uint16_t port; ///< Target service port }; @@ -822,9 +823,10 @@ socks_connector_on_connecting (void *user_data, const char *via) if (!self->on_connecting) return; - // TODO: reconstruct the address from the current target iterator, - // or just store it in unprocessed form - char *address = format_host_port_pair ("", ""); + struct socks_target *target = self->targets_iter; + char *port = xstrdup_printf ("%u", target->port); + char *address = format_host_port_pair (target->address_str, port); + free (port); self->on_connecting (self->user_data, address, via, self->protocol_iter ? "SOCKS4A" : "SOCKS5"); free (address); @@ -1005,6 +1007,7 @@ socks_connector_free (struct socks_connector *self) LIST_FOR_EACH (struct socks_target, iter, self->targets) { socks_addr_free (&iter->address); + free (iter->address_str); free (iter); } @@ -1037,6 +1040,7 @@ socks_connector_add_target (struct socks_connector *self, } target->port = port; + target->address_str = xstrdup (host); LIST_APPEND_WITH_TAIL (self->targets, self->targets_tail, target); return true; } -- cgit v1.2.3-70-g09d2