upstream

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: Apache-2.0 Imports: 18 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TLSPool

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

TLSPool is a connections pool for the DNS-over-TLS Upstream.

Example:

pool := TLSPool{Address: "tls://1.1.1.1:853"}
netConn, err := pool.Get()
if err != nil {panic(err)}
c := dns.Conn{Conn: netConn}
q := dns.Msg{}
q.SetQuestion("google.com.", dns.TypeA)
log.Println(q)
err = c.WriteMsg(&q)
if err != nil {panic(err)}
r, err := c.ReadMsg()
if err != nil {panic(err)}
log.Println(r)
pool.Put(c.Conn)

func (*TLSPool) Create added in v0.9.10

func (n *TLSPool) Create() (net.Conn, error)

Create creates a new connection for the pool (but not puts it there)

func (*TLSPool) Get

func (n *TLSPool) Get() (net.Conn, error)

Get gets or creates a new TLS connection

func (*TLSPool) Put

func (n *TLSPool) Put(c net.Conn)

Put returns connection to the pool

type Upstream

type Upstream interface {
	Exchange(m *dns.Msg) (*dns.Msg, error)
	Address() string
}

Upstream is an interface for a DNS resolver

func AddressToUpstream

func AddressToUpstream(address string, bootstrap string, timeout time.Duration) (Upstream, error)

AddressToUpstream converts the specified address to an Upstream instance * 8.8.8.8:53 -- plain DNS * tcp://8.8.8.8:53 -- plain DNS over TCP * tls://1.1.1.1 -- DNS-over-TLS * https://dns.adguard.com/dns-query -- DNS-over-HTTPS * sdns://... -- DNS stamp (see https://dnscrypt.info/stamps-specifications) bootstrap is a plain DNS which is used to resolve DoH/DoT hostnames (if any) timeout is a default upstream timeout. Also, it is used as a timeout for bootstrap DNS requests. timeout=0 means infinite timeout

Jump to

Keyboard shortcuts

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