DNS over HTTPS reslover for aiohttp
Project description
DNS over HTTPS reslover for aiohttp
Installation
$ pip install aiohttp-doh
Manual Usage
If you want use manualy, you must import ClientSession in aiohttp.client module and TCPConnector in aiohttp.connector module and DNSOverHTTPSResolver in aiohttp_doh package.
from aiohttp.client import ClientSession
from aiohttp.connector import TCPConnector
from aiohttp_doh import DNSOverHTTPSResolver
def my_client_session(*args, **kwargs):
resolver = DNSOverHTTPSResolver(endpoints=[
'https://cloudflare-dns.com/dns-query',
])
connector = TCPConnector(resolver=resolver)
return ClientSession(*args, **kwargs, connector=connector)
async def main():
async with my_client_session() as session:
async with session.get('http://example.com') as resp:
data = await resp.text()
print(data)
Shortcut
Manual usage is too board. So I make shortcut to use easily. You just replace aiohttp.ClientSession to aiohttp_doh.ClientSession.
from aiohttp_doh import ClientSession
async def main():
async with ClientSession() as session:
async with session.get('http://example.com') as resp:
data = await resp.text()
print(data)
Options
You can pass below parameter for configuration.
- endpoints
List of str. DNS over HTTPS endpoints. Shortcut use ‘https://dns.google.com/resolve’ and ‘https://cloudflare-dns.com/dns-query’ both in default. You can also use others instead.
- json_loads
Function for loads json. default is Python builtin json module’s one. You can use third-party json library like simplejson or ujson.
- resolver_class
Internal DNS resolver class. Using for connect to endpoint. default is aiohttp default.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aiohttp-doh-0.2.1.tar.gz
.
File metadata
- Download URL: aiohttp-doh-0.2.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.7.2 Darwin/18.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d464c66c7db87fee815f8f6ac80ac4a0181a632801584210d4b24b5815a7c37 |
|
MD5 | e9d0238a36a308e7f95cb7c61414d8ed |
|
BLAKE2b-256 | d160046bd2a9e23fd15ef0eef3559f07d2348f5816deb99e1bd10823140196ac |
File details
Details for the file aiohttp_doh-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: aiohttp_doh-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.7.2 Darwin/18.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ad9ede46cc1f58b007bb9283c7eb564cda580cd76b33d8f853a2605997ba222 |
|
MD5 | 3c9ac1b46ef02472c5b9dfb90889b8fb |
|
BLAKE2b-256 | 2e22aa7965a87212c17fcf4d80e7f79adb1479b116c4b4f3996b9149ada0a913 |