aio-libs / aiodns

Simple DNS resolver for asyncio
https://pypi.python.org/pypi/aiodns
MIT License
538 stars 69 forks source link

Support for non-standard ports? #117

Closed HarvsG closed 7 months ago

HarvsG commented 7 months ago

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

https://github.com/home-assistant/core/issues/113988

saghul commented 7 months ago

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.

HarvsG commented 7 months ago

Thank you