Sfoglia il codice sorgente

if Pack'ing fails the Write fails. Return SERVFAIL.

Ask Bjørn Hansen 13 anni fa
parent
commit
a311f705cc
1 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 6 3
      serve.go

+ 6 - 3
serve.go

@@ -95,9 +95,12 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
 
 	logPrintln(m)
 
-	// Ideally you would check the return code here, and perform SERVFAIL in case of
-	// an error.
-	w.Write(m)
+	err := w.Write(m)
+	if err != nil {
+		// if Pack'ing fails the Write fails. Return SERVFAIL.
+		log.Println("Error writing packet", m)
+		dns.Failed(w, req)
+	}
 	return
 }