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

getnameinfo() is broken on IPv6 link-local addresses #121

Closed
socketpair opened this issue Feb 6, 2020 · 3 comments
Closed

getnameinfo() is broken on IPv6 link-local addresses #121

socketpair opened this issue Feb 6, 2020 · 3 comments

Comments

@socketpair
Copy link
Contributor

socketpair commented Feb 6, 2020

https://pycares.readthedocs.io/en/latest/channel.html#pycares.Channel.getnameinfo

Function signature is completely wrong. instead of two arguments (name and port) you have to use one argument -- tuple. For ipv4 it would be 2-element tuple (ip and port). For IPv6 it would be 4-element tuple, where the last element is a scope-id. It is essential for Link-local IPv6.

See Python's native socket.getnameinfo().

In [16]: socket.getnameinfo(('fe80::841e:8fff:fea4:4f19', 456, 0, 3), socket.NI_NUMERICHOST | socket.NI_NUMERICSERV)
Out[16]: ('fe80::841e:8fff:fea4:4f19%wlp2s0', '456')

note wlp2s0. It is interface number 3 on my PC.

@saghul
Copy link
Owner

saghul commented Feb 6, 2020

Looks like the bug is two fold: the documentation is wrong, because we do take a tuple, and the code is wrong because we only look at the first 2 elements.

@saghul
Copy link
Owner

saghul commented Feb 6, 2020

Would you be able to provide a patch?

@saghul
Copy link
Owner

saghul commented Feb 6, 2020

cheers!

@saghul saghul closed this as completed Feb 6, 2020
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