Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultTimeToLive is the default duration a dns result is cached. DefaultTimeToLive = 60 * time.Minute )
DefaultTimeToLive is the default duration a dns result is cached.
Variables ¶
This section is empty.
Functions ¶
func NewResolver ¶
func NewResolver(collector module.ResolverMetrics, opts ...optFunc) (*madns.Resolver, error)
NewResolver is the factory function for creating an instance of this resolver.
func WithBasicResolver ¶
func WithBasicResolver(basic madns.BasicResolver) optFunc
WithBasicResolver is an option function for setting the basic resolver of this Resolver.
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
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 (*Resolver) LookupIPAddr ¶
LookupIPAddr implements BasicResolver interface for libp2p for looking up ip addresses through resolver.
Click to show internal directories.
Click to hide internal directories.