DNS over HTTPS based on aiohttp and async_dns
Project description
async-doh
DNS over HTTPS based on aiohttp and async_dns.
Installation
$ pip install async-doh
Usage
Client
import asyncio
import aiohttp
from async_doh.client import query, query_json
async def main():
async with DoHClient() as client:
result = await client.query('https://1.1.1.1/dns-query', 'www.google.com', 'A')
print('query:', result)
result = await client.query_json('https://1.1.1.1/dns-query', 'www.google.com', 'A')
print('query_json:', result)
asyncio.run(main())
Server
from aiohttp import web
from async_doh.server import application
web.run(application)
Now you have http://localhost:8080/dns-query
as an endpoint.
Patching async_dns
By importing the patch, async_dns will support queries throught HTTPS (aka DNS over HTTPS):
import async_doh.patch_resolver
import asyncio
from async_dns import types
from async_dns.resolver import ProxyResolver
resolver = ProxyResolver(proxies=['https://dns.alidns.com/dns-query'])
print(asyncio.run(resolver.query('www.google.com', types.A)))
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async-doh-0.1.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for async_doh-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22ffd0391f5602346e15f0515b7c85730992133ee8e0f863062c1a55fe24c2a1 |
|
MD5 | 501c267e9bf513deb79890f843b38c1e |
|
BLAKE2b-256 | 933881bce08c20360d1a96b1d63cb61cb3207f456c1f4deefc188a8d6cae30cb |