ipcache

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 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.
	// Traceroutes typically take 5 to 10 minutes.
	IPCacheTimeout = flag.Duration("IPCacheTimeout", 10*time.Minute, "Timeout duration in seconds for IPCache")

	// IPCacheUpdatePeriod determines how long to wait between
	// cache-scrubbing attempts.
	IPCacheUpdatePeriod = flag.Duration("IPCacheUpdatePeriod", 1*time.Minute, "We run the IP 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, trace 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) ([]byte, error)

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.

func (*RecentIPCache) UpdateTracer added in v0.4.1

func (rc *RecentIPCache) UpdateTracer(t Tracer)

UpdateTracer switches the Tracer being used.

type Tracer added in v0.3.2

type Tracer interface {
	Trace(conn connection.Connection, t time.Time) ([]byte, error)
	TraceFromCachedTrace(conn connection.Connection, t time.Time, cachedTest []byte) error
	DontTrace(conn connection.Connection, err error)
}

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