blocklist

package
v0.0.0-...-54f910c Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeBlockListHostsReaderf

func MakeBlockListHostsReaderf(b *BlockList) func(line string) error

func MakeBlockListReaderf

func MakeBlockListReaderf(b *BlockList, default_qtype uint16) func(line string) error

func NewLevel

func NewLevel() *level

Types

type BlockEntry

type BlockEntry struct {
	Name  string   `json:"name"`
	Block []string `json:"block"`
}

type BlockList

type BlockList struct {
	sync.RWMutex
	Root *level
}

func New

func New() *BlockList

func (*BlockList) Add

func (b *BlockList) Add(name string, qtype uint16)

Add entry

func (*BlockList) AddEntry

func (b *BlockList) AddEntry(entry string, default_qtype uint16) error

Add entry in format 'domain:qtype' (if qtype is missing use default)

func (*BlockList) AddHostsEntry

func (b *BlockList) AddHostsEntry(entry string) error

Add line from hosts file (only add if this is 0.0.0.0)

Expected format is:

0.0.0.0 domain 	# comment (optional)

func (*BlockList) Count

func (b *BlockList) Count() int

Note - this counts the number of block entries not the number of nodes (nodes with no block entries are not counted and if a single node has multiple block entries these are all counted)

func (*BlockList) Delete

func (b *BlockList) Delete(qname string, qtype uint16) bool

Delete single entry

func (*BlockList) DeleteEntry

func (b *BlockList) DeleteEntry(entry string, default_qtype uint16) (bool, error)

Add entry in format 'domain:qtype' (if qtype is missing use default)

func (*BlockList) DeleteTree

func (b *BlockList) DeleteTree(qname string) bool

Delete subtree under qname

func (*BlockList) Dump

func (b *BlockList) Dump() (out []BlockEntry)

Dump BlockList entries

func (*BlockList) Match

func (b *BlockList) Match(qname string, qtype uint16) bool

Match query against BlockList

func (*BlockList) PrintTree

func (b *BlockList) PrintTree()

Jump to

Keyboard shortcuts

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