]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/libunbound/python/doc/examples/example5.rst
0a31d9a57e76c76eab07db48480df33fc3b7d419
[apple/network_cmds.git] / unbound / libunbound / python / doc / examples / example5.rst
1 .. _example_resolver_only:
2
3 ==============================
4 Resolver only
5 ==============================
6
7 This example program shows how to perform DNS resolution only.
8 Unbound contains two basic modules: resolver and validator.
9 In case, the validator is not necessary, the validator module can be turned off using "module-config" option.
10 This option contains a list of module names separated by the space char. This list determined which modules should be employed and in what order.
11
12 ::
13
14 #!/usr/bin/python
15 import os
16 from unbound import ub_ctx,RR_TYPE_A,RR_CLASS_IN
17
18 ctx = ub_ctx()
19 ctx.set_option("module-config:","iterator")
20 ctx.resolvconf("/etc/resolv.conf")
21
22 status, result = ctx.resolve("www.google.com", RR_TYPE_A, RR_CLASS_IN)
23 if status == 0 and result.havedata:
24
25 print "Result:", result.data.address_list
26
27 .. note::
28 The :meth:`unbound.ub_ctx.set_option` method must be used before the first resolution (i.e. before :meth:`unbound.ub_ctx.resolve` or :meth:`unbound.ub_ctx.resolve_async` call).
29