dns

package
v0.33.20-find-inconsis... Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: AGPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultTimeToLive is the default duration a dns result is cached.
	DefaultTimeToLive = 5 * time.Minute
	DefaultCacheSize  = 10e3
)

DefaultTimeToLive is the default duration a dns result is cached.

Variables

This section is empty.

Functions

func WithBasicResolver

func WithBasicResolver(basic madns.BasicResolver) optFunc

WithBasicResolver is an option function for setting the basic resolver of this Resolver.

func WithTTL

func WithTTL(ttl time.Duration) optFunc

WithTTL is an option function for setting the time to live for cache entries.

Types

type Resolver

type Resolver struct {
	component.Component
	// contains filtered or unexported fields
}

Resolver is a cache-based dns resolver for libp2p. DNS cache implementation notes:

  1. Generic / possibly expected functionality NOT implemented: - Caches domains for TTL seconds as given by upstream DNS resolver, e.g. [1]. - Possibly pre-expire cached domains so no connection time resolve delay.
  2. Actual / pragmatic functionality implemented below: - Caches domains for global (not individual domain record TTL) TTL seconds. - Cached IP is returned even if cached entry expired; so no connection time resolve delay. - Detecting expired cached domain triggers async DNS lookup to refresh cached entry.

[1] https://en.wikipedia.org/wiki/Name_server#Caching_name_server

func NewResolver

func NewResolver(logger zerolog.Logger, collector module.ResolverMetrics, dnsCache mempool.DNSCache, opts ...optFunc) *Resolver

NewResolver is the factory function for creating an instance of this resolver.

func (*Resolver) LookupIPAddr

func (r *Resolver) LookupIPAddr(ctx context.Context, domain string) ([]net.IPAddr, error)

LookupIPAddr implements BasicResolver interface for libp2p for looking up ip addresses through resolver.

func (*Resolver) LookupTXT

func (r *Resolver) LookupTXT(ctx context.Context, txt string) ([]string, error)

LookupTXT implements BasicResolver interface for libp2p. If txt exists on cache it is resolved through the cache. An expired txt on cache is still addressed through the cache, however, a request is fired up asynchronously through the underlying basic resolver to resolve it from the network.

Jump to

Keyboard shortcuts

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