mirror of
https://github.com/coredns/coredns.git
synced 2025-12-16 23:35:11 -05:00
plugin/template : add support for extended DNS errors (#5659)
* plugin/template : add support for extended DNS errors Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
This commit is contained in:
@@ -33,10 +33,16 @@ type template struct {
|
||||
authority []*gotmpl.Template
|
||||
qclass uint16
|
||||
qtype uint16
|
||||
ederror *ederror
|
||||
fall fall.F
|
||||
upstream Upstreamer
|
||||
}
|
||||
|
||||
type ederror struct {
|
||||
code uint16
|
||||
reason string
|
||||
}
|
||||
|
||||
// Upstreamer looks up targets of CNAME templates
|
||||
type Upstreamer interface {
|
||||
Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error)
|
||||
@@ -125,6 +131,12 @@ func (h Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
msg.Ns = append(msg.Ns, rr)
|
||||
}
|
||||
|
||||
if template.ederror != nil {
|
||||
msg = msg.SetEdns0(4096, true)
|
||||
ede := dns.EDNS0_EDE{InfoCode: template.ederror.code, ExtraText: template.ederror.reason}
|
||||
msg.IsEdns0().Option = append(msg.IsEdns0().Option, &ede)
|
||||
}
|
||||
|
||||
w.WriteMsg(msg)
|
||||
return template.rcode, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user