From bf934ca0290d20cb47677614f65c3362242e13eb Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Fri, 16 Dec 2016 08:55:04 +0000 Subject: [PATCH] cmd/ensdns: Replace LGPL header with GPL header --- cmd/ensdns/main.go | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/cmd/ensdns/main.go b/cmd/ensdns/main.go index 81df6fbb45..c163ed95e4 100644 --- a/cmd/ensdns/main.go +++ b/cmd/ensdns/main.go @@ -1,18 +1,18 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. // -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // -// The go-ethereum library is distributed in the hope that it will be useful, +// go-ethereum is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. +// GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . +// You should have received a copy of the GNU General Public License +// along with go-ethereum. If not, see . package main @@ -85,9 +85,24 @@ func (ed *ENSDNS) Handle(w dns.ResponseWriter, r *dns.Msg) { if err != nil { log.Printf("Error resolving query %v: %v", question, err) m.Rcode = dns.RcodeServerFailure + break } + + // If no answer is found, and this wasn't a CNAME or * query, try looking for CNAMEs + if len(answers) == 0 && question.Qtype != dns.TypeCNAME && question.Qtype != dns.TypeANY { + question.Qtype = dns.TypeCNAME + answers, err = ed.resolve(question) + if err != nil { + log.Printf("Error resolving query %v: %v", question, err) + m.Rcode = dns.RcodeServerFailure + break + } + } + m.Answer = append(m.Answer, answers...) + m.Authoritative = true } + w.WriteMsg(m) }