Last active
January 15, 2023 05:08
-
-
Save rlb3/20fa2d664974e76bcb1d735fb71e58dc to your computer and use it in GitHub Desktop.
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
"google.com" | |
|> String.to_charlist() | |
|> :inet_res.lookup(:in, :a) | |
|> Enum.reduce([], fn ip, acc -> | |
[ | |
ip | |
|> Tuple.to_list() | |
|> Enum.join(".") | |
| acc | |
] | |
end) | |
'www.google.com' | |
|> :inet_res.getbyname(:a) | |
|> case do | |
{:ok, {_, _, _, _, _, ips}} -> | |
ips | |
|> Enum.reduce([], fn ip, acc -> | |
[ | |
ip | |
|> Tuple.to_list() | |
|> Enum.join(".") | |
| acc | |
] | |
end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment