SOCKS: fix "on_connecting" callback
This commit is contained in:
parent
4a89572089
commit
9686e55215
10
common.c
10
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user