dns

package
v0.3.1-rc.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Reserved         = EDNSOPT{0b00000000, 0b00000000} //0
	LLQ              = EDNSOPT{0b00000000, 0b00000001} //1 Optional
	UL               = EDNSOPT{0b00000000, 0b00000010} //2 On-hold
	NSID             = EDNSOPT{0b00000000, 0b00000011} //3 Standard
	Reserved2        = EDNSOPT{0b00000000, 0b00000100} //4
	DAU              = EDNSOPT{0b00000000, 0b00000101} //5 Standard
	DHU              = EDNSOPT{0b00000000, 0b00000110} //6 Standard
	N3U              = EDNSOPT{0b00000000, 0b00000111} //7 Standard
	EdnsClientSubnet = EDNSOPT{0b00000000, 0b00001000} //8 Optional
	EDNSEXPIRE       = EDNSOPT{0b00000000, 0b00001001} //9 Optional
	COOKIE           = EDNSOPT{0b00000000, 0b00001010} //10 Standard
	TcpKeepalive     = EDNSOPT{0b00000000, 0b00001011} //11 Standard
	Padding          = EDNSOPT{0b00000000, 0b00001100} //12 Standard
	CHAIN            = EDNSOPT{0b00000000, 0b00001101} //13 Standard
	KEYTAG           = EDNSOPT{0b00000000, 0b00001110} //14 Optional
	ExtendedDNSError = EDNSOPT{0b00000000, 0b00001111} //15 Standard
	EDNSClientTag    = EDNSOPT{0b00000000, 0b00010000} //16 Optional
	EDNSServerTag    = EDNSOPT{0b00000000, 0b00010001} //17 Optional

)

https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-11

View Source
var (
	A     = reqType{0b00000000, 0b00000001} // 1
	NS    = reqType{0b00000000, 0b00000010} // 2
	MD    = reqType{0b00000000, 0b00000011} // 3
	MF    = reqType{0b00000000, 0b00000100} // 3
	CNAME = reqType{0b00000000, 0b00000101} // 5
	SOA   = reqType{0b00000000, 0b00000110} // 6
	MB    = reqType{0b00000000, 0b00000111} // 7
	MG    = reqType{0b00000000, 0b00001000} // 8
	MR    = reqType{0b00000000, 0b00001001} // 9
	NULL  = reqType{0b00000000, 0b00001010} // 10
	WKS   = reqType{0b00000000, 0b00001011} // 11
	PTR   = reqType{0b00000000, 0b00001100} // 12
	HINFO = reqType{0b00000000, 0b00001101} // 13
	MINFO = reqType{0b00000000, 0b00001110} // 14
	MX    = reqType{0b00000000, 0b00001111} // 15
	TXT   = reqType{0b00000000, 0b00010000} // 16
	AAAA  = reqType{0b00000000, 0b00011100} // 28 https://www.ietf.org/rfc/rfc3596.txt
	RRSIG = reqType{0b00000000, 0b00101110} // 46 dnssec

	// only for req
	AXFR = reqType{0b00000000, 0b11111100} // 252
	ANY  = reqType{0b00000000, 0b11111111} // 255
)
View Source
var ErrNoIPFound = errors.New("no ip fond")
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

func NewClient

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

func NewDnsServer

func NewDnsServer(server string, process proxy.ResolverProxy) server.DNSServer

func NewDoH

func NewDoH(config Config) dns.DNS

func NewDoH3

func NewDoH3(config Config) dns.DNS

func NewDoQ

func NewDoQ(config Config) dns.DNS

func NewDoT

func NewDoT(config Config) dns.DNS

func NewDoU

func NewDoU(config Config) dns.DNS

func NewTCP

func NewTCP(config Config) dns.DNS

func Register

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

func Resolve

func Resolve(req, answer []byte) (resp []net.IP, err 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       pdns.Type
	Name       string
	Host       string
	Servername string
	Subnet     *net.IPNet
	IPv6       bool

	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 EDNSOPT

type EDNSOPT [2]byte

type Fake

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

func NewFake

func NewFake(ipRange *net.IPNet) *Fake

func (*Fake) GetDomainFromIP

func (fkdns *Fake) GetDomainFromIP(ip string) (string, bool)

func (*Fake) GetFakeIPForDomain

func (fkdns *Fake) GetFakeIPForDomain(domain string) string

GetFakeIPForDomain checks and generates a fake IP for a domain name

type FakeDNS

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

func WrapFakeDNS

func WrapFakeDNS(upStreamDo func(b []byte) ([]byte, error), pool *Fake) *FakeDNS

func (*FakeDNS) Close

func (f *FakeDNS) Close() error

func (*FakeDNS) Do

func (f *FakeDNS) Do(b []byte) ([]byte, error)

func (*FakeDNS) LookupIP

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

func (*FakeDNS) LookupPtr

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

func (*FakeDNS) Record

func (f *FakeDNS) Record(domain string, t dnsmessage.Type) (dns.IPResponse, error)

type Question

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

Jump to

Keyboard shortcuts

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