Documentation ¶
Index ¶
Constants ¶
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.
Types ¶
type Resolver ¶
Resolver is a cache-based dns resolver for libp2p. - DNS cache implementation notes:
- 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.
- 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 ¶
LookupIPAddr implements BasicResolver interface for libp2p for looking up ip addresses through resolver.
func (*Resolver) LookupTXT ¶
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.