ipcache

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ipcache provides a time-based cache object to keep track of recently-seen IP addresses.

Index

Constants

This section is empty.

Variables

View Source
var (
	// IPCacheTimeout sets a lower bound on the amount of time between subsequent traceroutes to a single IP address.
	IPCacheTimeout = flag.Duration("IPCacheTimeout", 120*time.Second, "Timeout duration in seconds for IPCache")

	// IPCacheUpdatePeriod determines how long to wait between cache-scrubbing attempts.
	IPCacheUpdatePeriod = flag.Duration("IPCacheUpdatePeriod", 1*time.Second, "We run the cache eviction loop with this frequency")
)

Functions

This section is empty.

Types

type RecentIPCache

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

RecentIPCache contains a list of all the IP addresses that we have traced to recently. We keep this list to ensure that we don't traceroute to the same location repeatedly at a high frequency.

func New

func New(ctx context.Context, tracer Tracer, ipCacheTimeout, ipCacheUpdatePeriod time.Duration) *RecentIPCache

New creates and returns a RecentIPCache. It also starts up a background goroutine that scrubs the cache.

func (*RecentIPCache) GetCacheLength added in v0.2.1

func (rc *RecentIPCache) GetCacheLength() int

GetCacheLength returns the number of items currently in the cache. The primary use of this is for testing, to ensure that something was put into or removed from the cache.

func (*RecentIPCache) Trace added in v0.2.1

func (rc *RecentIPCache) Trace(conn connection.Connection) string

Trace performs a trace and adds it to the cache. It calls the methods of the tracer, so if those create files on disk, then files on disk will be created as a side effect.

type Tracer added in v0.3.2

type Tracer interface {
	Trace(conn connection.Connection, t time.Time) string
	CreateCacheTest(conn connection.Connection, t time.Time, cachedTest string)
}

Tracer is the generic interface for all things that can perform a traceroute.

Jump to

Keyboard shortcuts

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