resolvcache

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package resolvcache implements a dnsutil.ResolvCache service interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache implements a resolv cache in memory.

func NewCache

func NewCache(expires time.Duration, limits Limits) *Cache

NewCache creates a new Cache.

func (*Cache) Clean

func (o *Cache) Clean()

Clean expired items from cache.

func (*Cache) Cleaned

func (o *Cache) Cleaned() time.Time

Cleaned returns time from last clean.

func (*Cache) Dump

func (o *Cache) Dump(out io.Writer)

Dump cache content to writer.

func (*Cache) Expires

func (o *Cache) Expires() time.Duration

Expires returns expiration time.

func (*Cache) Flush

func (o *Cache) Flush()

Flush cache.

func (*Cache) Flushed

func (o *Cache) Flushed() time.Time

Flushed returns time from last flush.

func (*Cache) Get

func (o *Cache) Get(client, resolved net.IP, name string) (bool, time.Time)

Get data.

func (*Cache) Set

func (o *Cache) Set(ts time.Time, client net.IP, name string, resolved []net.IP) error

Set data.

func (*Cache) Store

func (o *Cache) Store() time.Time

Store returns store time.

type Limits

type Limits struct {
	BlockSize       int
	MaxBlocksClient int
	MaxNamesNode    int
}

Limits stores max values for cache.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns limits.

type Option

type Option func(*options)

Option is used for component configuration.

func DumpCache

func DumpCache(d time.Duration, fname string) Option

DumpCache option sets interval and filename for dump.

func SetLogger

func SetLogger(l yalogi.Logger) Option

SetLogger option allows set a custom logger.

func SetTraceLogger

func SetTraceLogger(l TraceLogger) Option

SetTraceLogger option sets a collection and query logger.

type Service

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

Service implements a dnsutil.ResolvCache service

func NewService

func NewService(c *Cache, opt ...Option) *Service

NewService creates a new Service.

func (*Service) Check

func (s *Service) Check(ctx context.Context, client, resolved net.IP, name string) (dnsutil.CacheResponse, error)

Check implements dnsutil.ResolvChecker.

func (*Service) Collect

func (s *Service) Collect(ctx context.Context, client net.IP, name string, resolved []net.IP, cnames []string) error

Collect implements dnsutil.ResolvCollector.

func (*Service) Shutdown

func (s *Service) Shutdown()

Shutdown service cache.

func (*Service) Start

func (s *Service) Start() error

Start service cache.

func (*Service) Uptime

func (s *Service) Uptime(ctx context.Context) (time.Time, time.Duration, error)

Uptime returns cache information.

type TraceLogger

type TraceLogger interface {
	LogCollect(*peer.Peer, time.Time, net.IP, string, []net.IP, []string) error
	LogCheck(peer *peer.Peer, ts time.Time, client, resolved net.IP, name string, resp dnsutil.CacheResponse) error
}

TraceLogger interface defines collection and query logger interface.

Directories

Path Synopsis
Package tracelog implements an asyncronous resolvcache.TraceLogger.
Package tracelog implements an asyncronous resolvcache.TraceLogger.

Jump to

Keyboard shortcuts

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