dnsproxy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dnsproxy contains the DNS proxy.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Address is the default listen address of the DNS proxy.
	Address = "127.0.0.1:4253"

	// ListenUDP specifies whether the DNS proxy listens on UDP.
	ListenUDP = true

	// ListenTCP specifies whether the DNS proxy listens on TCP.
	ListenTCP = true
)

Functions

This section is empty.

Types

type Config added in v0.1.0

type Config struct {
	Address   string
	ListenUDP bool
	ListenTCP bool
}

Config is a DNS proxy configuration.

func NewConfig added in v0.1.0

func NewConfig() *Config

NewConfig returns a new DNS proxy configuration.

func (*Config) Valid added in v0.1.0

func (c *Config) Valid() bool

Valid returns whether the DNS proxy configuration is valid.

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is a DNS proxy.

func NewProxy

func NewProxy(config *Config) *Proxy

NewProxy returns a new Proxy that listens on address.

func (*Proxy) Reports

func (p *Proxy) Reports() chan *Report

Reports returns the Report channel for watched domains.

func (*Proxy) SetRemotes

func (p *Proxy) SetRemotes(remotes map[string][]string)

SetRemotes sets the mapping from domain names to remote server addresses.

func (*Proxy) SetWatches

func (p *Proxy) SetWatches(watches []string)

SetWatches sets the domains watched for A and AAAA record updates.

func (*Proxy) Start

func (p *Proxy) Start()

Start starts running the proxy.

func (*Proxy) Stop

func (p *Proxy) Stop()

Stop stops running the proxy.

type Remotes

type Remotes struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Remotes contains a mapping from domain names to remote DNS servers.

func NewRemotes

func NewRemotes() *Remotes

NewRemotes returns a new Remotes.

func (*Remotes) Add

func (r *Remotes) Add(domain string, servers []string)

Add adds a mapping from domain to servers.

func (*Remotes) Flush

func (r *Remotes) Flush()

Flush removes all mappings.

func (*Remotes) Get

func (r *Remotes) Get(domain string) []string

Get returns the servers for domain.

func (*Remotes) Remove

func (r *Remotes) Remove(domain string)

Remove removes a mapping from domain to servers.

type Report

type Report struct {
	Name string
	IP   net.IP
	TTL  uint32
	// contains filtered or unexported fields
}

Report is a report for a watched domain.

func NewReport

func NewReport(name string, ip net.IP, ttl uint32) *Report

NewReport returns a new report with domain name, IP and TTL.

func (*Report) Done

func (r *Report) Done()

Done signals that the report has been handled by its consumer.

func (*Report) String

func (r *Report) String() string

String returns the report as string.

func (*Report) Wait

func (r *Report) Wait()

Wait waits for the report to be handled by its consumer.

type Watches

type Watches struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Watches contains a list of domains to watch for A and AAAA updates.

func NewWatches

func NewWatches() *Watches

NewWatches returns a new Watches.

func (*Watches) Add

func (w *Watches) Add(domain string)

Add adds domain to the watch list.

func (*Watches) AddTempCNAME added in v1.0.0

func (w *Watches) AddTempCNAME(domain string, ttl uint32)

AddTempCNAME adds a temporary CNAME domain to the watch list with a ttl.

func (*Watches) AddTempDNAME added in v1.0.0

func (w *Watches) AddTempDNAME(domain string, ttl uint32)

AddTempDNAME adds a temporary DNAME domain to the watch list with a ttl.

func (*Watches) Close added in v0.2.0

func (w *Watches) Close()

Close closes the watches

func (*Watches) Contains

func (w *Watches) Contains(domain string) bool

Contains returns whether the domain is in the watch list.

func (*Watches) Flush

func (w *Watches) Flush()

Flush removes all entries from the watch list.

func (*Watches) Remove

func (w *Watches) Remove(domain string)

Remove removes domain from the watch list.

Jump to

Keyboard shortcuts

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