-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathdrop.go
More file actions
28 lines (22 loc) · 696 Bytes
/
drop.go
File metadata and controls
28 lines (22 loc) · 696 Bytes
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
package rdns
import (
"github.com/miekg/dns"
)
// DropResolver is a resolver that returns nil for every query which then
// causes any listeners to close the connection on the client.
type DropResolver struct {
id string
}
var _ Resolver = &DropResolver{}
// NewDropResolver returns a new instance of a DropResolver resolver.
func NewDropResolver(id string) *DropResolver {
return &DropResolver{id}
}
// Resolve a DNS query by returning nil to signal to the listener to drop this request.
func (r *DropResolver) Resolve(q *dns.Msg, ci ClientInfo) (*dns.Msg, error) {
logger(r.id, q, ci).Debug("dropping query")
return nil, nil
}
func (r *DropResolver) String() string {
return r.id
}