Skip to content

Commit 034f791

Browse files
Brian SheaBrian
Brian Shea
and
Brian
authored
answer queries with no matching handler with RcodeRefused (miekg#1151)
* answer queries with no matching handler with RcodeRefused * update documentation * mark HandleFailed deprecated * add handleRefused and use it to answer requests matching no handler * silence noise maker Co-authored-by: Brian <[email protected]>
1 parent 9df839b commit 034f791

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

serve_mux.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (mux *ServeMux) HandleRemove(pattern string) {
9191
// are redirected to the parent zone (if that is also registered),
9292
// otherwise the child gets the query.
9393
//
94-
// If no handler is found, or there is no question, a standard SERVFAIL
94+
// If no handler is found, or there is no question, a standard REFUSED
9595
// message is returned
9696
func (mux *ServeMux) ServeDNS(w ResponseWriter, req *Msg) {
9797
var h Handler
@@ -102,7 +102,7 @@ func (mux *ServeMux) ServeDNS(w ResponseWriter, req *Msg) {
102102
if h != nil {
103103
h.ServeDNS(w, req)
104104
} else {
105-
HandleFailed(w, req)
105+
handleRefused(w, req)
106106
}
107107
}
108108

server.go

+8
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ type response struct {
7878
writer Writer // writer to output the raw DNS bits
7979
}
8080

81+
// handleRefused returns a HandlerFunc that returns REFUSED for every request it gets.
82+
func handleRefused(w ResponseWriter, r *Msg) {
83+
m := new(Msg)
84+
m.SetRcode(r, RcodeRefused)
85+
w.WriteMsg(m)
86+
}
87+
8188
// HandleFailed returns a HandlerFunc that returns SERVFAIL for every request it gets.
89+
// Deprecated: This function is going away.
8290
func HandleFailed(w ResponseWriter, r *Msg) {
8391
m := new(Msg)
8492
m.SetRcode(r, RcodeServerFailure)

0 commit comments

Comments
 (0)