summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common.c')
-rw-r--r--common.c10
1 files 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;
}