Metadata-Version: 2.1
Name: async-doh
Version: 0.1.1
Summary: DNS over HTTPS based on aiohttp and async_dns
Home-page: https://github.com/gera2ld/async-doh
License: MIT
Keywords: async,dns,asyncio,doh
Author: Gerald
Author-email: gera2ld@live.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: aiohttp (>=3.6.2,<4.0.0)
Requires-Dist: async_dns (>=1.1.0,<2.0.0)
Project-URL: Repository, https://github.com/gera2ld/async-doh
Description-Content-Type: text/markdown

# async-doh

[![PyPI](https://img.shields.io/pypi/v/async-doh.svg)]()

DNS over HTTPS based on aiohttp and [async_dns](https://github.com/gera2ld/async_dns).

## Installation

```sh
$ pip install async-doh
```

## Usage

### Client

```py
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

```py
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

- <https://tools.ietf.org/html/rfc8484>

