saghul / aiodns

Simple DNS resolver for asyncio

Home Page:https://pypi.python.org/pypi/aiodns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for non-standard ports?

HarvsG opened this issue · comments

Do you support sending DNS requests to any port other than port 53?

In at least one example of sending a request to 208.67.222.222:5353 the IP was given to pycares which threw an error:

  File "/usr/local/lib/python3.12/site-packages/aiodns/__init__.py", line 55, in __init__
    self.nameservers = nameservers
    ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiodns/__init__.py", line 66, in nameservers
    self._channel.servers = value
    ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pycares/__init__.py", line 468, in servers
    raise ValueError("invalid IP address")
ValueError: invalid IP address

home-assistant/core#113988

You need to initialize the resolver like so: r = DNSResolver(nameservers=["208.67.222.222"], loop=loop, udp_port=5353, tcp_port=5353)

This is a bit clunky, but it's due to c-ares.

Thank you