1Response modification 2===================== 3 4This example shows how to modify the response produced by the ``iterator`` module. 5 6As soon as the iterator module returns the response, we : 7 81. invalidate the data in cache 92. modify the response *TTL* 103. rewrite the data in cache 114. return modified packet 12 13Note that the steps 1 and 3 are necessary only in case, the python module is the first module in the processing chain. 14In other cases, the validator module guarantees updating data which are produced by iterator module. 15 16Complete source code 17-------------------- 18 19.. literalinclude:: ../../examples/resmod.py 20 :language: python 21 22Testing 23------- 24 25Run Unbound server: 26 27``root@localhost>unbound -dv -c ./test-resmod.conf`` 28 29Issue a query for name ending with "nic.cz." 30 31``>>>dig A @127.0.0.1 www.nic.cz`` 32 33:: 34 35 ;; global options: printcmd 36 ;; Got answer: 37 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48831 38 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 5 39 40 ;; QUESTION SECTION: 41 ;www.nic.cz. IN A 42 43 ;; ANSWER SECTION: 44 www.nic.cz. 10 IN A 217.31.205.50 45 46 ;; AUTHORITY SECTION: 47 nic.cz. 10 IN NS e.ns.nic.cz. 48 nic.cz. 10 IN NS a.ns.nic.cz. 49 nic.cz. 10 IN NS c.ns.nic.cz. 50 51 ;; ADDITIONAL SECTION: 52 a.ns.nic.cz. 10 IN A 217.31.205.180 53 a.ns.nic.cz. 10 IN AAAA 2001:1488:dada:176::180 54 c.ns.nic.cz. 10 IN A 195.66.241.202 55 c.ns.nic.cz. 10 IN AAAA 2a01:40:1000::2 56 e.ns.nic.cz. 10 IN A 194.146.105.38 57 58 ;; Query time: 166 msec 59 ;; SERVER: 127.0.0.1#53(127.0.0.1) 60 ;; WHEN: Mon Jan 02 13:39:43 2009 61 ;; MSG SIZE rcvd: 199 62 63As you can see, TTL of all the records is set to 10. 64