ipcache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 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) *RecentIPCache

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

func (*RecentIPCache) Add

func (m *RecentIPCache) Add(ip string)

Add an IP to the cache.

func (*RecentIPCache) Has

func (m *RecentIPCache) Has(ip string) bool

Has tests whether an IP is in the cache.

Jump to

Keyboard shortcuts

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