# aiodnsresolver [![CircleCI](https://circleci.com/gh/michalc/aiodnsresolver.svg?style=svg)](https://circleci.com/gh/michalc/aiodnsresolver) [![Test Coverage](https://api.codeclimate.com/v1/badges/8fa95ca31fe002296b9b/test_coverage)](https://codeclimate.com/github/michalc/aiodnsresolver/test_coverage)
Asyncio Python DNS resolver. Pure Python, with no dependencies other than the standard library, threads are not used, and all code is in a single module. The nameservers to query are taken from `/etc/resolve.conf`.
Based on https://github.com/gera2ld/async_dns.
## Installation
```bash
pip install aiodnsresolver
```
## Usage
```python
from aiodnsresolver import Resolver, TYPES
resolve = Resolver()
ip_address = await resolve('www.google.com', TYPES.A)
```
The IP address returned is an instance of [IPv4Address](https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Address) or [IPv6Address](https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv6Address). Both support conversion to their usual string form by passing them to `str`.
## Security considerations
To migitate spoofing, several techniques are used.
- Each query is given a random ID, which is checked against any response.
- Each domain name is encoded with [0x20-bit encoding](https://astrolavos.gatech.edu/articles/increased_dns_resistance.pdf), which is checked against any response.
- A new socket, and so a new random local port, is used for each query.
## Scope
The scope of this project is deliberately restricted to operations that are used to resolve A or AAAA records: to resolve a domain name to one of its IP addresses, and have similar responsibilities to `gethostbyname`. Some limited extra behaviour is present/may be added, but great care is taken to prevent scope creep, especially to not add complexity that isn't required to resolve A or AAAA records.
- UDP queries are made, but not TCP. DNS servers must support UDP, and it's impossible for a single A and AAAA record to not fit into the maximum size of a UDP DNS response, 512 bytes. There may be other data that the DNS server would return in TCP connections, but this isn't required to resolve a domain name to a single IP address.
- CNAME records are followed transparently.
- Responses are cached, adhering to their TTL.
- The resolver is a _stub_ resolver: it delegates the responsibility of recursion to the nameserver(s) it queries. In the vast majority of envisioned use cases this is acceptable, since the nameservers in `/etc/resolve.conf` will be recursive.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:aiodnsresolver-0.0.38.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
aiodnsresolver-0.0.38.tar.gz (9个子文件)
aiodnsresolver-0.0.38
PKG-INFO 3KB
aiodnsresolver.egg-info
PKG-INFO 3KB
SOURCES.txt 188B
top_level.txt 15B
dependency_links.txt 1B
aiodnsresolver.py 8KB
setup.cfg 38B
setup.py 936B
README.md 2KB
共 9 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- java大型ERP系统源码 进销存财务一体化源码数据库 MySQL源码类型 WebForm
- 技术资料分享BMP图片文件详解很好的技术资料.zip
- 技术资料分享AT键盘接口资料很好的技术资料.zip
- 技术资料分享ATK-NEO-6M用户手册-V1.0很好的技术资料.zip
- 技术资料分享ATK-NEO-6M GPS模块使用说明-AN1303很好的技术资料.zip
- 用树莓派实现的丁真语音伴学装置
- python《K近邻算法实现简单的手写数字识别》+项目源码+文档说明
- C#MVC4权限管理系统开发框架源码数据库 SQL2008源码类型 WebForm
- Windows系统tcping文件,测试tcp端口能否通信
- 技术资料分享ATK-HC05蓝牙串口模块使用说明-AN1301很好的技术资料.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功