Documentation ¶
Overview ¶
Package proxy 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 ¶
- Constants
- Variables
- type HealthChecker
- type Proxy
- func (p *Proxy) Addr() string
- func (p *Proxy) Connect(m *dns.Msg, useTCP bool) (*dns.Msg, error)
- func (p *Proxy) Down(maxfails uint32) bool
- func (p *Proxy) Fails() uint32
- func (p *Proxy) GetHealthchecker() HealthChecker
- func (p *Proxy) Healthcheck()
- func (p *Proxy) SetExpire(expire time.Duration)
- func (p *Proxy) SetReadTimeout(duration time.Duration)
- func (p *Proxy) SetTLSConfig(cfg *tls.Config)
- func (p *Proxy) Start(duration time.Duration)
- func (p *Proxy) Stop()
- type Transport
Constants ¶
const AdvertiseUDPSize = 1232
AdvertiseUDPSize is the maximum message size that we advertise in the OPT RR of UDP messages. This is calculated as the minimum IPv6 MTU (1280) minus size of IPv6 (40) and UDP (8) headers.
Variables ¶
var ErrCachedClosed = errors.New("cached connection was closed by peer")
ErrCachedClosed means cached connection was closed by peer.
Functions ¶
This section is empty.
Types ¶
type HealthChecker ¶
type HealthChecker interface { Check(*Proxy) error SetTLSConfig(*tls.Config) GetTLSConfig() *tls.Config SetRecursionDesired(bool) GetRecursionDesired() bool SetDomain(domain string) GetDomain() string SetTCPTransport() GetReadTimeout() time.Duration SetReadTimeout(time.Duration) GetWriteTimeout() time.Duration SetWriteTimeout(time.Duration) }
HealthChecker checks the upstream health.
func NewHealthChecker ¶
func NewHealthChecker(recursionDesired bool, domain string) HealthChecker
NewHealthChecker returns a new HealthChecker.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy defines an upstream host.
func (*Proxy) GetHealthchecker ¶
func (p *Proxy) GetHealthchecker() HealthChecker
func (*Proxy) Healthcheck ¶
func (p *Proxy) Healthcheck()
Healthcheck kicks of a round of health checks for this proxy.
func (*Proxy) SetReadTimeout ¶
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.