Documentation ¶
Overview ¶
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 openening 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 openening 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 openening a new connection for every client. It works with UDP and TCP and uses inband healthchecking.
Index ¶
- Constants
- Variables
- type Forward
- func (f *Forward) Close()
- func (f *Forward) Forward(state request.Request) (*dns.Msg, error)
- func (f *Forward) Len() int
- func (f *Forward) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error)
- func (f *Forward) Name() string
- func (f *Forward) OnShutdown() error
- func (f *Forward) OnStartup() (err error)
- func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
- func (f *Forward) SetProxy(p *Proxy)
- type Policy
- type Proxy
Constants ¶
const ( DNS = iota + 1 TLS )
Supported protocols.
Variables ¶
var ( RequestCount = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "forward", Name: "request_count_total", Help: "Counter of requests made per upstream.", }, []string{"to"}) RcodeCount = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "forward", Name: "response_rcode_count_total", Help: "Counter of requests made per upstream.", }, []string{"rcode", "to"}) RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: plugin.Namespace, Subsystem: "forward", 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: "forward", Name: "healthcheck_failure_count_total", Help: "Counter of the number of failed healtchecks.", }, []string{"to"}) HealthcheckBrokenCount = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "forward", Name: "healthcheck_broken_count_total", Help: "Counter of the number of complete failures of the healtchecks.", }) SocketGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: plugin.Namespace, Subsystem: "forward", Name: "socket_count_total", Help: "Guage of open sockets per upstream.", }, []string{"to"}) )
Variables declared for monitoring.
Functions ¶
This section is empty.
Types ¶
type Forward ¶
Forward represents a plugin instance that can proxy requests to another (DNS) server. It has a list of proxies each representing one upstream proxy.
func NewLookup ¶
NewLookup returns a Forward that can be used for plugin that need an upstream to resolve external names. Note that the caller must run Close on the forward to stop the health checking goroutines.
func (*Forward) Forward ¶
Forward forward the request in state as-is. Unlike Lookup that adds EDNS0 suffix to the message. Forward may be called with a nil f, an error is returned in that case.
func (*Forward) Lookup ¶
Lookup will use name and type to forge a new message and will send that upstream. It will set any EDNS0 options correctly so that downstream will be able to process the reply. Lookup may be called with a nil f, an error is returned in that case.
func (*Forward) OnShutdown ¶
OnShutdown stops all configured proxies.
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.