Controller: Always send ADDRMAP event after RESOLVE command (#8596 part 1/2)

Since 7536c40 only DNS results for real SOCKS requests are added to the cache,
but not DNS results for DNSPort queries or control connection RESOLVE queries.
Only cache additions would trigger ADDRMAP events on successful resolve.

Change it so that DNS results received after a RESOLVE command also generate
ADDRMAP events.
This commit is contained in:
Desoxy 2013-04-03 18:50:27 +02:00
parent 33b7083f26
commit 2c40138210

View File

@ -2040,11 +2040,8 @@ tell_controller_about_resolved_result(entry_connection_t *conn,
int ttl, int ttl,
time_t expires) time_t expires)
{ {
expires = time(NULL) + ttl;
if (ttl >= 0 && (answer_type == RESOLVED_TYPE_IPV4 || if (answer_type == RESOLVED_TYPE_IPV4 && answer_len >= 4) {
answer_type == RESOLVED_TYPE_HOSTNAME)) {
return; /* we already told the controller. */
} else if (answer_type == RESOLVED_TYPE_IPV4 && answer_len >= 4) {
char *cp = tor_dup_ip(ntohl(get_uint32(answer))); char *cp = tor_dup_ip(ntohl(get_uint32(answer)));
control_event_address_mapped(conn->socks_request->address, control_event_address_mapped(conn->socks_request->address,
cp, expires, NULL); cp, expires, NULL);
@ -2116,8 +2113,9 @@ connection_ap_handshake_socks_resolved(entry_connection_t *conn,
conn->socks_request->has_finished = 1; conn->socks_request->has_finished = 1;
return; return;
} else { } else {
/* This must be a request from the controller. We already sent /* This must be a request from the controller. Since answers to those
* a mapaddress if there's a ttl. */ * requests are not cached, they do not generate an ADDRMAP event on
* their own. */
tell_controller_about_resolved_result(conn, answer_type, answer_len, tell_controller_about_resolved_result(conn, answer_type, answer_len,
(char*)answer, ttl, expires); (char*)answer, ttl, expires);
conn->socks_request->has_finished = 1; conn->socks_request->has_finished = 1;