aiocoap.util.asyncio.getaddrinfo_addrconfig module

Helper module around getaddrinfo shortcomings

async aiocoap.util.asyncio.getaddrinfo_addrconfig.getaddrinfo_routechecked(loop, log, host, port)

Variant of getaddrinfo that works like AI_ADDRCONFIG should probably work.

This is not only a workaround for 12377, but goes beyond it by checking routability. Even with 12377 fixed, AI_ADDRCONFIG would just avoid sending AAAA requests (if no v6 addresses were available at all). It would still not avoid filtering out responses that are just not routable – the typical example being that a host may be in a network with a ULA, so it needs to send AAAA requests because they might resolve to the ULA, but if a global address comes back, we still don’t want that address passed to the application.

The family and flags arguments are not accepted, because they are what is being altered (and it’d be hard to tell which combinations would work). It roughly behaves as if flags were set to AI_ADDRCONFIG | AI_V4MAPPED, and family to AF_INET6. The type and protocol are fixed to SOCK_DGRAM / IPPROTO_UDP, because only there we known that connect is side-effect free.

This function also differs from getaddrinfo in that it returns an asynchronous iterator (we don’t want to check addresses we don’t care about), and in that it only returns the sockaddr (because the rest is fixed anyway).