-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservfail.go
38 lines (29 loc) · 1020 Bytes
/
servfail.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package example is a CoreDNS plugin that prints "example" to stdout on every packet received.
//
// It serves as an example CoreDNS plugin with numerous code comments.
package servfail
import (
"context"
"github.com/coredns/coredns/plugin"
clog "github.com/coredns/coredns/plugin/pkg/log"
"github.com/miekg/dns"
)
// Define log to be a logger with the plugin name in it. This way we can just use log.Info and
// friends to log.
var log = clog.NewWithPlugin("servfail")
type ServFail struct {
Next plugin.Handler
}
// ServeDNS implements the plugin.Handler interface. This method gets called when example is used
// in a Server.
func (e *ServFail) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
msg := new(dns.Msg)
msg.SetReply(r)
msg.Authoritative = true
msg.RecursionAvailable = true
msg.Rcode = dns.RcodeServerFailure
w.WriteMsg(msg)
return dns.RcodeSuccess, nil
}
// Name implements the Handler interface.
func (e *ServFail) Name() string { return "servfail" }