blocklist

package
v1.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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 Supports wildcard domains like "*.example.com" to block all subdomains.

func New

func New(cfg *config.Config) *BlockList

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

func (b *BlockList) Exists(key string) bool

(*BlockList).Exists exists returns whether or not a key exists in the cache.

func (*BlockList) Get

func (b *BlockList) Get(key string) (bool, error)

(*BlockList).Get get returns the entry for a key or an error.

func (*BlockList) Length

func (b *BlockList) Length() int

(*BlockList).Length length returns the caches length.

func (*BlockList) Name

func (b *BlockList) Name() string

(*BlockList).Name name return middleware name.

func (*BlockList) Remove

func (b *BlockList) Remove(key string) bool

(*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

func (b *BlockList) RemoveBatch(keys []string) int

(*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.

func (*BlockList) Set

func (b *BlockList) Set(key string) bool

(*BlockList).Set sets a value in 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) SetBatch added in v1.6.6

func (b *BlockList) SetBatch(keys []string) int

(*BlockList).SetBatch adds multiple entries in a single mutation and a single disk write. Whitelisted keys are skipped. Returns the number actually added (excluding duplicates and whitelisted entries).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL