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