dns

package
v0.3.1-rc.7 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrCondEmptyResponse = errors.New("can't get response from cond")
View Source
var ErrNoIPFound = errors.New("no ip found")
View Source
var TlsProtos = []string{"doq-i02"}
View Source
var TlsProtosCompat = []string{"doq-i02", "doq-i01", "doq-i00", "doq", "dq"}

TlsProtosCompat stores alternative TLS protocols for experimental interoperability

Functions

func DOHJsonAPI

func DOHJsonAPI(DNSServer, domain string, proxy func(ctx context.Context, network, addr string) (net.Conn, error)) (DNS []net.IP, err error)

func New

func New(config Config) (dns.DNS, error)
Example
subnet, err := netip.ParsePrefix("1.1.1.1/24")
if err != nil {
	panic(err)
}

New(Config{
	Type:       dns.Type_doh,
	Name:       "cloudflare",
	Host:       "cloudflare-dns.com",
	Servername: "cloudflare-dns.com",
	IPv6:       true,
	Subnet:     subnet,
})
Output:

func NewClient

func NewClient(config Config, send func(context.Context, []byte) ([]byte, error)) *client

func NewDnsServer

func NewDnsServer(server string, process dns.DNS) server.DNSServer

func NewDoH

func NewDoH(config Config) (dns.DNS, error)

func NewDoH3

func NewDoH3(config Config) (dns.DNS, error)

func NewDoQ

func NewDoQ(config Config) (dns.DNS, error)

func NewDoT

func NewDoT(config Config) (dns.DNS, error)

func NewDoU

func NewDoU(config Config) (dns.DNS, error)

func NewTCP

func NewTCP(config Config) (dns.DNS, error)

func ParseAddr

func ParseAddr(netType statistic.Type, host, defaultPort string) (proxy.Address, error)

ParseAddr host eg: cloudflare-dns.com, https://cloudflare-dns.com, 1.1.1.1:853

func Register

func Register(tYPE pd.Type, f func(Config) (dns.DNS, error))

func RetrieveIPFromPtr

func RetrieveIPFromPtr(name string) (net.IP, error)

Types

type Answer

type Answer struct {
	Name    string `json:"name"`
	Type    int    `json:"type"`
	TTL     int    `json:"TTL"`
	Expires string `json:"Expires"`
	Data    string `json:"data"`
}

type Config

type Config struct {
	Type       pd.Type
	IPv6       bool
	Subnet     netip.Prefix
	Name       string
	Host       string
	Servername string
	Dialer     proxy.Proxy
}

type DOHJson

type DOHJson struct {
	Status           int        `json:"status"`
	TC               bool       `json:"TC"`
	RD               bool       `json:"RD"`
	RA               bool       `json:"RA"`
	AD               bool       `json:"AD"`
	CD               bool       `json:"CD"`
	Question         []Question `json:"Question"`
	Answer           []Answer   `json:"Answer"`
	EdnsClientSubnet string     `json:"edns_client_subnet"`
}

type FakeDNS

type FakeDNS struct {
	dns.DNS
	*FakeIPPool
}

func NewFakeDNS

func NewFakeDNS(upStreamDo dns.DNS, ipRange netip.Prefix, bbolt *cache.Cache) *FakeDNS

func (*FakeDNS) Close

func (f *FakeDNS) Close() error

func (*FakeDNS) LookupIP

func (f *FakeDNS) LookupIP(_ context.Context, domain string) ([]net.IP, error)

func (*FakeDNS) LookupPtr

func (f *FakeDNS) LookupPtr(name string) (string, error)

func (*FakeDNS) Record

func (f *FakeDNS) Record(_ context.Context, domain string, t dnsmessage.Type) (dns.IPRecord, error)

type FakeIPPool

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

func NewFakeIPPool

func NewFakeIPPool(prefix netip.Prefix, bbolt *cache.Cache) *FakeIPPool

func (*FakeIPPool) GetDomainFromIP

func (n *FakeIPPool) GetDomainFromIP(ip string) (string, bool)

func (*FakeIPPool) GetFakeIPForDomain

func (n *FakeIPPool) GetFakeIPForDomain(s string) string

func (*FakeIPPool) LRU

func (n *FakeIPPool) LRU() *lru.LRU[string, string]

type Question

type Question struct {
	Name string `json:"name"`
	Type int    `json:"type"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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