Project

flareon

0.01
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
A cloudflare DNS resolver client library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
>= 0
~> 10.0
~> 3.0

Runtime

~> 0.16.2
~> 1.12.1
 Project Readme

Flareon

A cloudflare DNS over HTTPs resolver client library.

Pokemon, gott'a catch 'em all!

Cloudflare’s DNS over HTTPs endpoint supports JSON format for querying DNS data -- and this gem helps to use it!

Installation

$ gem install flareon

Usage

Perform a basic DNS query over HTTPs:

Flareon.query("google.com")
# => {
#     "Status"=>0,
#     "TC"=>false,
#     "RD"=>true,
#     "RA"=>true,
#     "AD"=>false,
#     "CD"=>false,
#     "Question"=>[{"name"=>"google.com.", "type"=>1}],
#     "Answer"=>[{"name"=>"google.com.", "type"=>1, "TTL"=>83, "data"=>"172.217.1.46"}]
#    }

Single-threaded DNS query (IPv6) over HTTPs for multiple domains:

domains = ["google.com", "github.com", "microsoft.com", "apple.com"]

results = Flareon.batch_query(domains, type: "AAAA")

Multi-threaded DNS query (IPv4) over HTTPs for multiple domains:

domains = ["google.com", "github.com", "microsoft.com", "apple.com"]

results = Flareon.batch_query_multithreaded(domains, threads: 4) 

Get the raw JSON response:

json = Flareon.query("google.com", json: true)

Specify DNS query type:

Flareon.query("google.com", type: "A")
Flareon.query("google.com", type: "AAAA")
Flareon.query("google.com", type: "MX")

The nslookup method is an alias for the query method:

Flareon.nslookup("google.com")

The dig method is an alias for the query method:

Flareon.dig("google.com")

Check if a given name is resolvable:

Flareon.resolve?("google.com")
# => true

Resolve a given domain to an IP address:

Flareon.resolve("google.com")
# => "172.217.1.46"

Resolve a given domain to an IPv4 address:

Flareon.resolve("google.com")
Flareon.resolve("google.com", type: "A")
Flareon.resolve("google.com", type: 1)

Resolve a given domain to an IPv6 address:

Flareon.resolve("google.com", type: "AAAA")
Flareon.resolve("google.com", type: 28)

Resolve a give domain to all IPv4 and IPv6 addresses:

ip_addresses = Flareon.resolve_all("google.com")

# or

Flareon.resolve_all("google.com") do |ip_address|
  # do something with each ip_address
  puts ip_address
end

Inspiration

Saw hrbrmstr working on dnsflare and wanted something similiar in Ruby.

License

The gem is available as open source under the terms of the MIT License.