github.com/mamantoha/resolv-crystal

A DNS resolver library written in Crystal

4 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  resolv:
    github: mamantoha/resolv-crystal
    version: ~> 0.8.0

Then run:

shards install

shard.yml

Crystal
>= 1.0.0
License
MIT
Author
Anton Maminov

Dependencies

This version declares no dependencies.

README

Resolv

Crystal CI GitHub release License

Resolv is a DNS resolver library in Crystal that supports UDP, TCP, and DoH (DNS-over-HTTPS).

Supported Resource Record (RR) TYPEs :

TypeValueMeaningDefining RFC
A1a host addressRFC 1035
NS2an authoritative name serverRFC 1035
MD3a mail destination (Obsolete - use MX)RFC 1035
MF4a mail forwarder (Obsolete - use MX)RFC 1035
CNAME5the canonical name for an aliasRFC 1035
SOA6marks the start of a zone of authorityRFC 1035
MB7a mailbox domain name (EXPERIMENTAL)RFC 1035
MG8a mail group member (EXPERIMENTAL)RFC 1035
MR9a mail rename domain name (EXPERIMENTAL)RFC 1035
NULL10a null RR (EXPERIMENTAL)RFC 1035
WKS11a well known service descriptionRFC 1035
PTR12a domain name pointerRFC 1035
HINFO13host informationRFC 1035
MINFO14mailbox or mail list informationRFC 1035
MX15mail exchangeRFC 1035
TXT16text stringsRFC 1035
AAAA28IPv6 host addressRFC 3596
SRV33service locationRFC 2782
CAA257certification authority authorizationRFC 8659
LOC29Location recordRFC 1876

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      resolv:
        github: mamantoha/resolv-crystal
  2. Run shards install

Usage

require "resolv"

dns = Resolv::DNS.new("8.8.8.8", read_timeout: 10.seconds, retry: 3, requester: :tcp)

dns.resources("crystal-lang.org", :a)
# #<Resolv::DNS::Resource::A:0x1010d0c40 @address="18.66.112.124">

dns.mx_resources("gmail.com")
# #<Resolv::DNS::Resource::MX:0x1010d0560 @preference=40, @exchange="alt4.gmail-smtp-in.l.google.com">

dns.soa_resources("gmail.com")
# => #<Resolv::DNS::Resource::SOA:0x10245c100 @mname="ns1.google.com", @rname="dns-admin.google.com", @serial=646797294, @refresh=900, @retry=900, @expire=1800, @minimum=60>

dns.srv_resources("_xmpp-client._tcp.jabber.org")
# #<Resolv::DNS::Resource::SRV:0x74689eebdf60 @priority=30, @weight=30, @port=5222, @target="zeus.jabber.org">

dns = Resolv::DNS.new("dns.toys")
dns.txt_resources("lviv.weather")
# #<Resolv::DNS::Resource::TXT:0x104cf00a0 @txt_data=["Lviv (UA)", "28.00C (82.40F)", "43.90% hu.", "partlycloudy_day", "14:00, Thu"]>

Alternatives

Other alternatives are:

Contributing

  1. Fork it (https://github.com/mamantoha/resolv-crystal/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors