dnshandler

package
v0.0.0-...-e5a6d6e Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheKey

func CacheKey(msg *dns.Msg) string

CacheKey generates a string key on the tuple (DNS Record Type, Domain Name)

Types

type GoholeHandler

type GoholeHandler struct {
	Resolver *GoholeResolver
}

GoholeHandler is kind of a proxy to the GoholeResolver

func (GoholeHandler) ServeDNS

func (ghh GoholeHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

ServeDNS is the interface we need to satisfy for miekg/dns

type GoholeResolver

type GoholeResolver struct {
	// This is the recursive DNS resolver
	UpstreamDNS []string

	DNSCache *ttlcache.Cache
	// contains filtered or unexported fields
}

GoholeResolver is the cache and blocking mechanism

func NewGoholeResolver

func NewGoholeResolver(c *cli.Context) *GoholeResolver

NewGoholeResolver sets up a new Resolver

func (*GoholeResolver) AllowDomain

func (ghr *GoholeResolver) AllowDomain(domain string)

AllowDomain removes a domain from the blocklist.

func (*GoholeResolver) ApplyBlocklist

func (ghr *GoholeResolver) ApplyBlocklist(blocklistContent []byte)

ApplyBlocklist applies the block list content to the resolver. the content must be in hosts file format

func (*GoholeResolver) BlockDomain

func (ghr *GoholeResolver) BlockDomain(domain string)

BlockDomain blocks a domain in the Resolver. All queries for that domain will return NXDomain.

func (*GoholeResolver) FetchBlocklist

func (ghr *GoholeResolver) FetchBlocklist(url string) ([]byte, error)

FetchBlocklist downloads the given block list and returns it as a string. Returns an error if downloading fails

func (*GoholeResolver) Resolve

func (ghr *GoholeResolver) Resolve(r *dns.Msg) *dns.Msg

Resolve resolves a DNS query and returns a result.

Jump to

Keyboard shortcuts

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