]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/pythonmod/doc/examples/example2.rst
network_cmds-596.100.2.tar.gz
[apple/network_cmds.git] / unbound / pythonmod / doc / examples / example2.rst
1 Response generation
2 =====================
3
4 This example shows how to handle queries and generate response packet.
5
6 .. note::
7 If the python module is the first module and validator module is enabled (``module-config: "python validator iterator"``),
8 a return_msg security flag has to be set at least to 2. Leaving security flag untouched causes that the
9 response will be refused by unbound worker as unbound will consider it as non-valid response.
10
11 Complete source code
12 --------------------
13
14 .. literalinclude:: ../../examples/resgen.py
15 :language: python
16
17 Testing
18 -------
19
20 Run the unbound server:
21
22 ``root@localhost>unbound -dv -c ./test-resgen.conf``
23
24 Query for a A record ending with .localdomain
25
26 ``dig A test.xxx.localdomain @127.0.0.1``
27
28 Dig produces the following output::
29
30 ;; global options: printcmd
31 ;; Got answer:
32 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48426
33 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
34
35 ;; QUESTION SECTION:
36 ;test.xxx.localdomain. IN A
37
38 ;; ANSWER SECTION:
39 test.xxx.localdomain. 10 IN A 127.0.0.1
40
41 ;; Query time: 2 msec
42 ;; SERVER: 127.0.0.1#53(127.0.0.1)
43 ;; WHEN: Mon Jan 01 12:46:02 2009
44 ;; MSG SIZE rcvd: 54
45
46 As we handle (override) in python module only queries ending with "localdomain.", the unboud can still resolve host names.