Sovite.Abuse.ReverseDNS (sovite v0.6.0)

Copy Markdown View Source

Reverse DNS of a client address, and whether the forward lookup of the name confirms it (forward-confirmed reverse DNS, FCrDNS).

ReverseDNS.check(resolver, {192, 0, 2, 1})
#=> {:ok, "mail.example.com"}

check/3 looks up the PTR names of the address, then the addresses of each name: A records for an IPv4 client, AAAA for IPv6. The first name with the client's address among them is the confirmed hostname. Names are lower-cased, and names that are not valid domains are skipped. IPv4-mapped IPv6 addresses are checked as IPv4.

Options

  • :max_names - how many PTR names to check. Defaults to 10, the limit RFC 7208 §4.6.4 sets for SPF's ptr.

Summary

Types

The result of check/3

Functions

Looks up the reverse DNS of ip and confirms it. See the module documentation.

Returns the PTR name of ip, in in-addr.arpa or ip6.arpa.

Types

result()

@type result() ::
  {:ok, String.t()}
  | {:unconfirmed, [String.t()]}
  | :none
  | {:error, :temporary}

The result of check/3:

  • {:ok, hostname} - a PTR name whose addresses include the client.
  • {:unconfirmed, names} - PTR names, none of which confirms it.
  • :none - no PTR records, or none that is a valid domain name.
  • {:error, :temporary} - a DNS error; a retry might confirm a name.

Functions

check(resolver, ip, opts \\ [])

Looks up the reverse DNS of ip and confirms it. See the module documentation.

reverse_name(ip)

@spec reverse_name(:inet.ip_address()) :: String.t()

Returns the PTR name of ip, in in-addr.arpa or ip6.arpa.

iex> Sovite.Abuse.ReverseDNS.reverse_name({192, 0, 2, 1})
"1.2.0.192.in-addr.arpa"