Elixir interface to the host DNS utility https://hex.pm/packages/host
Find a file
2019-05-23 11:14:33 -07:00
config feature: passing tests 2018-03-06 22:50:39 -08:00
lib Merge branch 'more-types' of github.com:public-law/host into more-types 2019-02-20 23:12:46 -08:00
test new Error interface 2019-02-13 15:55:28 -08:00
.formatter.exs feature: passing tests 2018-03-06 22:50:39 -08:00
.gitignore feature: accept ip tuple 2018-03-07 15:58:38 -08:00
mix.exs remove Vex 2019-02-13 17:30:00 -08:00
mix.lock IPv4 module 2019-02-13 14:17:21 -08:00
README.md Update README.md 2019-05-23 11:14:33 -07:00

Reverse DNS

Provides reverse DNS name lookup. I.e., given an IP address, 1.2.3.4, it tries to find its domain name, happy.town.com.

iex(1)> Host.reverse_lookup(ip: "172.217.5.206")
{:ok, "lax28s10-in-f14.1e100.net"}

iex(2)> Host.reverse_lookup(ip: {172,217,5,206})
{:ok, "lax28s10-in-f14.1e100.net"}

This is useful e.g. in Phoenix, to get the vistor's domain name if it exists:

{:ok, visitor_domain_name} = Host.reverse_lookup(ip: conn.remote_ip)

Installation

The package can be installed by adding host to your list of dependencies in mix.exs:

def deps do
  [
    {:host, "~> 0.1.0"}
  ]
end