Inet.ex
was created in Elixir to simplify the invocation of address and DNS queries using :inet
.
If available in Hex, the package can be installed
by adding inet_ex
to your list of dependencies in mix.exs
:
def deps do
[
{:inet_ex, "~> 0.1.0"}
]
end
iex> {:ok, ip_address_list} = Inet.get_ip_address_list("www.google.com")
{:ok, ["142.251.220.68"]}
# This is direct calling :inet.gethostbyname()
iex> Inet.get_host_by_name("www.google.com")
{:ok, {:hostent, 'www.google.com', [], :inet, 4, [{142, 250, 66, 132}]}}
iex> {:ok, dns_list} = Inet.get_dns_list("8.8.8.8")
{:ok, ['one.one.one.one']}
# This is direct calling :inet.gethotbyaddr()
iex> Inet.get_host_by_addr("8.8.8.8")
{:ok,
{:hostent, 'dns.google', ['8.8.8.8.in-addr.arpa'], :inet, 4, [{8, 8, 8, 8}]}}
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/inet_ex.