tungd/elixir-dns

(CaseClauseError) no case clause matching: {"8.8.8.8", 53}

messutied opened this issue · 3 comments

Hi, I'm testing the package locally, running DNS.resolve("google.com") works, but running DNS.resolve("google.com", {"8.8.8.8", 53}) gives me the following error:

** (CaseClauseError) no case clause matching: {"8.8.8.8", 53}
    (kernel) inet_dns.erl:346: :inet_dns.encode_type/1
    (kernel) inet_dns.erl:267: :inet_dns.encode_query_section/3
    (kernel) inet_dns.erl:240: :inet_dns.encode/1
    (dns) lib/dns.ex:46: DNS.query/3
    (dns) lib/dns.ex:15: DNS.resolve/3

Any ideas? by the examples in the readme it looks like this should work.
Thanks

tungd commented

It looks like there are some change in the inet_dns module. What's your version of Erlang, Elixir and elixir-dns?

Hi @tungd, my Erlang version is Erlang/OTP 20 [erts-9.3.1], Elixir (1.4.5) and elixir-dns 2.1.0.

tungd commented

Hi, I'm so sorry for the late reply, and also sorry for the confusion. We have a breaking change in 2.x that resolve now include the record type. If you want to specify the DNS server you'll also need to include the record type. For example:

DNS.resolve("google.com", :a, {"8.8.8.8", 53}) # --> {:ok, [{172, 217, 24, 206}]}

I've updated the README to reflect this change.