Browse Source

handle dns.PackMessage error

this will fix #2599
DuckSoft 5 years ago
parent
commit
780318c5c8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      app/dns/dohdns.go

+ 5 - 1
app/dns/dohdns.go

@@ -246,7 +246,11 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
 			dnsCtx, cancel := context.WithDeadline(dnsCtx, deadline)
 			defer cancel()
 
-			b, _ := dns.PackMessage(r.msg)
+			b, err := dns.PackMessage(r.msg)
+			if err != nil {
+				newError("failed to pack dns query").Base(err).AtError().WriteToLog()
+				return
+			}
 			resp, err := s.dohHTTPSContext(dnsCtx, b.Bytes())
 			if err != nil {
 				newError("failed to retrieve response").Base(err).AtError().WriteToLog()