auth/credentials: don't ignore "client use kerberos" and --use-kerberos for machine...
[Samba.git] / python / samba / dnsresolver.py
bloba627555a855ae7133f981aa227ae0ade1e9442eb
1 # Samba wrapper for DNS resolvers
3 # Copyright (C) Stanislav Levin <slev@altlinux.org>
4 # Copyright (C) Alexander Bokovoy <ab@samba.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 import dns.resolver
21 import dns.rdatatype
22 import dns.reversename
24 class DNSResolver(dns.resolver.Resolver):
25 """DNS stub resolver compatible with both dnspython < 2.0.0
26 and dnspython >= 2.0.0.
28 Set `use_search_by_default` attribute to `True`, which
29 determines the default for whether the search list configured
30 in the system's resolver configuration is used for relative
31 names, and whether the resolver's domain may be added to relative
32 names.
34 Increase the default lifetime which determines the number of seconds
35 to spend trying to get an answer to the question. dnspython 2.0.0
36 changes this to 5sec, while the previous one was 30sec.
37 """
38 def __init__(self, *args, **kwargs):
39 super().__init__(*args, **kwargs)
40 self.reset_defaults()
41 self.resolve = getattr(super(), "resolve", self.query)
42 self.resolve_address = getattr(
43 super(),
44 "resolve_address",
45 self._resolve_address
48 def reset_defaults(self):
49 self.use_search_by_default = True
50 # the default is 5sec
51 self.lifetime = 15
53 def reset(self):
54 super().reset()
55 self.reset_defaults()
57 def _resolve_address(self, ip_address, *args, **kwargs):
58 """Query nameservers for PTR records.
60 :param ip_address: IPv4 or IPv6 address
61 :type ip_address: str
62 """
63 return self.resolve(
64 dns.reversename.from_address(ip_address),
65 rdtype=dns.rdatatype.PTR,
66 *args,
67 **kwargs,