AnyEvent::DNS questions
Brane F. Gračnar
brane.gracnar at planet9.si
Mon Mar 21 20:30:43 CET 2011
On Monday 21 of March 2011 19:07:52 Marc Lehmann wrote:
> On Mon, Mar 21, 2011 at 06:45:32PM +0100, "Brane F. Gračnar"
<brane.gracnar at planet9.si> wrote:
> > Is there a way to get TTL value of dns entry in resolve callback?
>
> Not at the moment - looking at the code, it seems I simply forgot to put it
> into the result record.
>
> Unfortunately, this is now hard to change without breaking the API.
Hmm, ok, what about specifying it as a last argument of callback?
I was looking at AnyEvent::CacheDNS and it seems that it caches results
forever...
> > What is the correct way to support /etc/hosts in anyevent resolver?
>
> You can't at the moment, as /etc/hosts does not have the necessary
> information to do lookups (no dns domains but host aliases with different
> semantics, only addresses, no other info).
>
> Note also that modules such as AnyEvent::HTTP rely on correct DNS
> operation, so you can't add hosts into the resolver without breaking it.
>
> The only viable point where one could add hosts lookups is in the
> AnyEvent::Socket::resolve_sockaddr function (the closest equivalent to
> gethostbyname etc.) - it could assume that entries in /etc/hosts are like
> dns records with a or aaaa types only and no other records for that host,
> in a kind of pre-processing step.
What about patching resolve() to check hosts hash (which would be re-read
every n seconds) in AnyEvent::DNS for 'a' and 'aaaa' request types before
sending actual query to nameserver?
Regards, Brane
More information about the anyevent
mailing list