-
Notifications
You must be signed in to change notification settings - Fork 65
/
blocklistdb.go
43 lines (35 loc) · 1011 Bytes
/
blocklistdb.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
39
40
41
42
43
package rdns
import (
"fmt"
"net"
"github.com/miekg/dns"
)
type BlocklistDB interface {
// Reload initializes a new instance of the same database but with
// a new ruleset loaded.
Reload() (BlocklistDB, error)
// Returns true if the question matches a rule. If the IP is not nil,
// respond with the given IP. NXDOMAIN otherwise. The returned names,
// if set, are used to answer PTR queries
Match(q dns.Question) (ip []net.IP, names []string, m *BlocklistMatch, matched bool)
fmt.Stringer
}
// BlocklistMatch is returned by blocklists when a match is found. It contains
// information about what rule matched, what list it was from etc. Used mostly
// for logging.
type BlocklistMatch struct {
List string // Identifier or name of the blocklist
Rule string // Identifier for the rule that matched
}
func (m *BlocklistMatch) GetList() string {
if m == nil {
return "none"
}
return m.List
}
func (m *BlocklistMatch) GetRule() string {
if m == nil {
return "none"
}
return m.Rule
}