Packages

A tool to map IPs, perform HTTP requests, and do reverse DNS lookups

Current section

Files

Jump to
inetnet_mapper lib internet_mapper http_fetcher.ex
Raw

lib/internet_mapper/http_fetcher.ex

defmodule InternetMapper.HTTPFetcher do
def fetch(ip) when is_binary(ip) do
url = "http://#{ip}/"
req = Finch.build(:get, url)
case Finch.request(req, InternetMapper.Finch, receive_timeout: 5_000) do
{:ok, %Finch.Response{status: status}} -> {:success, status}
{:error, reason} -> {:failure, reason}
end
rescue
e -> {:failure, e}
end
end