Home

Awesome

aiodns

StandWithUkraine GitHub issues GitHub license Support vshymanskyy

<!-- [![Build status](https://img.shields.io/github/actions/workflow/status/vshymanskyy/aiodns/static.yml?branch=main&style=flat-square&logo=github&label=build)](https://github.com/vshymanskyy/aiodns/actions) --> <!--[![GitHub Repo stars](https://img.shields.io/github/stars/vshymanskyy/aiodns?style=flat-square&color=green)](https://github.com/vshymanskyy/aiodns/stargazers) -->

A small async DNS client for MicroPython

Install

<img src="https://raw.githubusercontent.com/vshymanskyy/ViperIDE/refs/heads/main/assets/btn_install.png" alt="Install using ViperIDE" height="42"/>

Using CLI:

mpremote mip install github:vshymanskyy/aiodns

Using REPL (your board must be connected to the internet):

import mip
mip.install("github:vshymanskyy/aiodns")

Example

See usage examples

API

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)

Extra

Minify to ~2'800 bytes:

pip3 install -U python-minifier
pyminify aiodns.py -o aiodns_min.py --rename-globals --preserve-globals=getaddrinfo,servers,cache,cache_size,timeout_ms,AF_INET,AF_INET6,AF_UNSPEC,SOCK_DGRAM,SOCK_STREAM

Compile to MPY ~2'200 bytes:

mpy-cross aiodns.py -O3 -o aiodns.mpy

Run example using MicroPython Unix port:

export MICROPYPATH=".frozen:."
micropython examples/simple/main.py