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)
|
LIST_HEADER (struct socks_target)
|
||||||
|
|
||||||
|
char *address_str; ///< Target address as a string
|
||||||
struct socks_addr address; ///< Target address
|
struct socks_addr address; ///< Target address
|
||||||
uint16_t port; ///< Target service port
|
uint16_t port; ///< Target service port
|
||||||
};
|
};
|
||||||
|
@ -822,9 +823,10 @@ socks_connector_on_connecting (void *user_data, const char *via)
|
||||||
if (!self->on_connecting)
|
if (!self->on_connecting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: reconstruct the address from the current target iterator,
|
struct socks_target *target = self->targets_iter;
|
||||||
// or just store it in unprocessed form
|
char *port = xstrdup_printf ("%u", target->port);
|
||||||
char *address = format_host_port_pair ("", "");
|
char *address = format_host_port_pair (target->address_str, port);
|
||||||
|
free (port);
|
||||||
self->on_connecting (self->user_data, address, via,
|
self->on_connecting (self->user_data, address, via,
|
||||||
self->protocol_iter ? "SOCKS4A" : "SOCKS5");
|
self->protocol_iter ? "SOCKS4A" : "SOCKS5");
|
||||||
free (address);
|
free (address);
|
||||||
|
@ -1005,6 +1007,7 @@ socks_connector_free (struct socks_connector *self)
|
||||||
LIST_FOR_EACH (struct socks_target, iter, self->targets)
|
LIST_FOR_EACH (struct socks_target, iter, self->targets)
|
||||||
{
|
{
|
||||||
socks_addr_free (&iter->address);
|
socks_addr_free (&iter->address);
|
||||||
|
free (iter->address_str);
|
||||||
free (iter);
|
free (iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,6 +1040,7 @@ socks_connector_add_target (struct socks_connector *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
target->port = port;
|
target->port = port;
|
||||||
|
target->address_str = xstrdup (host);
|
||||||
LIST_APPEND_WITH_TAIL (self->targets, self->targets_tail, target);
|
LIST_APPEND_WITH_TAIL (self->targets, self->targets_tail, target);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue