adblock

package module
v0.0.0-...-a9b9d8e Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

CoreDNS AdBlock Plugin

[!IMPORTANT] This plugin is still actively being worked on.
Expect possible changes or reworks of how this plugin functions and how the config is structured.

Additionally, this README isn't always up-to-date, so not everything mentioned here might work as described.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConsulClient

func CreateConsulClient(consul *ConsulConfig) error

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultvalue string) string

func HandleError

func HandleError(request *dns.Msg, rcode int, writer dns.ResponseWriter, e error) (int, error)

func HandleNXDomain

func HandleNXDomain(qname string, request *dns.Msg, writer dns.ResponseWriter) (int, error)

func LoadAdBlockConfig

func LoadAdBlockConfig(c *caddy.Controller, config *AdBlockConfig) error

func LoadEnvFile

func LoadEnvFile(path string) error

func PrepareResponseRcode

func PrepareResponseRcode(request *dns.Msg, rcode int, recursionAvailable bool) *dns.Msg

func PrepareResponseReply

func PrepareResponseReply(request *dns.Msg, recursionAvailable bool) *dns.Msg

Types

type AdBlockConfig

type AdBlockConfig struct {
	Lists  []AdBlockList
	Consul ConsulConfig
}

func CreateAdBlockConfig

func CreateAdBlockConfig(c *caddy.Controller) (*AdBlockConfig, error)

func (*AdBlockConfig) UpdateNamedList

func (config *AdBlockConfig) UpdateNamedList(name string, entries []AdBlockEntry) bool

type AdBlockEntry

type AdBlockEntry struct {
	Pattern   string
	Modifiers map[string]string
	Address   net.IP
	TTL       uint32
	Wildcard  bool
}

func ParseDomainEntry

func ParseDomainEntry(domain string, address net.IP) AdBlockEntry

type AdBlockList

type AdBlockList struct {
	Name    string
	Entries []AdBlockEntry
}

func ParseAdBlockFile

func ParseAdBlockFile(reader io.Reader) (*AdBlockList, error)

func ParseHostsFile

func ParseHostsFile(name string, reader io.Reader) (*AdBlockList, error)

type AdBlockPlugin

type AdBlockPlugin struct {
	Next   plugin.Handler
	Config *AdBlockConfig
}

func CreatePlugin

func CreatePlugin(c *caddy.Controller) (*AdBlockPlugin, error)

func (AdBlockPlugin) DebugPrintLists

func (plug AdBlockPlugin) DebugPrintLists()

func (AdBlockPlugin) IsMatch

func (plug AdBlockPlugin) IsMatch(qname string) (bool, *AdBlockEntry)

func (AdBlockPlugin) Name

func (plug AdBlockPlugin) Name() string

func (AdBlockPlugin) ServeDNS

func (plug AdBlockPlugin) ServeDNS(ctx context.Context, writer dns.ResponseWriter, r *dns.Msg) (int, error)

type ConsulConfig

type ConsulConfig struct {
	Client       *api.Client
	Address      string
	Token        string
	DisableWatch bool
}

func CreateConsulConfig

func CreateConsulConfig(c *caddy.Controller) (*ConsulConfig, error)

func GetConsulEnvConfig

func GetConsulEnvConfig() ConsulConfig

func (*ConsulConfig) GetConsulKeyValue

func (consul *ConsulConfig) GetConsulKeyValue(key string) (*api.KVPair, float64, error)

func (ConsulConfig) ParseConsulFile

func (consul ConsulConfig) ParseConsulFile(key string) (*AdBlockList, error)

func (ConsulConfig) WatchConsulKey

func (consul ConsulConfig) WatchConsulKey(key string, fn handler) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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