From ebaaa7ff7187651c50d2efe120ff46a2543e8139 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Wed, 21 Mar 2018 02:14:11 +0800 Subject: [PATCH] Enable verbose for IETF protocol --- doh-server/ietf.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doh-server/ietf.go b/doh-server/ietf.go index 96b9013..f35a256 100644 --- a/doh-server/ietf.go +++ b/doh-server/ietf.go @@ -68,6 +68,25 @@ func (s *Server) parseRequestIETF(w http.ResponseWriter, r *http.Request) *DNSRe errtext: fmt.Sprintf("DNS packet parse failure (%s)", err.Error()), } } + + if s.conf.Verbose && len(msg.Question) > 0 { + question := msg.Question[0] + questionName := question.Name + questionClass := "" + if qclass, ok := dns.ClassToString[question.Qclass]; ok { + questionClass = qclass + } else { + questionClass = strconv.Itoa(int(question.Qclass)) + } + questionType := "" + if qtype, ok := dns.TypeToString[question.Qtype]; ok { + questionType = qtype + } else { + questionType = strconv.Itoa(int(question.Qtype)) + } + fmt.Printf("%s - - [%s] \"%s %s %s\"\n", r.RemoteAddr, time.Now().Format("02/Jan/2006:15:04:05 -0700"), questionName, questionClass, questionType) + } + msg.Id = dns.Id() opt := msg.IsEdns0() if opt == nil {