MCPcopy Create free account
hub / github.com/rthalley/dnspython / try_ddr

Method try_ddr

dns/asyncresolver.py:231–260  ·  view source on GitHub ↗

Try to update the resolver's nameservers using Discovery of Designated Resolvers (DDR). If successful, the resolver will subsequently use DNS-over-HTTPS or DNS-over-TLS for future queries. *lifetime*, a float, is the maximum time to spend attempting DDR. The default

(self, lifetime: float = 5.0)

Source from the content-addressed store, hash-verified

229 return canonical_name
230
231 async def try_ddr(self, lifetime: float = 5.0) -> None:
232 """Try to update the resolver's nameservers using Discovery of Designated
233 Resolvers (DDR). If successful, the resolver will subsequently use
234 DNS-over-HTTPS or DNS-over-TLS for future queries.
235
236 *lifetime*, a float, is the maximum time to spend attempting DDR. The default
237 is 5 seconds.
238
239 If the SVCB query is successful and results in a non-empty list of nameservers,
240 then the resolver's nameservers are set to the returned servers in priority
241 order.
242
243 The current implementation does not use any address hints from the SVCB record,
244 nor does it resolve addresses for the SCVB target name, rather it assumes that
245 the bootstrap nameserver will always be one of the addresses and uses it.
246 A future revision to the code may offer fuller support. The code verifies that
247 the bootstrap nameserver is in the Subject Alternative Name field of the
248 TLS certficate.
249 """
250 try:
251 expiration = time.time() + lifetime
252 answer = await self.resolve(
253 dns._ddr._local_resolver_name, "svcb", lifetime=lifetime
254 )
255 timeout = dns.query._remaining(expiration)
256 nameservers = await dns._ddr._get_nameservers_async(answer, timeout)
257 if len(nameservers) > 0:
258 self.nameservers = nameservers
259 except Exception:
260 pass
261
262
263default_resolver = None

Callers 1

try_ddrFunction · 0.45

Calls 2

resolveMethod · 0.95
timeMethod · 0.80

Tested by

no test coverage detected