-
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
For me, an important use of the requests_doh
library is skipping DNS requests entirely. That includes that I want to be able to avoid the DNS request to resolve the IP of the DNS resolver itself.
Right now, it's possible with some tricks:
import httpx
import requests
import requests_doh.adapter
import requests_doh.resolver
requests_doh.resolver.add_dns_provider("cloudflare_ip",
'https://104.16.249.249/dns-query', switch=True)
requests_doh.resolver.set_resolver_session(httpx.Client(verify=False,
headers={"Host": "cloudflare-dns.com"}))
doh = requests_doh.adapter.DNSOverHTTPSAdapter(provider="cloudflare_ip")
session = requests.Session()
session.mount('https://', doh)
session.mount('http://', doh)
session.get('https://example.com')
There are two changes that I would like to propose:
- It would be nice if you could connect to a custom server, without the need to add them to the dictionary in the
requests_doh.resolver
module first, so something likeDNSOverHTTPSAdapter(provider_url='https://104.16.249.249/dns-query', provider_host='cloudflare-dns.com')
. - If a DNS resolver is added by IP like above, we could add a way to verify the SSL certificate against the hostname. The easiest way to do that might be to use
requests.Session
for the resolver session, instead ofhttpx.Client
. Then it would be possible to add the domain, IP combination of the resolver to the cache, and re-use all existing logic.
What are your thoughts? I can work on a pull request if you're interested in the described changes.
Metadata
Metadata
Assignees
Labels
No labels