Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache is being ignored #13

Open
sjakub opened this issue Jul 13, 2016 · 1 comment
Open

Cache is being ignored #13

sjakub opened this issue Jul 13, 2016 · 1 comment

Comments

@sjakub
Copy link

sjakub commented Jul 13, 2016

This is probably caused by the fact that I am not using the APIs properly,
but I cannot get the cache to work... at all.

I use the resolver generated using dns_res_open(), passing a cache object to it.
Then I use dns_ai_open() and dns_ai_nextent().
Everything works fine, except the cache is getting ignored...

Nothing new is added to it, when I dump it to a file it's empty.
When I manually create a cache, using data generated by 'cache' tool,
it is loaded, but then it is getting ignored and still does the DNS query.

Is there an example how to add cache support to the resolver?
Thanks!

@wahern
Copy link
Owner

wahern commented Jul 23, 2016

  1. Be sure to include the letter "c" in the .lookup field of the resconf object. You can do that manually or by including the word "cache" in the "lookup" line in the resolv.conf file used to initialize the object. The order in which it appears controls when it's queried.

(/etc/resolv.conf "lookup ..." is the BSD equivalent to Linux's "hosts: ..." line in /etc/nsswitch.conf, though dns.c's /etc/nsswitch.conf parser doesn't recognize the "cache" keyword.)

  1. The cache API in dns.h is intended only for querying; there's no handler defined to insert new records through the API. That currently has to be done in the application using a private interface to its cache implementation after processing the result of dns_res_fetch.

The cache implementation in src/cache.h and src/cache.c was written principally for use by the RFC 4408 (SPF) test suite implemented in regress/rfc4408-tests.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants