Created
August 22, 2013 15:29
-
-
Save tomasfejfar/6308726 to your computer and use it in GitHub Desktop.
hostname resolver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| def resolve(hostname): | |
| return socket.gethostbyname(hostname) |
I is possible to integrate it to asible teplates?
socket.getaddrinfo may be a better choice ever since GHOST vulnerability was disclosed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
socket.gethostbynamewould return only the first resolved ip-address despite the fact that host may have more than one ip-address. To get all of the ip-addresses I'd recommend to usesocket.gethostbyname_ex. E.g.:return socket.gethostbyname_ex(hostname)[2]- would return a list of all ip-addresses that the host resolves to.