dnsx

package
v0.0.0-...-dd04f72 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Copyright (c) 2022 RethinkDNS and its authors.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Index

Constants

View Source
const (
	Start          = x.Start
	Complete       = x.Complete
	SendFailed     = x.SendFailed
	NoResponse     = x.NoResponse
	BadQuery       = x.BadQuery
	BadResponse    = x.BadResponse
	InternalError  = x.InternalError
	TransportError = x.TransportError
	ClientError    = x.ClientError
)
View Source
const (
	EB32 = backend.EB32
	EB64 = backend.EB64
)

encoding type, base32 or base64

View Source
const (
	// DNS transport types
	DOH      = x.DOH
	DNSCrypt = x.DNSCrypt
	DNS53    = x.DNS53
	DOT      = x.DOT
	ODOH     = x.ODOH

	CT = x.CT

	Goos      = x.Goos
	System    = x.System
	Local     = x.Local
	Default   = x.Default
	Preferred = x.Preferred
	Preset    = x.Preset
	BlockFree = x.BlockFree
	Bootstrap = x.Bootstrap
	BlockAll  = x.BlockAll
	Alg       = x.Alg
	DcProxy   = x.DcProxy
	IpMapper  = x.IpMapper

	// preferred network to use with t.Query
	NetTypeUDP = "udp"
	NetTypeTCP = "tcp"
	// preferred forwarding network, if any
	// ipn.Base is treated as a no-proxy
	NetNoProxy   = "Base"
	NetExitProxy = "Exit" // same as ipn.Exit

	// pseudo transport ID to tag dns64 responses
	AlgDNS64 = "dns64"
)
View Source
const AnyResolver = "__anyresolver"
View Source
const Local464Resolver = "__local464" // preset "forced" DNS64/NAT64
View Source
const OverlayResolver = "__overlay" // "net.DefaultResolver" dnsx.Goos
View Source
const Rfc7050WKN = "ipv4only.arpa."

ref: datatracker.ietf.org/doc/html/rfc8880

View Source
const UnderlayResolver = "__underlay" // used by transport dnsx.System

Variables

View Source
var (
	ErrNotDefaultTransport = errors.New("not a default transport")
	ErrNoDcProxy           = errors.New("no dnscrypt-proxy")
	ErrNoProxyProvider     = errors.New("no proxy provider")
	ErrNoProxyDNS          = errors.New("no proxy dns")
	ErrAddFailed           = errors.New("add failed")
)

Functions

func IsLocalProxy

func IsLocalProxy(pid string) bool

func NewDNSGateway

func NewDNSGateway(outer RdnsResolver, dns64 NatPt) (t *dnsgateway)

NewDNSGateway returns a DNS ALG, ready for use.

func PrefixFor

func PrefixFor(id string) string

func Req

func Req(t Transport, network string, q []byte, smm *x.DNSSummary) ([]byte, error)

Req sends q to transport t and returns the answer, if any; errors are unset if answer is not servfail or empty; smm, the in/out parameter, is dns summary as got from t.

Types

type DNS64

type DNS64 interface {
	// Add64 registers DNS64 resolver f to id.
	Add64(id string, f Transport) bool
	// Remove64 deregisters any current resolver from id.
	Remove64(id string) bool
	// ResetNat64Prefix sets the NAT64 prefix for transport id to ip6prefix.
	ResetNat64Prefix(ip6prefix string) bool
	// D64 synthesizes ans64 (AAAA) from ans6 if required, using resolver f.
	// Returned ans64 is nil if no DNS64 synthesis is needed (not AAAA).
	// Returned ans64 is ans6 if it already has AAAA records.
	D64(id string, ans6 []byte, f Transport) []byte
}

type Gateway

type Gateway interface {
	// given an alg or real ip, retrieves assoc real ips as csv, if any
	X(algip []byte) (realipcsv string)
	// given an alg or real ip, retrieves assoc dns names as csv, if any
	PTR(algip []byte, force bool) (domaincsv string)
	// given an alg or real ip, retrieve assoc blocklists as csv, if any
	RDNSBL(algip []byte) (blocklistcsv string)
	// contains filtered or unexported methods
}

type NAT64

type NAT64 interface {
	// Returns true if ip is a NAT64 address from transport id.
	IsNat64(id string, ip []byte) bool
	// Translates ip to IPv4 using the NAT64 prefix for transport id.
	// As a special case, ip is zero addr, output is always IPv4 zero addr.
	X64(id string, ip []byte) []byte
}

type NatPt

type NatPt interface {
	DNS64
	NAT64
}

type QueryError

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

func NewBadQueryError

func NewBadQueryError(err error) *QueryError

func NewBadResponseQueryError

func NewBadResponseQueryError(err error) *QueryError

func NewClientQueryError

func NewClientQueryError(err error) *QueryError

with http, for 4xx errors

func NewInternalQueryError

func NewInternalQueryError(err error) *QueryError

func NewNoResponseQueryError

func NewNoResponseQueryError(err error) *QueryError

func NewSendFailedQueryError

func NewSendFailedQueryError(err error) *QueryError

func NewTransportQueryError

func NewTransportQueryError(err error) *QueryError

with http, for 5xx errors

func (*QueryError) Error

func (e *QueryError) Error() string

func (*QueryError) SendFailed

func (e *QueryError) SendFailed() bool

func (*QueryError) Status

func (e *QueryError) Status() int

func (*QueryError) String

func (e *QueryError) String() string

func (*QueryError) Unwrap

func (e *QueryError) Unwrap() error

type RDNS

type RDNS interface {
	x.RDNS
	OnDeviceBlock() bool // Mode
	// contains filtered or unexported methods
}

type RdnsResolver

type RdnsResolver interface {
	x.RDNSResolver
	// contains filtered or unexported methods
}

type Resolver

type Resolver interface {
	x.DNSTransportMult
	RdnsResolver
	NatPt

	// special purpose pre-defined transports
	// Gateway implements a DNS ALG transport
	Gateway() Gateway
	// GetMult returns multi-transport, if available
	GetMult(id string) (TransportMult, error)

	IsDnsAddr(ipport string) bool
	// Lookup performs resolution on Default and/or Goos DNSes
	LocalLookup(q []byte) ([]byte, error)
	// Forward performs resolution on any DNS transport
	Forward(q []byte) ([]byte, error)
	// Serve reads DNS query from conn and writes DNS answer to conn
	Serve(proto string, conn protect.Conn)
}

func NewResolver

func NewResolver(fakeaddrs string, tunmode *settings.TunMode, dtr x.DNSTransport, l x.DNSListener, pt NatPt) Resolver

type Transport

type Transport interface {
	x.DNSTransport
	// Given a DNS query (including ID), returns a DNS response with matching
	// ID, or an error if no response was received.  The error may be accompanied
	// by a SERVFAIL response if appropriate.
	Query(network string, q []byte, summary *x.DNSSummary) ([]byte, error)
}

Transport represents a DNS query transport. This interface is exported by gobind, so it has to be very simple.

func NewCachingTransport

func NewCachingTransport(t Transport, ttl time.Duration) Transport

func NewDefaultCachingTransport

func NewDefaultCachingTransport(t Transport) (ct Transport)

type TransportMult

type TransportMult interface {
	x.DNSTransportMult
	Transport
}

TransportMult is a hybrid: transport and a multi-transport.

Jump to

Keyboard shortcuts

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