Documentation ¶
Overview ¶
Package proxard implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be 50% faster than just opening a new connection for every client. It works with UDP and TCP and uses inband healthchecking.
Package forward implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be 50% faster than just opening a new connection for every client. It works with UDP and TCP and uses inband healthchecking.
Index ¶
- Variables
- type HealthChecker
- type Proxard
- func (f *Proxard) ForceTCP() bool
- func (f *Proxard) Len() int
- func (f *Proxard) List() []*Proxy
- func (f *Proxard) Name() string
- func (f *Proxard) OnShutdown() error
- func (f *Proxard) OnStartup() (err error)
- func (f *Proxard) PreferUDP() bool
- func (f *Proxard) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
- func (f *Proxard) SetProxy(p *Proxy)
- type Proxy
- type Transport
Constants ¶
This section is empty.
Variables ¶
var ( RequestCount = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "proxard", Name: "request_count_total", Help: "Counter of requests made per upstream.", }, []string{"to"}) RcodeCount = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "proxard", Name: "response_rcode_count_total", Help: "Counter of requests made per upstream.", }, []string{"rcode", "to"}) RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: plugin.Namespace, Subsystem: "proxard", Name: "request_duration_seconds", Buckets: plugin.TimeBuckets, Help: "Histogram of the time each request took.", }, []string{"to"}) HealthcheckFailureCount = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "proxard", Name: "healthcheck_failure_count_total", Help: "Counter of the number of failed healthchecks.", }, []string{"to"}) HealthcheckBrokenCount = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "proxard", Name: "healthcheck_broken_count_total", Help: "Counter of the number of complete failures of the healthchecks.", }) SocketGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: plugin.Namespace, Subsystem: "proxard", Name: "sockets_open", Help: "Gauge of open sockets per upstream.", }, []string{"to"}) MaxConcurrentRejectCount = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "proxard", Name: "max_concurrent_reject_count_total", Help: "Counter of the number of queries rejected because the concurrent queries were at maximum.", }) )
Variables declared for monitoring.
var ( // ErrNoHealthy means no healthy proxies left. ErrNoHealthy = errors.New("no healthy proxies") // ErrNoForward means no forwarder defined. ErrNoForward = errors.New("no forwarder defined") // ErrCachedClosed means cached connection was closed by peer. ErrCachedClosed = errors.New("cached connection was closed by peer") )
Functions ¶
This section is empty.
Types ¶
type HealthChecker ¶
type HealthChecker interface { Check(*Proxy) error SetTLSConfig(*tls.Config) SetRecursionDesired(bool) GetRecursionDesired() bool }
HealthChecker checks the upstream health.
func NewHealthChecker ¶
func NewHealthChecker(trans string, recursionDesired bool) HealthChecker
NewHealthChecker returns a new HealthChecker based on transport.
type Proxard ¶
type Proxard struct { // ErrLimitExceeded indicates that a query was rejected because the number of concurrent queries has exceeded // the maximum allowed (maxConcurrent) ErrLimitExceeded error Next plugin.Handler // contains filtered or unexported fields }
Proxard represents a plugin instance that can proxy requests to another (DNS) server. It has a list of proxies each representing one upstream proxy.
func (*Proxard) ForceTCP ¶
ForceTCP returns if TCP is forced to be used even when the request comes in over UDP.
func (*Proxard) List ¶
List returns a set of proxies to be used for this client depending on the policy in f.
func (*Proxard) OnShutdown ¶
OnShutdown stops all configured proxies.
func (*Proxard) PreferUDP ¶
PreferUDP returns if UDP is preferred to be used even when the request comes in over TCP.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy defines an upstream host.
func (*Proxy) Healthcheck ¶
func (p *Proxy) Healthcheck()
Healthcheck kicks of a round of health checks for this proxy.
func (*Proxy) SetTLSConfig ¶
SetTLSConfig sets the TLS config in the lower p.transport and in the healthchecking client.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport hold the persistent cache.
func (*Transport) Dial ¶
Dial dials the address configured in transport, potentially reusing a connection or creating a new one.
func (*Transport) SetTLSConfig ¶
SetTLSConfig sets the TLS config in transport.