]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/pythonmod/doc/examples/example1.rst
b49e64409255cff7074d485c3922664ff42ca342
[apple/network_cmds.git] / unbound / pythonmod / doc / examples / example1.rst
1 .. _log_handler:
2
3 Packet logger
4 =========================
5
6 This example shows how to log and print details about query and response.
7 As soon as the ``iterator`` has finished (event is :data:`module_event_moddone`), ``qstate.return_msg`` contains response packet or ``None``.
8 This packet will be send to a client that asked for it.
9
10 Complete source code
11 --------------------
12
13 .. literalinclude:: ../../examples/log.py
14 :language: python
15
16 Testing
17 ------------------
18 Run the unbound server:
19
20 ``root@localhost>unbound -dv -c ./test-log.conf``
21
22 In case you use own configuration file, don't forget to enable python module: ``module-config: "validator python iterator"`` and use valid script path: ``python-script: "./examples/log.py"``.
23
24 Example of output::
25
26 [1231790168] unbound[7941:0] info: response for <f.gtld-servers.NET. AAAA IN>
27 [1231790168] unbound[7941:0] info: reply from <gtld-servers.NET.> 192.5.6.31#53
28 [1231790168] unbound[7941:0] info: query response was ANSWER
29 [1231790168] unbound[7941:0] info: pythonmod: operate called, id: 1, event:module_event_moddone
30 ----------------------------------------------------------------------------------------------------
31 Query: f.gtld-servers.NET., type: AAAA (28), class: IN (1)
32 ----------------------------------------------------------------------------------------------------
33 Return reply :: flags: 8080, QDcount: 1, Security:0, TTL=86400
34 qinfo :: qname: ['f', 'gtld-servers', 'NET', ''] f.gtld-servers.NET., qtype: AAAA, qclass: IN
35 Reply:
36 0 : ['gtld-servers', 'NET', ''] gtld-servers.NET. flags: 0000 type: SOA (6) class: IN (1)
37 0 : TTL= 86400
38 0x00 | 00 3A 02 41 32 05 4E 53 54 4C 44 03 43 4F 4D 00 05 | . : . A 2 . N S T L D . C O M . .
39 0x10 | 05 6E 73 74 6C 64 0C 76 65 72 69 73 69 67 6E 2D 67 | . n s t l d . v e r i s i g n - g
40 0x20 | 67 72 73 03 43 4F 4D 00 77 74 2D 64 00 00 0E 10 00 | g r s . C O M . w t - d . . . . .
41 0x30 | 00 00 03 84 00 12 75 00 00 01 51 80 | . . . . . . u . . . Q .
42