{"id":15357204,"url":"https://github.com/gera2ld/async-doh","last_synced_at":"2025-07-06T20:05:50.725Z","repository":{"id":57412089,"uuid":"286522590","full_name":"gera2ld/async-doh","owner":"gera2ld","description":"DNS over HTTPS based on aiohttp and async-dns","archived":false,"fork":false,"pushed_at":"2021-07-22T12:45:48.000Z","size":26,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-25T03:07:18.215Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gera2ld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-10T16:14:52.000Z","updated_at":"2025-05-18T00:50:16.000Z","dependencies_parsed_at":"2022-09-09T17:21:56.967Z","dependency_job_id":null,"html_url":"https://github.com/gera2ld/async-doh","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/gera2ld/async-doh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fasync-doh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fasync-doh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fasync-doh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fasync-doh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gera2ld","download_url":"https://codeload.github.com/gera2ld/async-doh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fasync-doh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263836198,"owners_count":23517859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T12:33:58.955Z","updated_at":"2025-07-06T20:05:50.708Z","avatar_url":"https://github.com/gera2ld.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# async-doh\n\n[![PyPI](https://img.shields.io/pypi/v/async-doh.svg)]()\n\nDNS over HTTPS based on aiohttp and [async_dns](https://github.com/gera2ld/async_dns).\n\n## Installation\n\n```bash\n$ pip install async-doh\n```\n\n## Usage\n\n### Command-line\n\n```\nusage: python3 -m async_doh.client [-h] [-n NAMESERVERS [NAMESERVERS ...]] [-t TYPES [TYPES ...]] hostnames [hostnames ...]\n\nAsync DNS resolver with DoH\n\npositional arguments:\n  hostnames             the hostnames to query\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -n NAMESERVERS [NAMESERVERS ...], --nameservers NAMESERVERS [NAMESERVERS ...]\n                        name servers\n  -t TYPES [TYPES ...], --types TYPES [TYPES ...]\n                        query types, default as `any`\n```\n\nExamples:\n\n```sh\n$ python3 -m async_doh.client -n https://223.5.5.5/dns-query -t ANY -- www.google.com\n```\n\n### Client\n\n```py\nimport asyncio\nimport aiohttp\nfrom async_doh.client import DoHClient\n\nasync def main():\n    async with DoHClient() as client:\n        result = await client.query('https://1.1.1.1/dns-query', 'www.google.com', 'A')\n        print('query:', result)\n        result = await client.query_json('https://1.1.1.1/dns-query', 'www.google.com', 'A')\n        print('query_json:', result)\n\nasyncio.run(main())\n```\n\n### Server\n\n```py\nfrom aiohttp import web\nfrom async_doh.server import application\n\nweb.run(application)\n```\n\nNow you have `http://localhost:8080/dns-query` as an endpoint.\n\n### Patching async_dns\n\nBy importing the patch, async_dns will use aiohttp to send queries through HTTPS (aka DNS over HTTPS):\n\n```py\nimport asyncio\nfrom async_dns.core import types\nfrom async_dns.resolver import ProxyResolver\nfrom async_doh.client import patch\n\nasync def main():\n    revoke = await patch()\n    resolver = ProxyResolver(proxies=['https://dns.alidns.com/dns-query'])\n    res, _ = await resolver.query('www.google.com', types.A)\n    print(res)\n    await revoke()\n\nasyncio.run(main())\n```\n\n## References\n\n- \u003chttps://tools.ietf.org/html/rfc8484\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgera2ld%2Fasync-doh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgera2ld%2Fasync-doh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgera2ld%2Fasync-doh/lists"}