dns

package
v0.3.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 21 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
)

Functions

func DNSServer

func DNSServer()

func DOHJsonAPI

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

func GetReq

func GetReq(req []byte) (resp respHeader, err error)

func NewClient

func NewClient(subnet *net.IPNet, send func([]byte) ([]byte, error)) *client

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 DNS

type DNS interface {
	LookupIP(domain string) ([]net.IP, error)
	Resolver() *net.Resolver
}

func NewDNS

func NewDNS(host string, subnet *net.IPNet, p proxy.PacketProxy) DNS

func NewDoH

func NewDoH(host string, subnet *net.IPNet, p proxy.StreamProxy) DNS

func NewDoT

func NewDoT(host string, subnet *net.IPNet, p proxy.StreamProxy) DNS

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 Question

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

Directories

Path Synopsis
Package mock_dns is a generated GoMock package.
Package mock_dns is a generated GoMock package.

Jump to

Keyboard shortcuts

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