dns

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: AGPL-3.0 Imports: 16 Imported by: 1

Documentation

Overview

Package dns with DoT/DoH supports

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoDNSAvailable is reported when all servers failed to response
	ErrNoDNSAvailable = errors.New("no dns available")
	// ErrSuccess is designed for range hosts to break
	ErrSuccess = errors.New("success")
)
View Source
var DefaultResolver = &net.Resolver{
	PreferGo: true,
	Dial: func(ctx context.Context, _, _ string) (net.Conn, error) {
		if ip.IsIPv6Available {
			return IPv6Servers.DialContext(ctx, nil)
		}
		return IPv4Servers.DialContext(ctx, nil)
	},
}

DefaultResolver ...

View Source
var IPv4Servers = List{
	// contains filtered or unexported fields
}

IPv4Servers is the default server set

View Source
var IPv6Servers = List{
	// contains filtered or unexported fields
}

IPv6Servers should only be used when IPv6 is available

Functions

func DialTLSContext added in v1.0.3

func DialTLSContext(ctx context.Context, network, addr string) (net.Conn, error)

DialTLSContext fills http.Transport method with terasu and DNS

func DialTLSContextWithConfig added in v1.0.3

func DialTLSContextWithConfig(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error)

DialTLSContextWithConfig fills http2.Transport method with terasu and DNS

func LookupHost

func LookupHost(ctx context.Context, host string) (addrs []string, err error)

LookupHost use default resolver with its fallback

Types

type Config added in v1.0.1

type Config struct {
	Servers   map[string][]string `yaml:"Servers"`   // Servers map[dot.com]ip:ports
	Fallbacks map[string][]string `yaml:"Fallbacks"` // Fallbacks map[domain]ips
}

Config is the user config

type List added in v1.0.1

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

List is a bundle of DNSs

func NewEmptyList added in v1.0.2

func NewEmptyList() *List

NewEmptyList ...

func (*List) Add added in v1.0.1

func (ds *List) Add(c *Config)

Add ...

func (*List) DialContext added in v1.0.1

func (ds *List) DialContext(ctx context.Context, d *net.Dialer) (tlsConn *tls.Conn, err error)

DialContext ...

Jump to

Keyboard shortcuts

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