-
Notifications
You must be signed in to change notification settings - Fork 49
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
Use socket.getaddrinfo instead of socket.gethostbyname #305
Conversation
This pull request is a first step to proper IPv6 support and support for IPv6-only mirrors. |
IPv6 support is tracked in issue #306 for the moment. |
a358946
to
5cfd112
Compare
861f200
to
d9d0078
Compare
socket.gethostbyname only returns a single IPv4 address. Any additional IPv4 addresses and all IPv6 addresses are ignored. As a consequence, hosts without IPv4 addresses are ignored and any additional information from additional IPv4 addresses is ignored. If IPv4 addresses are rotated by the implementation of socket.gethostbyname, for example, common with DNS servers and resolvers, the geolocation information for the host can change without every call of socket.gethostbyname. It seems better to consider all addresses, both all IPv4 and IPv6 addresses, and to summarize the geolocation information when only a single result is required. Signed-off-by: Matthias-Christian Ott <[email protected]>
I have updated this pull request and would appreciate if it could be merged before larger changes are made again that create conflicts and would require me to update this pull request again. |
Signed-off-by: Aurélien Bompard <[email protected]>
Also, follow the [line of sight](https://medium.com/@matryer/line-of-sight-in-code-186dd7cdea88) code style. Signed-off-by: Aurélien Bompard <[email protected]>
Thanks for updating it! I've fixed a couple remaining issues due to the rebase, and refactored the common code. |
Now that it is possible to store the geographic location of a host in the database, it would perhaps also be a good idea to use this information in the world map and perhaps also in the crawler if it is available. |
The world map is generated from the mirror coordinates in the database already. Or did I misunderstood your question? |
No, it is not. The location is generated from the city geolocation. See
|
Ah, you may have been tricked into believing that the |
socket.gethostbyname only returns a single IPv4 address. Any additional
IPv4 addresses and all IPv6 addresses are ignored. As a consequence,
hosts without IPv4 addresses are ignored and any additional information
from additional IPv4 addresses is ignored. If IPv4 addresses are rotated
by the implementation of socket.gethostbyname, for example, common with
DNS servers and resolvers, the geolocation information for the host can
change without every call of socket.gethostbyname.
It seems better to consider all addresses, both all IPv4 and IPv6
addresses, and to summarize the geolocation information when only a
single result is required.