Inconsistent addrmap events when resolving hostname (regression)
Tor 0.2.3.x would generate an ADDRMAP event for all addresses added to the cache, and since all resolved IPv4 addresses were added to the cache, all IPv4 addresses generated an ADDRMAP event. Ticket #7570 (moved) introduced circuit-based separation of the DNS cache and "broke" that mechanism: Resolves generated via the DNSPort or a control connection do not end up in the cache and thus don't generate an ADDRMAP event. Also, when the cache is disabled by adding the
SocksPort 9050 NoCacheDNS to the torrc, no ADDRMAP event is generated.
Git-bisect shows commit 7536c40e9641a0724f0c9e6f994306d762d37e4d introduced this problem.
First, we should be clear about when to generate ADDRMAP events. From the control spec:
4.1.7. New Address mapping These events are generated when a new address mapping is entered in Tor's address map cache, or when the answer for a RESOLVE command is found.
This would mean that DNS data retrieved for DNSPort queries or when NoCacheDNS is set would not trigger an event. Do we want this behavior? Or do we want to trigger ADDRMAP events for any mapping that is not already in the cache, even if it is not going to be cached anyway?