https://github.com/vshymanskyy/aiodns
A small async DNS client for MicroPython
https://github.com/vshymanskyy/aiodns
asyncio cellular dns esp32 esp8266 ethernet lte mdns micropython rpi-pico-w wifi
Last synced: 3 days ago
JSON representation
A small async DNS client for MicroPython
- Host: GitHub
- URL: https://github.com/vshymanskyy/aiodns
- Owner: vshymanskyy
- License: mit
- Created: 2024-10-13T15:25:39.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-01-08T10:24:32.000Z (4 months ago)
- Last Synced: 2025-04-22T14:09:27.016Z (3 days ago)
- Topics: asyncio, cellular, dns, esp32, esp8266, ethernet, lte, mdns, micropython, rpi-pico-w, wifi
- Language: Python
- Homepage:
- Size: 73.2 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-micropython - aiodns - A small, versatile DNS client that provides an async version of `getaddrinfo` and works with any connectivity. (Libraries / Communications)
README
# aiodns
[](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
[](https://github.com/vshymanskyy/aiodns/issues)
[](https://github.com/vshymanskyy/aiodns)
[](https://quicknote.io/da0a7d50-bb49-11ec-936a-6d7fd5a2de08)
[](https://github.com/vshymanskyy/aiodns/actions)A small async DNS client for MicroPython
- Works on `ESP32`, `ESP8266`, `Raspberry Pi Pico W`, `WM W600` and other boards
- Versatile, runs multiple queries at a time using multiple DNS servers
- Supports IPv4 and IPv6
- Supports `mDNS` (Multicast DNS) name resolution
- Works with WiFi, Ethernet, Cellular, and in multi-network scenarios
- Caches up to 32 hostnames (configurable)
- API-compatible with `getaddrinfo`## Install
[
](https://viper-ide.org/?install=github:vshymanskyy/aiodns)
Using CLI:
```sh
mpremote mip install github:vshymanskyy/aiodns
```Using REPL (your board must be connected to the internet):
```py
import mip
mip.install("github:vshymanskyy/aiodns")
```## Example
See [usage examples](./examples)
## API
```py
aiodns.servers = set(["8.8.8.8", "1.1.1.1"])
aiodns.servers.add("9.9.9.9")
aiodns.timeout_ms = 5000
aiodns.cache.clear()
aiodns.cache_size = 32
await aiodns.getaddrinfo(hostname, port, family=AF_INET, type=0, proto=0, flags=0)
```## Build
```sh
pip3 install -U python-minifier mpy-cross
python3 ./extra/build.py
```Output:
```log
Minified: 2796 bytes
Compiled: 2202 bytes
```## Run using MicroPython Unix port:
```sh
export MICROPYPATH=".frozen:./lib:."
mkdir -p lib
micropython -m mip install logging
micropython examples/simple/main.py
```## Run using Python 3:
```sh
pip3 install -U microemu
microemu examples/simple/main.py
```