Skip to content

suhanlee/inet.ex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inet.ex

Inet.ex was created in Elixir to simplify the invocation of address and DNS queries using :inet.

Installation

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

Usage

Get ip address list by host name

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}]}}

Get dns list by ip address

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages