rrda

REST API allowing to perform DNS queries over HTTP
Log | Files | Refs | README | LICENSE

commit c69a417e3451f3e278ff97f95f02a3856e0453f8
parent 201a0f92d736496436a7be4de802b8e4c00f7d3b
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed, 11 Dec 2019 12:43:22 +0100

Switch back to using Msg.MsgHdr.Truncated, as dns.ErrTruncated is obsoleted.

This reverts commit 18c4fa4f4ddad235a91505e1c7c854f676b16be7.

Diffstat:
Mrrda.go | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/rrda.go b/rrda.go @@ -1,11 +1,11 @@ /*****************************************************************************/ /* */ /* RRDA (RRDA REST DNS API) 1.02 */ -/* Copyright (c) 2012-2017, Frederic Cambus */ +/* Copyright (c) 2012-2019, Frederic Cambus */ /* https://www.statdns.com */ /* */ /* Created: 2012-03-11 */ -/* Last Updated: 2017-02-17 */ +/* Last Updated: 2019-12-11 */ /* */ /* RRDA is released under the BSD 2-Clause license. */ /* See LICENSE file for details. */ @@ -109,9 +109,12 @@ func resolve(w http.ResponseWriter, r *http.Request, server string, domain strin c := new(dns.Client) Redo: - in, _, err := c.Exchange(m, server) // Second return value is RTT, not used for now + if in, _, err := c.Exchange(m, server); err == nil { // Second return value is RTT, not used for now + if in.MsgHdr.Truncated { + c.Net = "tcp" + goto Redo + } - if err == nil { switch in.MsgHdr.Rcode { case dns.RcodeServerFailure: error(w, 500, 502, "The name server encountered an internal failure while processing this request (SERVFAIL)") @@ -122,9 +125,6 @@ Redo: default: jsonify(w, r, in.Question, in.Answer, in.Ns, in.Extra) } - } else if err == dns.ErrTruncated { - c.Net = "tcp" - goto Redo } else { error(w, 500, 501, "DNS server could not be reached") }