Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in the README does not work #15

Closed
covuworie opened this issue Jun 9, 2020 · 4 comments
Closed

Example in the README does not work #15

covuworie opened this issue Jun 9, 2020 · 4 comments

Comments

@covuworie
Copy link

Hi,

This library seems to have some very good functionality and I am looking into incorporating it into a project of mine. However, I'm struggling to get the example that you have in the README to even work:

import asyncio
from async_dns import types
from async_dns.resolver import ProxyResolver

loop = asyncio.get_event_loop()
resolver = ProxyResolver()
res = loop.run_until_complete(resolver.query('www.baidu.com', types.A))
print(res)

I get a value of None returned when I paste the code into the following online REPL: https://repl.it/repls/CoordinatedLameCoins

You can see the versions of python and pypi libraries being used in the pyproject.toml. Even when I edit the file to force the use of the latest version (1.0.9) I get the same result.

Also, even if I change the domain name to google.com, facebook.com etc. the same None result is returned.

Am I missing something here?

@gera2ld
Copy link
Owner

gera2ld commented Jun 9, 2020

The ProxyResolver uses 8.8.8.8, 8.8.4.4 as its name servers by default.
However the environment you are trying to use does not work with them.
A quick workaround in your case is to use the system nameservers instead:

from async_dns import get_nameservers

resolver = ProxyResolver(proxies=get_nameservers())

@gera2ld gera2ld closed this as completed Jun 9, 2020
@covuworie
Copy link
Author

Thanks @gera2ld, this seems to have fixed the issue. It's strange as I thought that I had used aiodns before in that environment with remote nameservers. But I tried that also again and it failed.

I'll probably do some other tests in a docker container or virtual environment on my machine so I don't have this issue again.

A quick question. Are there any plans to return errors when a domain name is not found, or the server fails, or there is a timeout etc.? At the moment None is returned which doesn't give much information.

@gera2ld
Copy link
Owner

gera2ld commented Jun 11, 2020

Are there any plans to return errors when a domain name is not found, or the server fails, or there is a timeout etc.?

Not yet but perhaps there should be. This project was designed to simply provide a DNS service at the beginning and the APIs are not well designed.

@covuworie
Copy link
Author

I see what you are saying. However, the design of the API is not actually as as bad as you say. You've done a good job making the API very concise. I've had a lot of experience designing APIs in the past and good APIs are hard to design. The main thing missing is documentation of the methods, parameters / arguments and responses.

Possibly the responses could be split out into their own classes. But I think more comprehensive documentation and clear naming would probably make this less essential. It took me a bit of time to work out the responses depending on the name servers I was using (tld vs authoritative) and required me to understand quite a bit about the DNS system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants