gera2ld / async_dns

DNS library based on asyncio
MIT License
70 stars 17 forks source link

CLI errors #16

Closed jayvdb closed 4 years ago

jayvdb commented 4 years ago

This is my first attempt at using the CLI, based on the README.

> python3 -m async_dns.resolver -n 8.8.8.8 www.google.com
usage: python3 -m async_dns.resolver [-h] [-n NAMESERVERS [NAMESERVERS ...]] [-t TYPES [TYPES ...]] hostnames [hostnames ...]
python3 -m async_dns.resolver: error: the following arguments are required: hostnames
> python3 -m async_dns.resolver www.google.com
Traceback (most recent call last):
  File "/usr/lib64/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/site-packages/async_dns/resolver/__main__.py", line 57, in <module>
    resolve_hostnames(_parse_args())
  File "/usr/lib/python3.8/site-packages/async_dns/resolver/__main__.py", line 48, in resolve_hostnames
    res = fut.result()
  File "/usr/lib/python3.8/site-packages/async_dns/resolver/__main__.py", line 24, in resolve_hostname
    return await resolver.query(hostname, qtype)
  File "/usr/lib/python3.8/site-packages/async_dns/resolver/__init__.py", line 38, in query
    result, _cached = await self.query_with_timeout(fqdn, qtype, timeout, tick)
  File "/usr/lib/python3.8/site-packages/async_dns/resolver/__init__.py", line 51, in query_with_timeout
    return await asyncio.wait_for(self._query(fqdn, qtype, tick), timeout)
  File "/usr/lib64/python3.8/asyncio/tasks.py", line 483, in wait_for
    return fut.result()
  File "/usr/lib/python3.8/site-packages/async_dns/resolver/__init__.py", line 59, in _query
    addr = Address.parse(fqdn)
  File "/usr/lib/python3.8/site-packages/async_dns/core/address.py", line 120, in parse
    assert addr.ip_type, InvalidHost(hostinfo.hostname)
AssertionError: www.google.com

fwiw, I am running a package which was built a different way, which could be part of the problem. The build process is at https://build.opensuse.org/package/show/home:jayvdb:py-new/python-async-dns

gera2ld commented 4 years ago

Something is wrong when qtype=ANY. You may try this as a workaround:

> python3 -m async_dns.resolver -n 8.8.8.8 -t A AAAA -- www.google.com

Note that -- is needed before hostnames because -t or -n in your case can have multiple arguments, I'll fix this in the document.