proxy

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: Unlicense Imports: 17 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	UDPListenAddr *net.UDPAddr // if nil, then it does not listen for UDP
	TCPListenAddr *net.TCPAddr // if nil, then it does not listen for TCP

	TLSListenAddr *net.TCPAddr // if nil, then it does not listen for TLS (DoT)
	TLSConfig     *tls.Config  // necessary for listening for TLS

	Ratelimit          int      // max number of requests per second from a given IP (0 to disable)
	RatelimitWhitelist []string // a list of whitelisted client IP addresses

	RefuseAny bool // if true, refuse ANY requests

	CacheEnabled bool // cache status

	Upstreams []upstream.Upstream // list of upstreams
	Fallback  upstream.Upstream   // fallback resolver (which will be used if regular upstream failed to answer)
	Handler   Handler             // custom middleware (optional)
}

Config contains all the fields necessary for proxy configuration

type DNSContext

type DNSContext struct {
	Proto       string            // "udp", "tcp", "tls", "https"
	Req         *dns.Msg          // DNS request
	Res         *dns.Msg          // DNS response from an upstream
	Conn        net.Conn          // underlying client connection
	Addr        net.Addr          // client address
	StartTime   time.Time         // processing start time
	Upstream    upstream.Upstream // upstream that was chosen
	UpstreamIdx int               // upstream index
}

DNSContext represents a DNS request message context

type Handler

type Handler func(p *Proxy, d *DNSContext) error

Handler is an optional custom handler for DNS requests It is called instead of the default method (Proxy.Resolve()) See handler_test.go for examples

type Proxy

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

Proxy combines the proxy server state and configuration

func (*Proxy) Addr added in v0.9.1

func (p *Proxy) Addr(proto string) net.Addr

Addr returns the listen address for the specified proto or null if the proxy does not listen to it

func (*Proxy) Resolve added in v0.9.1

func (p *Proxy) Resolve(d *DNSContext) error

Resolve is the default resolving method used by the DNS proxy to query upstreams

func (*Proxy) Start

func (p *Proxy) Start() error

Start initializes the proxy server and starts listening

func (*Proxy) Stop

func (p *Proxy) Stop() error

Stop stops the proxy server including all its listeners

Jump to

Keyboard shortcuts

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