Skip to content

Commit

Permalink
proxy: add servfail
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Apr 5, 2024
1 parent 2dae2da commit 3533c3f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions proxy/beforerequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ type BeforeRequestHandler interface {
// set accordingly.
//
// If returned err is a [BeforeRequestError], the given response message is
// used, on any other error processed at all. If err is nil, the request is
// processed further. [Proxy] assumes a handler itself doesn't set the
// [DNSContext.Res] field.
// used, on any other error a SERVFAIL response used. If err is nil, the
// request is processed further. [Proxy] assumes a handler itself doesn't
// set the [DNSContext.Res] field.
HandleBefore(p *Proxy, dctx *DNSContext) (err error)
}

Expand All @@ -72,13 +72,14 @@ func (p *Proxy) handleBefore(d *DNSContext) (cont bool) {

log.Debug("dnsproxy: handling before request: %s", err)

befReqErr := new(*BeforeRequestError)
if errors.As(err, befReqErr) {
if befReqErr := new(*BeforeRequestError); errors.As(err, befReqErr) {
d.Res = (*befReqErr).Response

p.logDNSMessage(d.Res)
p.respond(d)
} else {
d.Res = p.messages.NewMsgSERVFAIL(d.Req)
}

p.logDNSMessage(d.Res)
p.respond(d)

return false
}

0 comments on commit 3533c3f

Please sign in to comment.