1 /******************************************************************************
2  * ldns_resolver.i: LDNS resolver class
3  *
4  * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
5  *                     Karel Slany    (slany AT fit.vutbr.cz)
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  *     * Redistributions of source code must retain the above copyright notice,
12  *       this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in the
15  *       documentation and/or other materials provided with the distribution.
16  *     * Neither the name of the organization nor the names of its
17  *       contributors may be used to endorse or promote products derived from
18  *       this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *****************************************************************************/
32 
33 
34 /* ========================================================================= */
35 /* SWIG setting and definitions. */
36 /* ========================================================================= */
37 
38 /* Creates temporary instance of (ldns_resolver *). */
39 %typemap(in,numinputs=0,noblock=1) (ldns_resolver **r)
40 {
41   ldns_resolver *$1_res;
42   $1 = &$1_res;
43 }
44 
45 /* Result generation, appends (ldns_resolver *) after the result. */
46 %typemap(argout,noblock=1) (ldns_resolver **r)
47 {
48   $result = SWIG_Python_AppendOutput($result,
49     SWIG_NewPointerObj(SWIG_as_voidptr($1_res),
50       SWIGTYPE_p_ldns_struct_resolver, SWIG_POINTER_OWN |  0 ));
51 }
52 
53 %newobject ldns_resolver_new;
54 %newobject ldns_resolver_pop_nameserver;
55 %newobject ldns_resolver_query;
56 %newobject ldns_resolver_search;
57 %newobject ldns_axfr_next;
58 %newobject ldns_get_rr_list_addr_by_name;
59 %newobject ldns_get_rr_list_name_by_addr;
60 
61 %delobject ldns_resolver_deep_free;
62 %delobject ldns_resolver_free;
63 
64 %nodefaultctor ldns_struct_resolver; /* No default constructor. */
65 %nodefaultdtor ldns_struct_resolver; /* No default destructor. */
66 
67 %ignore ldns_struct_resolver::_searchlist;
68 %ignore ldns_struct_resolver::_nameservers;
69 %ignore ldns_resolver_set_nameservers;
70 
71 %rename(ldns_resolver) ldns_struct_resolver;
72 
73 
74 /* Clone data on pull. */
75 
76 %newobject _ldns_axfr_last_pkt;
77 %rename(__ldns_axfr_last_pkt) ldns_axfr_last_pkt;
78 %inline
79 %{
_ldns_axfr_last_pkt(const ldns_resolver * res)80   ldns_pkt * _ldns_axfr_last_pkt(const ldns_resolver *res)
81   {
82     return ldns_pkt_clone(ldns_axfr_last_pkt(res));
83   }
84 %}
85 
86 %newobject _ldns_resolver_dnssec_anchors;
87 %rename(__ldns_resolver_dnssec_anchors) ldns_resolver_dnssec_anchors;
88 %inline
89 %{
_ldns_resolver_dnssec_anchors(const ldns_resolver * res)90   ldns_rr_list * _ldns_resolver_dnssec_anchors(const ldns_resolver *res)
91   {
92     return ldns_rr_list_clone(ldns_resolver_dnssec_anchors(res));
93   }
94 %}
95 
96 %newobject _ldns_resolver_domain;
97 %rename(__ldns_resolver_domain) ldns_resolver_domain;
98 %inline
99 %{
_ldns_resolver_domain(const ldns_resolver * res)100   ldns_rdf * _ldns_resolver_domain(const ldns_resolver *res)
101   {
102     /* Prevents assertion failures. */
103     ldns_rdf *rdf;
104     rdf = ldns_resolver_domain(res);
105     if (rdf != NULL) {
106       rdf = ldns_rdf_clone(rdf);
107     }
108     return rdf;
109   }
110 %}
111 
112 %newobject _ldns_resolver_tsig_algorithm;
113 %rename(__ldns_resolver_tsig_algorithm) ldns_resolver_tsig_algorithm;
114 %inline
115 %{
_ldns_resolver_tsig_algorithm(const ldns_resolver * res)116   const char * _ldns_resolver_tsig_algorithm(const ldns_resolver *res)
117   {
118     const char *str;
119     str = ldns_resolver_tsig_algorithm(res);
120     if (str != NULL) {
121       str = strdup(str);
122     }
123     return str;
124   }
125 %}
126 
127 %newobject _ldns_resolver_tsig_keydata;
128 %rename(__ldns_resolver_tsig_keydata) ldns_resolver_tsig_keydata;
129 %inline
130 %{
_ldns_resolver_tsig_keydata(const ldns_resolver * res)131   const char * _ldns_resolver_tsig_keydata(const ldns_resolver *res)
132   {
133     const char *str;
134     str = ldns_resolver_tsig_keydata(res);
135     if (str != NULL) {
136       str = strdup(str);
137     }
138     return str;
139   }
140 %}
141 
142 %newobject _ldns_resolver_tsig_keyname;
143 %rename(__ldns_resolver_tsig_keyname) ldns_resolver_tsig_keyname;
144 %inline
145 %{
_ldns_resolver_tsig_keyname(const ldns_resolver * res)146   const char * _ldns_resolver_tsig_keyname(const ldns_resolver *res)
147   {
148     const char *str;
149     str = ldns_resolver_tsig_keyname(res);
150     if (str != NULL) {
151       str = strdup(str);
152     }
153     return str;
154   }
155 %}
156 
157 /* End of pull cloning. */
158 
159 /* Clone data on push. */
160 
161 %rename(__ldns_resolver_set_dnssec_anchors) ldns_resolver_set_dnssec_anchors;
162 %inline
163 %{
_ldns_resolver_set_dnssec_anchors(ldns_resolver * res,ldns_rr_list * rrl)164   void _ldns_resolver_set_dnssec_anchors(ldns_resolver *res,
165     ldns_rr_list * rrl)
166   {
167     ldns_rr_list *rrl_clone = NULL;
168     if (rrl != NULL) {
169       rrl_clone = ldns_rr_list_clone(rrl);
170     }
171     /* May leak memory, when overwriting pointer value. */
172     ldns_resolver_set_dnssec_anchors(res, rrl_clone);
173   }
174 %}
175 
176 %rename(__ldns_resolver_set_domain) ldns_resolver_set_domain;
177 %inline
178 %{
_ldns_resolver_set_domain(ldns_resolver * res,ldns_rdf * rdf)179   void _ldns_resolver_set_domain(ldns_resolver *res, ldns_rdf *rdf)
180   {
181     ldns_rdf *rdf_clone = NULL;
182     if (rdf != NULL) {
183       rdf_clone = ldns_rdf_clone(rdf);
184     }
185     /* May leak memory, when overwriting pointer value. */
186     ldns_resolver_set_domain(res, rdf_clone);
187   }
188 %}
189 
190 /* End of push cloning. */
191 
192 
193 /* ========================================================================= */
194 /* Debugging related code. */
195 /* ========================================================================= */
196 
197 #ifdef LDNS_DEBUG
198 %rename(__ldns_resolver_deep_free) ldns_resolver_deep_free;
199 %rename(__ldns_resolver_free) ldns_resolver_free;
200 %inline
201 %{
202   /*!
203    * @brief Prints information about deallocated resolver and deallocates.
204    */
_ldns_resolver_deep_free(ldns_resolver * r)205   void _ldns_resolver_deep_free(ldns_resolver *r)
206   {
207     printf("******** LDNS_RESOLVER deep free 0x%lX ************\n",
208       (long unsigned int) r);
209     ldns_resolver_deep_free(r);
210   }
211 
212   /*!
213    * @brief Prints information about deallocated resolver and deallocates.
214    *
215    * @note There should be no need to use this function in the wrapper code, as
216    *    it is likely to leak memory.
217    */
_ldns_resolver_free(ldns_resolver * r)218   void _ldns_resolver_free(ldns_resolver *r)
219   {
220     printf("******** LDNS_RESOLVER free 0x%lX ************\n",
221       (long unsigned int) r);
222     ldns_resolver_free(r);
223   }
224 %}
225 #else /* !LDNS_DEBUG */
226 %rename(_ldns_resolver_deep_free) ldns_resolver_deep_free;
227 %rename(_ldns_resolver_free) ldns_resolver_free;
228 #endif /* LDNS_DEBUG */
229 
230 
231 /* ========================================================================= */
232 /* Added C code. */
233 /* ========================================================================= */
234 
235 %newobject _replacement_ldns_resolver_trusted_key;
236 %inline
237 %{
238   /*!
239    * @brief Replaces the rrs in the list with their clones.
240    *
241    * Prevents memory corruption when automatically deallocating list content.
242    */
_rr_list_replace_content_with_clones(ldns_rr_list * rrl)243   void _rr_list_replace_content_with_clones(ldns_rr_list *rrl)
244   {
245     size_t count;
246     unsigned int i;
247 
248     if (rrl == NULL) {
249       return;
250     }
251 
252     count = ldns_rr_list_rr_count(rrl);
253     for (i = 0; i < count; ++i) {
254       ldns_rr_list_set_rr(rrl,
255         ldns_rr_clone(ldns_rr_list_rr(rrl, i)),
256         i);
257     }
258   }
259 
260   /*
261    * @brief Behaves similarly to ldns_resolver_trusted_key().
262    *
263    * Prevents memory leakage by controlling the usage of content cloning.
264    *
265    * @return Newly allocated list of trusted key clones if any found,
266    *     NULL else.
267    */
_replacement_ldns_resolver_trusted_key(const ldns_resolver * res,ldns_rr_list * keys)268   ldns_rr_list * _replacement_ldns_resolver_trusted_key(
269     const ldns_resolver *res, ldns_rr_list *keys)
270   {
271     ldns_rr_list *trusted_keys = ldns_rr_list_new();
272 
273     if (ldns_resolver_trusted_key(res, keys, trusted_keys)) {
274       _rr_list_replace_content_with_clones(trusted_keys);
275     } else {
276       ldns_rr_list_deep_free(trusted_keys); trusted_keys = NULL;
277     }
278 
279     return trusted_keys;
280   }
281 %}
282 
283 
284 /* ========================================================================= */
285 /* Encapsulating Python code. */
286 /* ========================================================================= */
287 
288 %feature("docstring") ldns_struct_resolver "LDNS resolver object.
289 
290 The :class:`ldns_resolver` object keeps a list of name servers and can perform
291 queries.
292 
293 **Usage**
294 
295 >>> import ldns
296 >>> resolver = ldns.ldns_resolver.new_frm_file(\"/etc/resolv.conf\")
297 >>> pkt = resolver.query(\"www.nic.cz\", ldns.LDNS_RR_TYPE_A,ldns.LDNS_RR_CLASS_IN)
298 >>> if (pkt) and (pkt.answer()):
299 >>>    print pkt.answer()
300 www.nic.cz.	1757	IN	A	217.31.205.50
301 
302 This simple example instances a resolver in order to resolve www.nic.cz A type
303 record."
304 
305 %extend ldns_struct_resolver {
306 
307   %pythoncode
308   %{
309         def __init__(self):
310             """
311                Cannot be created directly from Python.
312             """
313             raise Exception("This class can't be created directly. " +
314                 "Please use: new_frm_file(filename), new_frm_fp(file) " +
315                 "or new_frm_fp_l(file, line)")
316 
317         __swig_destroy__ = _ldns._ldns_resolver_deep_free
318 
319         #
320         # LDNS_RESOLVER_CONSTRUCTORS_
321         #
322 
323         @staticmethod
324         def new():
325             """
326                Creates a new resolver object.
327 
328                :return: (:class:`ldns_resolver`) New resolver object or None.
329 
330                .. note::
331                    The returned resolver object is unusable unless some
332                    name servers are added.
333 
334                **Usage**
335                  >>> resolver = ldns.ldns_resolver.new()
336                  >>> ns_addr = ldns.ldns_rdf.new_frm_str("8.8.8.8", ldns.LDNS_RDF_TYPE_A)
337                  >>> if not ns_addr: raise Exception("Can't create resolver address.")
338                  >>> status = resolver.push_nameserver(ns_addr)
339                  >>> if status != ldns.LDNS_STATUS_OK: raise Exception("Can't push resolver address.")
340                  >>> pkt = resolver.query("www.nic.cz.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
341                  >>> if (pkt) and (pkt.answer()):
342                  >>>     print pkt.answer()
343                  www.nic.cz.     1265    IN      A       217.31.205.50
344             """
345             return _ldns.ldns_resolver_new()
346 
347         @staticmethod
348         def new_frm_file(filename = "/etc/resolv.conf", raiseException=True):
349             """
350                Creates a resolver object from given file name
351 
352                :param filename: Name of file which contains resolver
353                    informations (usually /etc/resolv.conf).
354                :type filename: str
355                :param raiseException: If True, an exception occurs in case a
356                    resolver object can't be created.
357                :type raiseException: bool
358                :throws TypeError: When arguments of inappropriate types.
359                :throws Exception: When `raiseException` set and resolver
360                    couldn't be created.
361                :return: (:class:`ldns_resolver`) Resolver object or None.
362                    An exception occurs if the object can't be created and
363                    'raiseException' is True.
364             """
365             status, resolver = _ldns.ldns_resolver_new_frm_file(filename)
366             if status != LDNS_STATUS_OK:
367                 if (raiseException):
368                     raise Exception("Can't create resolver, error: %d" % status)
369                 return None
370             return resolver
371 
372         @staticmethod
373         def new_frm_fp(file, raiseException=True):
374             """
375                Creates a resolver object from file
376 
377                :param file: A file object.
378                :type file: file
379                :param raiseException: If True, an exception occurs in case a
380                    resolver object can't be created.
381                :type raiseException: bool
382                :throws TypeError: When arguments of inappropriate types.
383                :throws Exception: When `raiseException` set and resolver
384                    couldn't be created.
385                :return: (:class:`ldns_resolver`) Resolver object or None.
386                    An exception occurs if the object can't be created and
387                    `raiseException` is True.
388             """
389             status, resolver = _ldns.ldns_resolver_new_frm_fp(file)
390             if status != LDNS_STATUS_OK:
391                 if (raiseException):
392                     raise Exception("Can't create resolver, error: %d" % status)
393                 return None
394             return resolver
395 
396         @staticmethod
397         def new_frm_fp_l(file, raiseException=True):
398             """
399                Creates a resolver object from file
400 
401                :param file: A file object.
402                :type file: file
403                :param raiseException: If True, an exception occurs in case a
404                    resolver instance can't be created.
405                :type raiseException: bool
406                :throws TypeError: When arguments of inappropriate types.
407                :throws Exception: When `raiseException` set and resolver
408                    couldn't be created.
409                :return:
410                   * (:class:`ldns_resolver`) Resolver instance or None.
411                       An exception occurs if an instance can't be created and
412                       `raiseException` is True.
413 
414                   * (int) - The line number. (e.g., for debugging)
415             """
416             status, resolver, line = _ldns.ldns_resolver_new_frm_fp_l(file)
417             if status != LDNS_STATUS_OK:
418                 if (raiseException):
419                     raise Exception("Can't create resolver, error: %d" % status)
420                 return None
421             return resolver, line
422 
423         #
424         # _LDNS_RESOLVER_CONSTRUCTORS
425         #
426 
427         # High level functions
428 
429         def get_addr_by_name(self, name, aclass = _ldns.LDNS_RR_CLASS_IN, flags = _ldns.LDNS_RD):
430             """
431                Ask the resolver about name and return all address records.
432 
433                :param name: The name to look for. String is automatically
434                    converted to dname.
435                :type name: :class:`ldns_dname` or str
436                :param aclass: The class to use.
437                :type aclass: ldns_rr_class
438                :param flags: Give some optional flags to the query.
439                :type flags: uint16_t
440                :throws TypeError: When arguments of inappropriate types.
441                :return: (:class:`ldns_rr_list`) RR List object or None.
442 
443                **Usage**
444                  >>> addr = resolver.get_addr_by_name("www.google.com", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
445                  >>> if (not addr): raise Exception("Can't retrieve server address")
446                  >>> for rr in addr.rrs():
447                  >>>     print rr
448                  www.l.google.com.	300	IN	A	74.125.43.99
449                  www.l.google.com.	300	IN	A	74.125.43.103
450                  www.l.google.com.	300	IN	A	74.125.43.104
451                  www.l.google.com.	300	IN	A	74.125.43.147
452             """
453             rdf = name
454             if isinstance(name, str):
455                 rdf =  _ldns.ldns_dname_new_frm_str(name)
456             return _ldns.ldns_get_rr_list_addr_by_name(self, rdf, aclass, flags)
457 
458         def get_name_by_addr(self, addr, aclass = _ldns.LDNS_RR_CLASS_IN, flags = _ldns.LDNS_RD):
459             """
460                Ask the resolver about the address and return the name.
461 
462                :param name: (ldns_rdf of A or AAAA type) the addr to look for.
463                    If a string is given, A or AAAA type is identified
464                    automatically.
465                :type name: :class:`ldns_rdf` of A or AAAA type
466                :param aclass: The class to use.
467                :type aclass: ldns_rr_class
468                :param flags: Give some optional flags to the query.
469                :type flags: uint16_t
470                :throws TypeError: When arguments of inappropriate types.
471                :return: (:class:`ldns_rr_list`) RR List object or None.
472 
473                **Usage**
474                  >>> addr = resolver.get_name_by_addr("74.125.43.99", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
475                  >>> if (not addr): raise Exception("Can't retrieve server address")
476                  >>> for rr in addr.rrs():
477                  >>>     print rr
478                  99.43.125.74.in-addr.arpa.	85641	IN	PTR	bw-in-f99.google.com.
479 
480             """
481             rdf = addr
482             if isinstance(addr, str):
483                 if (addr.find("::") >= 0): #IPv6
484                     rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_AAAA, addr)
485                 else:
486                     rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_A, addr)
487             return _ldns.ldns_get_rr_list_name_by_addr(self, rdf, aclass, flags)
488 
489         def print_to_file(self,output):
490             """Print a resolver (in so far that is possible) state to output."""
491             _ldns.ldns_resolver_print(output,self)
492 
493         def axfr_complete(self):
494             """
495                Returns True if the axfr transfer has completed
496                (i.e., 2 SOA RRs and no errors were encountered).
497 
498                :return: (bool)
499             """
500             return _ldns.ldns_axfr_complete(self)
501             #parameters: const ldns_resolver *,
502             #retvals: bool
503 
504         def axfr_last_pkt(self):
505             """
506                Returns a last packet that was sent by the server in the AXFR
507                transfer (usable for instance to get the error code on failure).
508 
509                :return: (:class:`ldns_pkt`) Last packet of the AXFR transfer.
510             """
511             return _ldns._ldns_axfr_last_pkt(self)
512             #parameters: const ldns_resolver *,
513             #retvals: ldns_pkt *
514 
515         def axfr_next(self):
516             """
517                Get the next stream of RRs in a AXFR.
518 
519                :return: (:class:`ldns_rr`) The next RR from the AXFR stream.
520             """
521             return _ldns.ldns_axfr_next(self)
522             #parameters: ldns_resolver *,
523             #retvals: ldns_rr *
524 
525         def axfr_start(self, domain, aclass):
526             """
527                Prepares the resolver for an axfr query. The query is sent and
528                the answers can be read with :meth:`axfr_next`.
529 
530                :param domain: Domain to axfr.
531                :type domain: :class:`dlsn_dname`
532                :param aclass: The class to use.
533                :type aclass: ldns_rr_class
534                :throws TypeError: When arguments of inappropriate types.
535                :return: (ldns_status) The status of the transfer.
536 
537                .. note::
538                    The type checking of parameter `domain` is benevolent.
539                    It allows also to pass a dname :class:`ldns_rdf` object.
540                    This will probably change in future.
541 
542                **Usage**
543                ::
544 
545                   status = resolver.axfr_start("nic.cz", ldns.LDNS_RR_CLASS_IN)
546                   if (status != ldns.LDNS_STATUS_OK):
547                       raise Exception("Can't start AXFR, error: %s" % ldns.ldns_get_errorstr_by_id(status))
548                   #Print the results
549                   while True:
550                        rr = resolver.axfr_next()
551                        if not rr:
552                           break
553 
554                        print rr
555             """
556             # TODO -- Add checking for ldns_rdf and ldns_dname.
557             rdf = domain
558             if isinstance(domain, str):
559                 rdf = _ldns.ldns_dname_new_frm_str(domain)
560             return _ldns.ldns_axfr_start(self, rdf, aclass)
561             #parameters: ldns_resolver *resolver, ldns_rdf *domain, ldns_rr_class c
562             #retvals: int
563 
564         #
565         # LDNS_RESOLVER_METHODS_
566         #
567 
568         def debug(self):
569             """
570                Get the debug status of the resolver.
571 
572                :return: (bool) True if so, otherwise False.
573             """
574             return _ldns.ldns_resolver_debug(self)
575             #parameters: const ldns_resolver *,
576             #retvals: bool
577 
578         def dec_nameserver_count(self):
579             """
580                Decrement the resolver's name server count.
581             """
582             _ldns.ldns_resolver_dec_nameserver_count(self)
583             #parameters: ldns_resolver *,
584             #retvals:
585 
586         def defnames(self):
587             """
588                Does the resolver apply default domain name.
589 
590                :return: (bool)
591             """
592             return _ldns.ldns_resolver_defnames(self)
593             #parameters: const ldns_resolver *,
594             #retvals: bool
595 
596         def dnsrch(self):
597             """
598                Does the resolver apply search list.
599 
600                :return: (bool)
601             """
602             return _ldns.ldns_resolver_dnsrch(self)
603             #parameters: const ldns_resolver *,
604             #retvals: bool
605 
606         def dnssec(self):
607             """
608                Does the resolver do DNSSEC.
609 
610                :return: (bool) True: yes, False: no.
611             """
612             return _ldns.ldns_resolver_dnssec(self)
613             #parameters: const ldns_resolver *,
614             #retvals: bool
615 
616         def dnssec_anchors(self):
617             """
618                Get the resolver's DNSSEC anchors.
619 
620                :return: (:class:`ldns_rr_list`) An rr list containing trusted
621                    DNSSEC anchors.
622             """
623             return _ldns._ldns_resolver_dnssec_anchors(self)
624             #parameters: const ldns_resolver *,
625             #retvals: ldns_rr_list *
626 
627         def dnssec_cd(self):
628             """
629                Does the resolver set the CD bit.
630 
631                :return: (bool) True: yes, False: no.
632             """
633             return _ldns.ldns_resolver_dnssec_cd(self)
634             #parameters: const ldns_resolver *,
635             #retvals: bool
636 
637         def domain(self):
638             """
639                What is the default dname to add to relative queries.
640 
641                :return: (:class:`ldns_dname`) The dname which is added.
642             """
643             dname = _ldns._ldns_resolver_domain(self)
644             if dname != None:
645                 return ldns_dname(_ldns._ldns_resolver_domain(self), clone=False)
646             else:
647                 return dname
648             #parameters: const ldns_resolver *,
649             #retvals: ldns_rdf *
650 
651         def edns_udp_size(self):
652             """
653                Get the resolver's udp size.
654 
655                :return: (uint16_t) The udp mesg size.
656             """
657             return _ldns.ldns_resolver_edns_udp_size(self)
658             #parameters: const ldns_resolver *,
659             #retvals: uint16_t
660 
661         def fail(self):
662             """
663                Does the resolver only try the first name server.
664 
665                :return: (bool) True: yes, fail, False: no, try the others.
666             """
667             return _ldns.ldns_resolver_fail(self)
668             #parameters: const ldns_resolver *,
669             #retvals: bool
670 
671         def fallback(self):
672             """
673                Get the truncation fall-back status.
674 
675                :return: (bool) Whether the truncation fall*back mechanism
676                    is used.
677             """
678             return _ldns.ldns_resolver_fallback(self)
679             #parameters: const ldns_resolver *,
680             #retvals: bool
681 
682         def igntc(self):
683             """
684                Does the resolver ignore the TC bit (truncated).
685 
686                :return: (bool) True: yes, False: no.
687             """
688             return _ldns.ldns_resolver_igntc(self)
689             #parameters: const ldns_resolver *,
690             #retvals: bool
691 
692         def incr_nameserver_count(self):
693             """
694                Increment the resolver's name server count.
695             """
696             _ldns.ldns_resolver_incr_nameserver_count(self)
697             #parameters: ldns_resolver *,
698             #retvals:
699 
700         def ip6(self):
701             """
702                Does the resolver use ip6 or ip4.
703 
704                :return: (uint8_t) 0: both, 1: ip4, 2:ip6
705             """
706             return _ldns.ldns_resolver_ip6(self)
707             #parameters: const ldns_resolver *,
708             #retvals: uint8_t
709 
710         def nameserver_count(self):
711             """
712                How many name server are configured in the resolver.
713 
714                :return: (size_t) Number of name servers.
715             """
716             return _ldns.ldns_resolver_nameserver_count(self)
717             #parameters: const ldns_resolver *,
718             #retvals: size_t
719 
720         def nameserver_rtt(self, pos):
721             """
722                Return the used round trip time for a specific name server.
723 
724                :param pos: The index to the name server.
725                :type pos: size_t
726                :throws TypeError: When arguments of inappropriate types.
727                :return: (size_t) The rrt, 0: infinite,
728                    >0: undefined (as of * yet).
729             """
730             return _ldns.ldns_resolver_nameserver_rtt(self, pos)
731             #parameters: const ldns_resolver *,size_t,
732             #retvals: size_t
733 
734         def nameservers(self):
735             """
736                Return the configured name server ip address.
737 
738                :return: (ldns_rdf \*\*) A ldns_rdf pointer to a list of the
739                    addresses.
740             """
741             # TODO -- Convert to list of ldns_rdf.
742             return _ldns.ldns_resolver_nameservers(self)
743             #parameters: const ldns_resolver *,
744             #retvals: ldns_rdf **
745 
746         def nameservers_randomize(self):
747             """
748                Randomize the name server list in the resolver.
749             """
750             _ldns.ldns_resolver_nameservers_randomize(self)
751             #parameters: ldns_resolver *,
752             #retvals:
753 
754         def pop_nameserver(self):
755             """
756                Pop the last name server from the resolver.
757 
758                :return: (:class:`ldns_rdf`) The popped address or None if empty.
759             """
760             return _ldns.ldns_resolver_pop_nameserver(self)
761             #parameters: ldns_resolver *,
762             #retvals: ldns_rdf *
763 
764         def port(self):
765             """
766                Get the port the resolver should use.
767 
768                :return: (uint16_t) The port number.
769             """
770             return _ldns.ldns_resolver_port(self)
771             #parameters: const ldns_resolver *,
772             #retvals: uint16_t
773 
774         def prepare_query_pkt(self, name, t, c, f, raiseException=True):
775             """
776                Form a query packet from a resolver and name/type/class combo.
777 
778                :param name: Query for this name.
779                :type name: :class:`ldns_dname` or str
780                :param t: Query for this type (may be 0, defaults to A).
781                :type t: ldns_rr_type
782                :param c: Query for this class (may be 0, default to IN).
783                :type c: ldns_rr_class
784                :param f: The query flags.
785                :type f: uint16_t
786                :throws TypeError: When arguments of inappropriate types.
787                :throws Exception: When `raiseException` set and answer
788                    couldn't be resolved.
789                :return: (:class:`ldns_pkt`) Query packet or None.
790                    An exception occurs if the object can't be created and
791                    'raiseException' is True.
792             """
793             rdf = name
794             if isinstance(name, str):
795                 rdf = _ldns.ldns_dname_new_frm_str(name)
796             status, pkt = _ldns.ldns_resolver_prepare_query_pkt(self, rdf, t, c, f)
797             if status != LDNS_STATUS_OK:
798                 if (raiseException):
799                     raise Exception("Can't create resolver, error: %d" % status)
800                 return None
801             return pkt
802             #parameters: ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
803             #retvals: ldns_status,ldns_pkt **
804 
805         def push_dnssec_anchor(self, rr):
806             """
807                Push a new trust anchor to the resolver.
808                It must be a DS or DNSKEY rr.
809 
810                :param rr: The RR to add as a trust anchor.
811                :type rr: DS of DNSKEY :class:`ldns_rr`
812                :throws TypeError: When arguments of inappropriate types.
813                :return: (ldns_status) A status.
814             """
815             return _ldns.ldns_resolver_push_dnssec_anchor(self, rr)
816             #parameters: ldns_resolver *,ldns_rr *,
817             #retvals: ldns_status
818 
819         def push_nameserver(self, n):
820             """
821                Push a new name server to the resolver.
822                It must be an IP address v4 or v6.
823 
824                :param n: The ip address.
825                :type n: :class:`ldns_rdf` of A or AAAA type.
826                :throws TypeError: When arguments of inappropriate types.
827                :return: (ldns_status) A status.
828             """
829             return _ldns.ldns_resolver_push_nameserver(self, n)
830             #parameters: ldns_resolver *,ldns_rdf *,
831             #retvals: ldns_status
832 
833         def push_nameserver_rr(self, rr):
834             """
835                Push a new name server to the resolver.
836                It must be an A or AAAA RR record type.
837 
838                :param rr: The resource record.
839                :type rr: :class:`ldns_rr` of A or AAAA type.
840                :throws TypeError: When arguments of inappropriate types.
841                :return: (ldns_status) A status.
842             """
843             return _ldns.ldns_resolver_push_nameserver_rr(self, rr)
844             #parameters: ldns_resolver *,ldns_rr *,
845             #retvals: ldns_status
846 
847         def push_nameserver_rr_list(self, rrlist):
848             """
849                Push a new name server rr_list to the resolver.
850 
851                :param rrlist: The rr list to push.
852                :type rrlist: :class:`ldns_rr_list`
853                :throws TypeError: When arguments of inappropriate types.
854                :return: (ldns_status) A status.
855             """
856             return _ldns.ldns_resolver_push_nameserver_rr_list(self, rrlist)
857             #parameters: ldns_resolver *,ldns_rr_list *,
858             #retvals: ldns_status
859 
860         def push_searchlist(self, rd):
861             """
862                Push a new rd to the resolver's search-list.
863 
864                :param rd: To push.
865                :param rd: :class:`ldns_dname` or str
866                :throws TypeError: When arguments of inappropriate types.
867 
868                .. note:
869                    The function does not return any return status,
870                    so the caller must ensure the correctness of the passed
871                    values.
872             """
873             rdf = rd
874             if isinstance(rd, str):
875                 rdf = _ldns.ldns_dname_new_frm_str(rd)
876             _ldns.ldns_resolver_push_searchlist(self, rdf)
877             #parameters: ldns_resolver *,ldns_rdf *,
878             #retvals:
879 
880         def query(self,name,atype=_ldns.LDNS_RR_TYPE_A,aclass=_ldns.LDNS_RR_CLASS_IN,flags=_ldns.LDNS_RD):
881             """
882                Send a query to a name server.
883 
884                :param name: The name to look for.
885                :type name: :class:`ldns_dname` or str
886                :param atype: The RR type to use.
887                :type atype: ldns_rr_type
888                :param aclass: The RR class to use.
889                :type aclass: ldns_rr_class
890                :param flags: Give some optional flags to the query.
891                :type flags: uint16_t
892                :throws TypeError: When arguments of inappropriate types.
893                :return: (:class:`ldns_pkt`) A packet with the reply from the
894                    name server if _defnames is true the default domain will
895                    be added.
896             """
897             # Explicit conversion from string to ldns_rdf prevents memory leaks.
898             # TODO -- Find out why.
899             dname = name
900             if isinstance(name, str):
901                 dname = _ldns.ldns_dname_new_frm_str(name)
902             return _ldns.ldns_resolver_query(self, dname, atype, aclass, flags)
903             #parameters: const ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
904             #retvals: ldns_pkt *
905 
906         def random(self):
907             """
908                Does the resolver randomize the name server before usage?
909 
910                :return: (bool) True: yes, False: no.
911             """
912             return _ldns.ldns_resolver_random(self)
913             #parameters: const ldns_resolver *,
914             #retvals: bool
915 
916         def recursive(self):
917             """
918                Is the resolver set to recurse?
919 
920                :return: (bool) True if so, otherwise False.
921             """
922             return _ldns.ldns_resolver_recursive(self)
923             #parameters: const ldns_resolver *,
924             #retvals: bool
925 
926         def retrans(self):
927             """
928                Get the retransmit interval.
929 
930                :return: (uint8_t) The retransmit interval.
931             """
932             return _ldns.ldns_resolver_retrans(self)
933             #parameters: const ldns_resolver *,
934             #retvals: uint8_t
935 
936         def retry(self):
937             """
938                Get the number of retries.
939 
940                :return: (uint8_t) The number of retries.
941             """
942             return _ldns.ldns_resolver_retry(self)
943             #parameters: const ldns_resolver *,
944             #retvals: uint8_t
945 
946         def rtt(self):
947             """
948                Return the used round trip times for the name servers.
949 
950                :return: (size_t \*) a size_t* pointer to the list. yet)
951             """
952             return _ldns.ldns_resolver_rtt(self)
953             #parameters: const ldns_resolver *,
954             #retvals: size_t *
955 
956         def search(self, name, atype=_ldns.LDNS_RR_TYPE_A, aclass=_ldns.LDNS_RR_CLASS_IN, flags=_ldns.LDNS_RD):
957             """
958                Send the query for using the resolver and take the search list
959                into account The search algorithm is as follows: If the name is
960                absolute, try it as-is, otherwise apply the search list.
961 
962                :param name: The name to look for.
963                :type name: :class:`ldns_dname` or str
964                :param atype: The RR type to use.
965                :type atype: ldns_rr_type
966                :param aclass: The RR class to use.
967                :type aclass: ldns_rr_class
968                :param flags: Give some optional flags to the query.
969                :type flags: uint16_t
970                :throws TypeError: When arguments of inappropriate types.
971                :return: (:class:`ldns_pkt`) A packet with the reply from the
972                    name server.
973             """
974             # Explicit conversion from string to ldns_rdf prevents memory leaks.
975             # TODO -- Find out why.
976             dname = name
977             if isinstance(name, str):
978                 dname = _ldns.ldns_dname_new_frm_str(name)
979             return _ldns.ldns_resolver_search(self, dname, atype, aclass, flags)
980             #parameters: const ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
981             #retvals: ldns_pkt *
982 
983         def searchlist(self):
984             """
985                What is the search-list as used by the resolver.
986 
987                :return: (ldns_rdf \*\*) A ldns_rdf pointer to a list of the addresses.
988             """
989             return _ldns.ldns_resolver_searchlist(self)
990             #parameters: const ldns_resolver *,
991             #retvals: ldns_rdf \*\*
992 
993         def searchlist_count(self):
994             """
995                Return the resolver's search-list count.
996 
997                :return: (size_t) The search-list count.
998             """
999             return _ldns.ldns_resolver_searchlist_count(self)
1000             #parameters: const ldns_resolver *,
1001             #retvals: size_t
1002 
1003         def send(self, name, atype, aclass, flags, raiseException=True):
1004             """
1005                Send the query for name as-is.
1006 
1007                :param name: The name to look for.
1008                :type name: :class:`ldns_dname` or str
1009                :param atype: The RR type to use.
1010                :type atype: ldns_rr_type
1011                :param aclass: The RR class to use.
1012                :type aclass: ldns_rr_class
1013                :param flags: Give some optional flags to the query.
1014                :type flags: uint16_t
1015                :throws TypeError: When arguments of inappropriate types.
1016                :throws Exception: When `raiseException` set and answer
1017                    couldn't be resolved.
1018                :return: (:class:`ldns_pkt`) A packet with the reply from the
1019                    name server.
1020             """
1021             # Explicit conversion from string to ldns_rdf prevents memory leaks.
1022             # TODO -- Find out why.
1023             dname = name
1024             if isinstance(name, str):
1025                 dname = _ldns.ldns_dname_new_frm_str(name)
1026             status, pkt = _ldns.ldns_resolver_send(self, dname, atype, aclass, flags)
1027             if status != LDNS_STATUS_OK:
1028                 if (raiseException):
1029                     raise Exception("Can't create resolver, error: %d" % status)
1030                 return None
1031             return pkt
1032             #parameters: ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
1033             #retvals: ldns_status,ldns_pkt **
1034 
1035         def send_pkt(self, query_pkt):
1036             """
1037                Send the given packet to a name server.
1038 
1039                :param query_pkt: Query packet.
1040                :type query_pkt: :class:`ldns_pkt`
1041                :throws TypeError: When arguments of inappropriate types.
1042                :return: * (ldns_status) Return status.
1043                         * (:class:`ldns_pkt`) Response packet if returns status ok.
1044             """
1045             status, answer = _ldns.ldns_resolver_send_pkt(self, query_pkt)
1046             return _ldns.ldns_resolver_send_pkt(self,query_pkt)
1047             #parameters: ldns_resolver *,ldns_pkt *,
1048             #retvals: ldns_status,ldns_pkt **
1049 
1050         def set_debug(self, b):
1051             """
1052                Set the resolver debugging.
1053 
1054                :param b: True: debug on, False: debug off.
1055                :type b: bool
1056             """
1057             _ldns.ldns_resolver_set_debug(self, b)
1058             #parameters: ldns_resolver *,bool,
1059             #retvals:
1060 
1061         def set_defnames(self, b):
1062             """
1063                Whether the resolver uses the name set with _set_domain.
1064 
1065                :param b: True: use the defaults, False: don't use them.
1066                :type b: bool
1067             """
1068             _ldns.ldns_resolver_set_defnames(self, b)
1069             #parameters: ldns_resolver *,bool,
1070             #retvals:
1071 
1072         def set_dnsrch(self, b):
1073             """
1074                Whether the resolver uses the search list.
1075 
1076                :param b: True: use the list, False: don't use the list.
1077                :type b: bool
1078             """
1079             _ldns.ldns_resolver_set_dnsrch(self, b)
1080             #parameters: ldns_resolver *,bool,
1081             #retvals:
1082 
1083         def set_dnssec(self, b):
1084             """
1085                Whether the resolver uses DNSSEC.
1086 
1087                :param b: True: use DNSSEC, False: don't use DNSSEC.
1088                :type b: bool
1089             """
1090             _ldns.ldns_resolver_set_dnssec(self, b)
1091             #parameters: ldns_resolver *,bool,
1092             #retvals:
1093 
1094         def set_dnssec_anchors(self, l):
1095             """
1096                Set the resolver's DNSSEC anchor list directly.
1097                RRs should be of type DS or DNSKEY.
1098 
1099                :param l: The list of RRs to use as trust anchors.
1100                :type l: :class:`ldns_rr_list`
1101                :throws TypeError: When arguments of inappropriate types.
1102             """
1103             _ldns._ldns_resolver_set_dnssec_anchors(self, l)
1104             #parameters: ldns_resolver *,ldns_rr_list *,
1105             #retvals:
1106 
1107         def set_dnssec_cd(self, b):
1108             """
1109                Whether the resolver uses the checking disable bit.
1110 
1111                :param b: True: enable, False: disable.
1112                :type b: bool
1113             """
1114             _ldns.ldns_resolver_set_dnssec_cd(self, b)
1115             #parameters: ldns_resolver *,bool,
1116             #retvals:
1117 
1118         def set_domain(self, rd):
1119             """
1120                Set the resolver's default domain.
1121                This gets appended when no absolute name is given.
1122 
1123                :param rd: The name to append.
1124                :type rd: :class:`ldns_dname` or str
1125                :throws TypeError: When arguments of inappropriate types.
1126                :throws Exception: When `rd` a non dname rdf.
1127 
1128                .. note::
1129                    The type checking of parameter `rd` is benevolent.
1130                    It allows also to pass a dname :class:`ldns_rdf` object.
1131                    This will probably change in future.
1132             """
1133             # Also has to be able to pass None or dame string.
1134             if isinstance(rd, str):
1135                 dname = _ldns.ldns_dname_new_frm_str(rd)
1136             elif (not isinstance(rd, ldns_dname)) and \
1137                isinstance(rd, ldns_rdf) and \
1138                rd.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
1139                 warnings.warn("The ldns_resolver.set_domain() method" +
1140                     " will drop the possibility to accept ldns_rdf." +
1141                     " Convert argument to ldns_dname.",
1142                     PendingDeprecationWarning, stacklevel=2)
1143                 dname = rd
1144             else:
1145                 dname = rd
1146             if (not isinstance(dname, ldns_rdf)) and (dname != None):
1147                 raise TypeError("Parameter must be derived from ldns_rdf.")
1148             if (isinstance(dname, ldns_rdf)) and \
1149                (dname.get_type() != _ldns.LDNS_RDF_TYPE_DNAME):
1150                 raise Exception("Operands must be ldns_dname.")
1151             _ldns._ldns_resolver_set_domain(self, dname)
1152             #parameters: ldns_resolver *,ldns_rdf *,
1153             #retvals:
1154 
1155         def set_edns_udp_size(self, s):
1156             """
1157                Set maximum udp size.
1158 
1159                :param s: The udp max size.
1160                :type s: uint16_t
1161                :throws TypeError: When arguments of inappropriate types.
1162             """
1163             _ldns.ldns_resolver_set_edns_udp_size(self,s)
1164             #parameters: ldns_resolver *,uint16_t,
1165             #retvals:
1166 
1167         def set_fail(self, b):
1168             """
1169                Whether or not to fail after one failed query.
1170 
1171                :param b: True: yes fail, False: continue with next name server.
1172                :type b: bool
1173             """
1174             _ldns.ldns_resolver_set_fail(self, b)
1175             #parameters: ldns_resolver *,bool,
1176             #retvals:
1177 
1178         def set_fallback(self, fallback):
1179             """
1180                Set whether the resolvers truncation fall-back mechanism is used
1181                when :meth:`query` is called.
1182 
1183                :param fallback: Whether to use the fall-back mechanism.
1184                :type fallback: bool
1185             """
1186             _ldns.ldns_resolver_set_fallback(self, fallback)
1187             #parameters: ldns_resolver *,bool,
1188             #retvals:
1189 
1190         def set_igntc(self, b):
1191             """
1192                Whether or not to ignore the TC bit.
1193 
1194                :param b: True: yes ignore, False: don't ignore.
1195                :type b: bool
1196             """
1197             _ldns.ldns_resolver_set_igntc(self, b)
1198             #parameters: ldns_resolver *,bool,
1199             #retvals:
1200 
1201         def set_ip6(self, i):
1202             """
1203                Whether the resolver uses ip6.
1204 
1205                :param i: 0: no pref, 1: ip4, 2: ip6
1206                :type i: uint8_t
1207                :throws TypeError: When arguments of inappropriate types.
1208             """
1209             _ldns.ldns_resolver_set_ip6(self, i)
1210             #parameters: ldns_resolver *,uint8_t,
1211             #retvals:
1212 
1213         def set_nameserver_count(self, c):
1214             """
1215                Set the resolver's name server count directly.
1216 
1217                :param c: The name server count.
1218                :type c: size_t
1219                :throws TypeError: When arguments of inappropriate types.
1220             """
1221             _ldns.ldns_resolver_set_nameserver_count(self, c)
1222             #parameters: ldns_resolver *,size_t,
1223             #retvals:
1224 
1225         def set_nameserver_rtt(self, pos, value):
1226             """
1227                Set round trip time for a specific name server.
1228                Note this currently differentiates between: unreachable and
1229                reachable.
1230 
1231                :param pos: The name server position.
1232                :type pos: size_t
1233                :param value: The rtt.
1234                :type value: size_t
1235                :throws TypeError: When arguments of inappropriate types.
1236             """
1237             _ldns.ldns_resolver_set_nameserver_rtt(self, pos, value)
1238             #parameters: ldns_resolver *,size_t,size_t,
1239             #retvals:
1240 
1241         def set_nameservers(self, rd):
1242             """
1243                Set the resolver's name server count directly by using an
1244                rdf list.
1245 
1246                :param rd: The resolver addresses.
1247                :type rd: ldns_rdf \*\*
1248                :throws TypeError: When arguments of inappropriate types.
1249             """
1250             _ldns.ldns_resolver_set_nameservers(self, rd)
1251             #parameters: ldns_resolver *,ldns_rdf **,
1252             #retvals:
1253 
1254         def set_port(self, p):
1255             """
1256                Set the port the resolver should use.
1257 
1258                :param p: The port number.
1259                :type p: uint16_t
1260                :throws TypeError: When arguments of inappropriate types.
1261             """
1262             _ldns.ldns_resolver_set_port(self, p)
1263             #parameters: ldns_resolver *,uint16_t,
1264             #retvals:
1265 
1266         def set_random(self, b):
1267             """
1268                Should the name server list be randomized before each use.
1269 
1270                :param b: True: randomize, False: don't.
1271                :type b: bool
1272             """
1273             _ldns.ldns_resolver_set_random(self, b)
1274             #parameters: ldns_resolver *,bool,
1275             #retvals:
1276 
1277         def set_recursive(self, b):
1278             """
1279                Set the resolver recursion.
1280 
1281                :param b: True: set to recurse, False: unset.
1282                :type b: bool
1283             """
1284             _ldns.ldns_resolver_set_recursive(self, b)
1285             #parameters: ldns_resolver *,bool,
1286             #retvals:
1287 
1288         def set_retrans(self, re):
1289             """
1290                Set the resolver retrans time-out (in seconds).
1291 
1292                :param re: The retransmission interval in seconds.
1293                :type re: uint8_t
1294                :throws TypeError: When arguments of inappropriate types.
1295             """
1296             _ldns.ldns_resolver_set_retrans(self, re)
1297             #parameters: ldns_resolver *,uint8_t,
1298             #retvals:
1299 
1300         def set_retry(self, re):
1301             """
1302                Set the resolver retry interval (in seconds).
1303 
1304                :param re: The retry interval.
1305                :type re: uint8_t
1306                :throws TypeError: When arguments of inappropriate types.
1307             """
1308             _ldns.ldns_resolver_set_retry(self,re)
1309             #parameters: ldns_resolver *,uint8_t,
1310             #retvals:
1311 
1312         def set_rtt(self, rtt):
1313             """
1314                Set round trip time for all name servers.
1315                Note this currently differentiates between: unreachable and reachable.
1316 
1317                :param rtt: A list with the times.
1318                :type rtt: size \*
1319                :throws TypeError: When arguments of inappropriate types.
1320             """
1321             _ldns.ldns_resolver_set_rtt(self, rtt)
1322             #parameters: ldns_resolver *,size_t *,
1323             #retvals:
1324 
1325         def set_timeout(self, timeout):
1326             """
1327                Set the resolver's socket time out when talking to remote hosts.
1328 
1329                :param timeout: The time-out to use.
1330                :param timeout: struct timeval
1331                :throws TypeError: When arguments of inappropriate types.
1332             """
1333             _ldns.ldns_resolver_set_timeout(self,timeout)
1334             #parameters: ldns_resolver *,struct timeval,
1335             #retvals:
1336 
1337         def set_tsig_algorithm(self, tsig_algorithm):
1338             """
1339                Set the tsig algorithm.
1340 
1341                :param tsig_algorithm: The tsig algorithm.
1342                :param tsig_algorithm: str
1343                :throws TypeError: When arguments of inappropriate types.
1344             """
1345             _ldns.ldns_resolver_set_tsig_algorithm(self, tsig_algorithm)
1346             #parameters: ldns_resolver *,char *,
1347             #retvals:
1348 
1349         def set_tsig_keydata(self, tsig_keydata):
1350             """
1351                Set the tsig key data.
1352 
1353                :param tsig_keydata: The key data.
1354                :type tsig_keydata: str
1355                :throws TypeError: When arguments of inappropriate types.
1356             """
1357             _ldns.ldns_resolver_set_tsig_keydata(self, tsig_keydata)
1358             #parameters: ldns_resolver *,char *,
1359             #retvals:
1360 
1361         def set_tsig_keyname(self, tsig_keyname):
1362             """
1363                Set the tsig key name.
1364 
1365                :param tsig_keyname: The tsig key name.
1366                :type tsig_keyname: str
1367                :throws TypeError: When arguments of inappropriate types.
1368             """
1369             _ldns.ldns_resolver_set_tsig_keyname(self, tsig_keyname)
1370             #parameters: ldns_resolver *,char *,
1371             #retvals:
1372 
1373         def set_usevc(self, b):
1374             """
1375                Whether the resolver uses a virtual circuit (TCP).
1376 
1377                :param b: True: use TCP, False: don't use TCP.
1378                :type b: bool
1379             """
1380             _ldns.ldns_resolver_set_usevc(self, b)
1381             #parameters: ldns_resolver *,bool,
1382             #retvals:
1383 
1384         def timeout(self):
1385             """
1386                What is the time-out on socket connections.
1387 
1388                :return: (struct timeval) The time-out.
1389             """
1390             return _ldns.ldns_resolver_timeout(self)
1391             #parameters: const ldns_resolver *,
1392             #retvals: struct timeval
1393 
1394         def trusted_key(self, keys):
1395             """
1396                Returns true if at least one of the provided keys is a trust
1397                anchor.
1398 
1399                :param keys: The key set to check.
1400                :type keys: :class:`ldns_rr_list`
1401                :throws TypeError: When arguments of inappropriate types.
1402                :return: (:class:`ldns_rr_list`) List of trusted keys if at
1403                    least one of the provided keys is a configured trust anchor,
1404                    None else.
1405             """
1406             return _ldns._replacement_ldns_resolver_trusted_key(self, keys)
1407             #parameters: const ldns_resolver *,ldns_rr_list *,ldns_rr_list *,
1408             #retvals: bool
1409 
1410         def tsig_algorithm(self):
1411             """
1412                Return the tsig algorithm as used by the name server.
1413 
1414                :return: (str) The algorithm used.
1415             """
1416             return _ldns._ldns_resolver_tsig_algorithm(self)
1417             #parameters: const ldns_resolver *,
1418             #retvals: char *
1419 
1420         def tsig_keydata(self):
1421             """
1422                Return the tsig key data as used by the name server.
1423 
1424                :return: (str) The key data used.
1425             """
1426             return _ldns._ldns_resolver_tsig_keydata(self)
1427             #parameters: const ldns_resolver *,
1428             #retvals: char *
1429 
1430         def tsig_keyname(self):
1431             """
1432                Return the tsig key name as used by the name server.
1433 
1434                :return: (str) The name used.
1435             """
1436             return _ldns._ldns_resolver_tsig_keyname(self)
1437             #parameters: const ldns_resolver *,
1438             #retvals: char *
1439 
1440         def usevc(self):
1441             """
1442                Does the resolver use tcp or udp.
1443 
1444                :return: (bool) True: tcp, False: udp.
1445             """
1446             return _ldns.ldns_resolver_usevc(self)
1447             #parameters: const ldns_resolver *,
1448             #retvals: bool
1449 
1450         #
1451         # _LDNS_RESOLVER_METHODS
1452         #
1453   %}
1454 }
1455