xdns

package
v0.0.0-...-d92f398 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientMagicLen = 8
)

Variables

View Source
var (
	CertMagic               = [4]byte{0x44, 0x4e, 0x53, 0x43}
	ServerMagic             = [8]byte{0x72, 0x36, 0x66, 0x6e, 0x76, 0x57, 0x6a, 0x38}
	MinDNSPacketSize        = 12 + 5
	MaxDNSPacketSize        = 4096
	MaxDNSUDPPacketSize     = 4096
	MaxDNSUDPSafePacketSize = 1252
	BlockTTL                = uint32(5)
	AnsTTL                  = uint32(300)
	MaxMTU                  = 0xffff // 65k, ought to be enough for everybody
)
View Source
var (
	MDNSAddr4 = &net.UDPAddr{
		IP:   net.ParseIP(mdnsip4),
		Port: mdnsPort,
	}
	MDNSAddr6 = &net.UDPAddr{
		IP:   net.ParseIP(mdnsip6),
		Port: mdnsPort,
	}
)

Functions

func AAAAAnswer

func AAAAAnswer(msg *dns.Msg) []*netip.Addr

func AAnswer

func AAnswer(msg *dns.Msg) []*netip.Addr

func AName

func AName(ans dns.RR) (string, error)

func AQuadAForQuery

func AQuadAForQuery(q *dns.Msg, ips ...netip.Addr) (a *dns.Msg, err error)

func AQuadAUnspecified

func AQuadAUnspecified(msg *dns.Msg) bool

func AddEDNS0PaddingIfNoneFound

func AddEDNS0PaddingIfNoneFound(msg *dns.Msg, unpaddedPacket []byte, paddingLen int) ([]byte, error)

func Ans

func Ans(msg *dns.Msg) (s string)

func AsMsg

func AsMsg(packet []byte) *dns.Msg

func AsMsg2

func AsMsg2(packet []byte) (*dns.Msg, error)

func BlockResponseFromMessage

func BlockResponseFromMessage(q []byte) (*dns.Msg, error)

func DnsIPPort

func DnsIPPort(s string) (ipp netip.AddrPort, err error)

func EmptyResponseFromMessage

func EmptyResponseFromMessage(srcMsg *dns.Msg) *dns.Msg

func ExtractMDNSDomain

func ExtractMDNSDomain(msg *dns.Msg) (svc, tld string)

func FindUnique

func FindUnique(s []string, n []string) (u []string)

returns unique strings in n not in s as new array

func GetBlocklistStampFromURL

func GetBlocklistStampFromURL(rawurl string) (string, error)

TODO: Move to dnsx?

func GetBlocklistStampHeaderKey

func GetBlocklistStampHeaderKey() string

GetBlocklistStampHeaderKey returns the http-header key for blocklists stamp

func GetInterestingRData

func GetInterestingRData(msg *dns.Msg) string

func HasAAAAAnswer

func HasAAAAAnswer(msg *dns.Msg) bool

func HasAAAAQuestion

func HasAAAAQuestion(msg *dns.Msg) bool

whether the given msg (ans/query) has a AAAA question section

func HasAAnswer

func HasAAnswer(msg *dns.Msg) bool

func HasAQuadAQuestion

func HasAQuadAQuestion(msg *dns.Msg) bool

whether the given msg (ans/query) has a a/aaaa question section

func HasAQuestion

func HasAQuestion(msg *dns.Msg) bool

whether the given msg (ans/query) has a A question section

func HasAnyAnswer

func HasAnyAnswer(msg *dns.Msg) bool

func HasAnyQuestion

func HasAnyQuestion(msg *dns.Msg) bool

func HasHTTPQuestion

func HasHTTPQuestion(msg *dns.Msg) (ok bool)

whether the given msg (ans/query) has a https question section

func HasRcodeSuccess

func HasRcodeSuccess(msg *dns.Msg) bool

func HasSVCBQuestion

func HasSVCBQuestion(msg *dns.Msg) (ok bool)

whether the given msg (ans/query) has a svcb question section

func HasTCFlag

func HasTCFlag(msg *dns.Msg) bool

func HasTCFlag2

func HasTCFlag2(packet []byte) bool

func IPHints

func IPHints(msg *dns.Msg, x dns.SVCBKey) []*netip.Addr

