Help us shape the future of Go! Take the 2026 Go Developer Survey

dns

package
v1.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: GPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRawSupport           = E.New("no raw query support by current transport")
	ErrNotCached              = E.New("not cached")
	ErrResponseRejected       = E.New("response rejected")
	ErrResponseRejectedCached = E.Extend(ErrResponseRejected, "cached")
)

Functions

func FixedResponse

func FixedResponse(id uint16, question dns.Question, addresses []netip.Addr, timeToLive uint32) *dns.Msg

func FixedResponseCNAME

func FixedResponseCNAME(id uint16, question dns.Question, record string, timeToLive uint32) *dns.Msg

func FixedResponseMX

func FixedResponseMX(id uint16, question dns.Question, records []*net.MX, timeToLive uint32) *dns.Msg

func FixedResponseStatus

func FixedResponseStatus(message *dns.Msg, rcode int) *dns.Msg

func FixedResponseTXT

func FixedResponseTXT(id uint16, question dns.Question, records []string, timeToLive uint32) *dns.Msg

func FormatQuestion

func FormatQuestion(string string) string

func FqdnToDomain

func FqdnToDomain(fqdn string) string

func MessageToAddresses

func MessageToAddresses(response *dns.Msg) []netip.Addr

func NewLocalDialer

func NewLocalDialer(ctx context.Context, options option.LocalDNSServerOptions) (N.Dialer, error)

func NewRemoteDialer

func NewRemoteDialer(ctx context.Context, options option.RemoteDNSServerOptions) (N.Dialer, error)

func RegisterTransport

func RegisterTransport[Options any](registry *TransportRegistry, transportType string, constructor TransportConstructorFunc[Options])

func SetClientSubnet

func SetClientSubnet(message *dns.Msg, clientSubnet netip.Prefix) *dns.Msg

func TruncateDNSMessage

func TruncateDNSMessage(request *dns.Msg, response *dns.Msg, headroom int) (*buf.Buffer, error)

Types

type Client

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

func NewClient

func NewClient(options ClientOptions) *Client

func (*Client) ClearCache

func (c *Client) ClearCache()

func (*Client) Exchange

func (c *Client) Exchange(ctx context.Context, transport adapter.DNSTransport, message *dns.Msg, options adapter.DNSQueryOptions, responseChecker func(responseAddrs []netip.Addr) bool) (*dns.Msg, error)

func (*Client) ExchangeCache

func (c *Client) ExchangeCache(ctx context.Context, message *dns.Msg) (*dns.Msg, bool)

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, transport adapter.DNSTransport, domain string, options adapter.DNSQueryOptions, responseChecker func(responseAddrs []netip.Addr) bool) ([]netip.Addr, error)

func (*Client) LookupCache

func (c *Client) LookupCache(domain string, strategy C.DomainStrategy) ([]netip.Addr, bool)

func (*Client) Start

func (c *Client) Start()

type ClientOptions

type ClientOptions struct {
	Timeout          time.Duration
	DisableCache     bool
	DisableExpire    bool
	IndependentCache bool
	CacheCapacity    uint32
	ClientSubnet     netip.Prefix
	RDRC             func() adapter.RDRCStore
	Logger           logger.ContextLogger
}

type RcodeError

type RcodeError int
const (
	RcodeFormatError RcodeError = mDNS.RcodeFormatError
	RcodeNameError   RcodeError = mDNS.RcodeNameError
	RcodeRefused     RcodeError = mDNS.RcodeRefused
)

func (RcodeError) Error

func (e RcodeError) Error() string

type Router

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

func NewRouter

func NewRouter(ctx context.Context, logFactory log.Factory, options option.DNSOptions) *Router

func (*Router) ClearCache

func (r *Router) ClearCache()

func (*Router) Close

func (r *Router) Close() error

func (*Router) Exchange

func (r *Router) Exchange(ctx context.Context, message *mDNS.Msg, options adapter.DNSQueryOptions) (*mDNS.Msg, error)

func (*Router) Initialize

func (r *Router) Initialize(rules []option.DNSRule) error

func (*Router) Lookup

func (r *Router) Lookup(ctx context.Context, domain string, options adapter.DNSQueryOptions) ([]netip.Addr, error)

func (*Router) LookupReverseMapping

func (r *Router) LookupReverseMapping(ip netip.Addr) (string, bool)

func (*Router) ResetNetwork

func (r *Router) ResetNetwork()

func (*Router) Start

func (r *Router) Start(stage adapter.StartStage) error

type TransportAdapter

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

func NewTransportAdapter

func NewTransportAdapter(transportType string, transportTag string, dependencies []string) TransportAdapter

func NewTransportAdapterWithLocalOptions

func NewTransportAdapterWithLocalOptions(transportType string, transportTag string, localOptions option.LocalDNSServerOptions) TransportAdapter

func NewTransportAdapterWithRemoteOptions

func NewTransportAdapterWithRemoteOptions(transportType string, transportTag string, remoteOptions option.RemoteDNSServerOptions) TransportAdapter

func (*TransportAdapter) Dependencies

func (a *TransportAdapter) Dependencies() []string

func (*TransportAdapter) LegacyClientSubnet

func (a *TransportAdapter) LegacyClientSubnet() netip.Prefix

func (*TransportAdapter) LegacyStrategy

func (a *TransportAdapter) LegacyStrategy() C.DomainStrategy

func (*TransportAdapter) Tag

func (a *TransportAdapter) Tag() string

func (*TransportAdapter) Type

func (a *TransportAdapter) Type() string

type TransportConstructorFunc

type TransportConstructorFunc[T any] func(ctx context.Context, logger log.ContextLogger, tag string, options T) (adapter.DNSTransport, error)

type TransportManager

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

func NewTransportManager

func NewTransportManager(logger logger.ContextLogger, registry adapter.DNSTransportRegistry, outbound adapter.OutboundManager, defaultTag string) *TransportManager

func (*TransportManager) Close

func (m *TransportManager) Close() error

func (*TransportManager) Create

func (m *TransportManager) Create(ctx context.Context, logger log.ContextLogger, tag string, transportType string, options any) error

func (*TransportManager) Default

func (m *TransportManager) Default() adapter.DNSTransport

func (*TransportManager) FakeIP

func (*TransportManager) Initialize

func (m *TransportManager) Initialize(defaultTransportFallback adapter.DNSTransport)

func (*TransportManager) Remove

func (m *TransportManager) Remove(tag string) error

func (*TransportManager) Start

func (m *TransportManager) Start(stage adapter.StartStage) error

func (*TransportManager) Transport

func (m *TransportManager) Transport(tag string) (adapter.DNSTransport, bool)

func (*TransportManager) Transports

func (m *TransportManager) Transports() []adapter.DNSTransport

type TransportRegistry

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

func NewTransportRegistry

func NewTransportRegistry() *TransportRegistry

func (*TransportRegistry) CreateDNSTransport

func (r *TransportRegistry) CreateDNSTransport(ctx context.Context, logger log.ContextLogger, tag string, transportType string, options any) (adapter.DNSTransport, error)

func (*TransportRegistry) CreateOptions

func (r *TransportRegistry) CreateOptions(transportType string) (any, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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