aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-23 04:17:15 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-23 04:26:59 +0200
commit9686e552151a9382238ab01b3632f5ce3402ee3a (patch)
tree901f61dc1bf36ea3bb6e43094ed29ad06f49d212
parent4a8957208909ec9bd496af9455f2c6f65f470269 (diff)
downloadxK-9686e552151a9382238ab01b3632f5ce3402ee3a.tar.gz
xK-9686e552151a9382238ab01b3632f5ce3402ee3a.tar.xz
xK-9686e552151a9382238ab01b3632f5ce3402ee3a.zip
SOCKS: fix "on_connecting" callback
-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;
}