Skip to content

Instantly share code, notes, and snippets.

@rlb3
Last active January 15, 2023 05:08
Show Gist options
  • Save rlb3/20fa2d664974e76bcb1d735fb71e58dc to your computer and use it in GitHub Desktop.
Save rlb3/20fa2d664974e76bcb1d735fb71e58dc to your computer and use it in GitHub Desktop.
"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