]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/pythonmod/doc/examples/example3.rst
6213dc188f12860b87aa1e604fbd9d38453a5033
[apple/network_cmds.git] / unbound / pythonmod / doc / examples / example3.rst
1 Response modification
2 =====================
3
4 This example shows how to modify the response produced by the ``iterator`` module.
5
6 As soon as the iterator module returns the response, we :
7
8 1. invalidate the data in cache
9 2. modify the response *TTL*
10 3. rewrite the data in cache
11 4. return modified packet
12
13 Note that the steps 1 and 3 are neccessary only in case, the python module is the first module in the processing chain.
14 In other cases, the validator module guarantees updating data which are produced by iterator module.
15
16 Complete source code
17 --------------------
18
19 .. literalinclude:: ../../examples/resmod.py
20 :language: python
21
22 Testing
23 -------
24
25 Run Unbound server:
26
27 ``root@localhost>unbound -dv -c ./test-resmod.conf``
28
29 Issue 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
63 As you can see, TTL of all the records is set to 10.