<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hello all,</p>
<p>I have built a DNS filtering service using the pythonmod for unbound. Everything is working as it should apart from the cache. I want to disable the cache completely as I am filtering the results based on the incoming IP address. As an example anyone from 192.168.30.20 can access social media sites, but anyone from 192.168.30.30 is returned the IP address of the server instead which shows a "blocked" message.</p>
<p>The code is working perfectly, but the cache is causing issues as if someone requests from 192.168.30.20 then the query is put into the cache which then gets delivered to 192.168.30.30. I have returned the cache size to 0 which helped a bit, but it still keeps some items in the cache for a short period (about a minute). Here is what I have put in my config file:</p>
<p> module-config: "python iterator"<br /> msg-cache-size: 0<br /> rrset-cache-size: 0<br /> key-cache-size: 0</p>
<p>Even with these settings, queries are still going into the cache as shown below:</p>
<p>root@dns1:/etc/unbound# unbound-control dump_cache | grep amoory<br />amoory.com. 592 IN A 89.184.84.7</p>
<p> </p>
<p>I also play with the cache-max-ttl option, but that seems to return the lower ttl to the client too. If there a way of simply disabling the cache?</p>
<p>The dream would be to have a cache per client of incoming IP address, but I wouldn't want to have to code it from scratch in pythonmod.</p>
<p> </p>
<p>In my 'operate' method in pythonmod I have even put the follow, but this still doesn't prevent items going in to the cache:</p>
<p><span class="pl-k"></span>if (event == MODULE_EVENT_NEW) or (event == MODULE_EVENT_PASS):<br /> #Turn off the cache management<br /> # Instruct other modules to not lookup for an<br /> # answer in the cache.<br /> qstate.no_cache_lookup = 1<br /><br /> # Instruct other modules to not store the answer in<br /> # the cache.<br /> qstate.no_cache_store = 1</p>
<p>I can show the full code if needed. Any help would be appreciated!</p>
<p> </p>
<div> </div>
</body></html>