Documentation
¶
Index ¶
- type BlockList
- func (b *BlockList) Exists(key string) bool
- func (b *BlockList) Get(key string) (bool, error)
- func (b *BlockList) Length() int
- func (b *BlockList) Name() string
- func (b *BlockList) Remove(key string) bool
- func (b *BlockList) RemoveBatch(keys []string) int
- func (b *BlockList) ServeDNS(ctx context.Context, ch *middleware.Chain)
- func (b *BlockList) Set(key string) bool
- func (b *BlockList) SetBatch(keys []string) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockList ¶
type BlockList struct {
// contains filtered or unexported fields
}
BlockList type
Matching semantics:
- A bare domain (e.g. "example.com") blocks that exact name AND every subdomain ("sub.example.com", "a.b.example.com", ...). This mirrors how Pi-hole/AdGuard/dnsmasq treat a blocked domain and makes the popular plain-domain lists (e.g. hagezi *-onlydomains) work as users expect.
- A "*.example.com" wildcard blocks subdomains only, not the apex.
func New ¶
New returns a new BlockList.
Configured whitelist/blocklist entries and existing local blocklist files are loaded synchronously so filtering is active as soon as New returns. Remote blocklist refresh runs asynchronously — a slow or unreachable source used to leave ServeDNS with empty maps for the entire HTTP timeout window even when local files were available.
func (*BlockList) Exists ¶
(*BlockList).Exists exists returns whether or not a key exists in the cache.
func (*BlockList) Remove ¶
(*BlockList).Remove removes an entry from the blocklist.
The disk write happens outside b.mu so concurrent DNS queries (which take mu.RLock in ServeDNS) are not blocked during I/O.
func (*BlockList) RemoveBatch ¶ added in v1.6.6
(*BlockList).RemoveBatch removes multiple entries in a single mutation and a single disk write. Returns the number actually removed (excluding entries that weren't present).
func (*BlockList) ServeDNS ¶
func (b *BlockList) ServeDNS(ctx context.Context, ch *middleware.Chain)
(*BlockList).ServeDNS serveDNS implements the Handle interface.