func IsAAAAQType

func IsAAAAQType(qtype uint16) bool

whether the qtype code is a aaaa qtype

func IsAQType

func IsAQType(qtype uint16) bool

whether the qtype code is a A qtype

func IsHTTPQuestion

func IsHTTPQuestion(q *dns.Question) bool

whether question q is a https question

func IsHTTPSQType

func IsHTTPSQType(qtype uint16) bool

whether the qtype code is a https qtype

func IsMDNSQuery

func IsMDNSQuery(qname string) bool

func IsNXDomain

func IsNXDomain(msg *dns.Msg) bool

func IsSVCBQType

func IsSVCBQType(qtype uint16) bool

whether the qtype code is a svcb qtype

func IsSVCBQuestion

func IsSVCBQuestion(q *dns.Question) bool

whether question q is a svcb question

func IsServFailOrInvalid

func IsServFailOrInvalid(msg *dns.Msg) bool

func Len

func Len(msg *dns.Msg) int

func MakeAAAARecord

func MakeAAAARecord(name string, ip6 string, expiry int) dns.RR

func MakeARecord

func MakeARecord(name string, ip4 string, expiry int) dns.RR

func Max

func Max(a, b int) int

func MaybeToQuadA

func MaybeToQuadA(answer dns.RR, prefix *net.IPNet, minttl uint32) dns.RR

func Min

func Min(a, b int) int

func Net2ProxyID

func Net2ProxyID(network string) (proto, pid string)

Net2ProxyID splits network string into proto and pid; proto is the network protocol and pid is the proxy ID. May return empty strings.

func NetAndProxyID

func NetAndProxyID(proto, pid string) string

NetAndProxyID joins proto and pid into a network string. proto is the network protocol and pid is the proxy ID. May return just the separator ":", if both proto, pid are empty.

func NormalizeQName

func NormalizeQName(str string) (string, error)

func PrefixWithSize

func PrefixWithSize(packet []byte) ([]byte, error)

func QName

func QName(msg *dns.Msg) string

func QType

func QType(msg *dns.Msg) uint16

func RTtl

func RTtl(msg *dns.Msg) int

func Rcode

func Rcode(msg *dns.Msg) int

func ReadPrefixed

func ReadPrefixed(conn *net.Conn) ([]byte, error)

TODO: merge this with doh.Accept

func RefusedResponseFromMessage

func RefusedResponseFromMessage(srcMsg *dns.Msg) (dstMsg *dns.Msg, err error)

func RemoveEDNS0Options

func RemoveEDNS0Options(msg *dns.Msg) bool

func RemoveOverlap

func RemoveOverlap(s []string, r []string) []string

remove removes elements at indices r from a ascii string slice s and returns a slice

func Request4FromRequest6

func Request4FromRequest6(msg6 *dns.Msg) *dns.Msg

func Request4FromResponse6

func Request4FromResponse6(msg6 *dns.Msg) *dns.Msg

func RequestFromResponse

func RequestFromResponse(msg *dns.Msg) *dns.Msg

func Servfail

func Servfail(q *dns.Msg) *dns.Msg

Servfail returns a SERVFAIL response to the query q.

func StringReverse

func StringReverse(s string) string

func SubstAAAARecords

func SubstAAAARecords(out *dns.Msg, subip6s []*netip.Addr, ttl int) bool

func SubstARecords

func SubstARecords(out *dns.Msg, subip4s []*netip.Addr, ttl int) bool

func SubstSVCBRecordIPs

func SubstSVCBRecordIPs(out *dns.Msg, x dns.SVCBKey, subiphints []*netip.Addr, ttl int) bool

func Targets

func Targets(msg *dns.Msg) (targets []string)

func ToIp6Hint

func ToIp6Hint(answer dns.RR, prefix *net.IPNet) dns.RR

func TruncatedResponse

func TruncatedResponse(packet []byte) ([]byte, error)

func WithTtl

func WithTtl(msg *dns.Msg, secs uint32) (ok bool)

Types

type CryptoConstruction

type CryptoConstruction uint16
const (
	UndefinedConstruction CryptoConstruction = iota
	XSalsa20Poly1305
	XChacha20Poly1305
)

Jump to

Keyboard shortcuts

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