Documentation ¶
Index ¶
- Constants
- type BackendCollector
- type BoundedPacketCounter
- func (bc *BoundedPacketCounter[T]) AddOrInsert(key T, c PacketCounts, makeNew func(PacketCounts) *PacketCounts)
- func (bc *BoundedPacketCounter[T]) Get(key T) (*PacketCounts, bool)
- func (bc *BoundedPacketCounter[T]) GetOverflow() optionals.Optional[PacketCounts]
- func (bc *BoundedPacketCounter[T]) HasReachedLimit() bool
- func (bc *BoundedPacketCounter[T]) Len() int
- func (bc *BoundedPacketCounter[T]) RawMap() map[T]*PacketCounts
- func (bc *BoundedPacketCounter[T]) TopN(n int, project func(*PacketCounts) int) (rv map[T]*PacketCounts, overflow optionals.Optional[PacketCounts])
- type Collector
- func New3PTrackerFilterCollector(col Collector) Collector
- func NewBackendCollector(svc akid.ServiceID, lrn akid.LearnSessionID, lc rest.LearnClient, ...) Collector
- func NewDummyCollector() Collector
- func NewHTTPHostAllowlistCollector(matchers []*regexp.Regexp, col Collector) Collector
- func NewHTTPHostFilterCollector(matchers []*regexp.Regexp, col Collector) Collector
- func NewHTTPPathAllowlistCollector(matchers []*regexp.Regexp, col Collector) Collector
- func NewHTTPPathFilterCollector(matchers []*regexp.Regexp, col Collector) Collector
- func NewSamplingCollector(sampleRate float64, collector Collector) Collector
- type HARCollector
- type LearnSessionCollector
- type PacketCountCollector
- type PacketCountConsumer
- type PacketCountDiscard
- type PacketCounter
- func (s *PacketCounter) AllPorts() []PacketCounts
- func (s *PacketCounter) Summary(n int) *PacketCountSummary
- func (s *PacketCounter) Total() PacketCounts
- func (s *PacketCounter) TotalOnHost(host string) PacketCounts
- func (s *PacketCounter) TotalOnInterface(name string) PacketCounts
- func (s *PacketCounter) TotalOnPort(port int) PacketCounts
- func (s *PacketCounter) Update(c PacketCounts)
- type SamplingCollector
- type SharedRateLimit
- type TeeCollector
- type UserTrafficCollector
Constants ¶
const ( // One sample is collected per epoch RateLimitEpochTime = "rate-limit-epoch-time" // Maximum time to remember a request which we selected, but haven't seen a reaponse. RateLimitMaxDuration = "rate-limit-max-duration" // Channel size for packets coming in to collector RateLimitQueueDepth = "rate-limit-queue-depth" // Parameter controlling exponential moving average RateLimitExponentialAlpha = "rate-limit-exponential-alpha" )
Special host name indicating that no host information was available, e.g. because TLS 1.3 encrypts SNI data.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendCollector ¶
type BackendCollector struct {
// contains filtered or unexported fields
}
Sends witnesses up to akita cloud.
func (*BackendCollector) Close ¶
func (c *BackendCollector) Close() error
func (*BackendCollector) Process ¶
func (c *BackendCollector) Process(t akinet.ParsedNetworkTraffic) error
func (*BackendCollector) SwitchLearnSession ¶ added in v0.20.4
func (c *BackendCollector) SwitchLearnSession(session akid.LearnSessionID)
type BoundedPacketCounter ¶ added in v0.21.19
type BoundedPacketCounter[T constraints.Ordered] struct { // contains filtered or unexported fields }
func NewBoundedPacketCounter ¶ added in v0.21.19
func NewBoundedPacketCounter[T constraints.Ordered](limit int) *BoundedPacketCounter[T]
Creates a bounded packet counter limited to `limit` entries.
func (*BoundedPacketCounter[T]) AddOrInsert ¶ added in v0.21.19
func (bc *BoundedPacketCounter[T]) AddOrInsert(key T, c PacketCounts, makeNew func(PacketCounts) *PacketCounts)
Adds c to m[key]. Inserts makeNew(c) when adding a new key. Adds to overflow instead if the limit has been reached.
Use makeNew() to control the contents of the first PacketCount inserted for each new key, e.g. to set Interface = "*" when counting by port.
func (*BoundedPacketCounter[T]) Get ¶ added in v0.21.19
func (bc *BoundedPacketCounter[T]) Get(key T) (*PacketCounts, bool)
func (*BoundedPacketCounter[T]) GetOverflow ¶ added in v0.21.19
func (bc *BoundedPacketCounter[T]) GetOverflow() optionals.Optional[PacketCounts]
Return the overflow if the size hit the limit or None otherwise.
func (*BoundedPacketCounter[T]) HasReachedLimit ¶ added in v0.21.19
func (bc *BoundedPacketCounter[T]) HasReachedLimit() bool
func (*BoundedPacketCounter[T]) Len ¶ added in v0.21.19
func (bc *BoundedPacketCounter[T]) Len() int
func (*BoundedPacketCounter[T]) RawMap ¶ added in v0.21.19
func (bc *BoundedPacketCounter[T]) RawMap() map[T]*PacketCounts
func (*BoundedPacketCounter[T]) TopN ¶ added in v0.21.19
func (bc *BoundedPacketCounter[T]) TopN(n int, project func(*PacketCounts) int) (rv map[T]*PacketCounts, overflow optionals.Optional[PacketCounts])
Return a new map with the N entries in counts with the highest TCP packet counts. In the case of a tie for the Nth position, the entry with the smallest key is selected.
Returns the overflow count in overflow, or None if there is no overflow.
type Collector ¶
type Collector interface { // Hands new data from network to the collector. The implementation may choose // to process them asynchronously (e.g. to wait for the response to a // corresponding request). // Implementations should only return error if the error is unrecoverable and // the whole process should stop immediately. Process(akinet.ParsedNetworkTraffic) error // Implementations must complete processing all requests/responses before // returning. Close() error }
func New3PTrackerFilterCollector ¶
Filters out third-party trackers.
func NewBackendCollector ¶
func NewBackendCollector( svc akid.ServiceID, lrn akid.LearnSessionID, lc rest.LearnClient, maxWitnessSize_bytes optionals.Optional[int], packetCounts PacketCountConsumer, plugins []plugin.AkitaPlugin, ) Collector
func NewDummyCollector ¶ added in v0.19.0
func NewDummyCollector() Collector
func NewHTTPHostAllowlistCollector ¶ added in v0.16.3
Allows only matching hosts
func NewHTTPHostFilterCollector ¶
Filter out matching HTTP hosts
func NewHTTPPathAllowlistCollector ¶ added in v0.16.3
Allows only matching paths TODO: compile the N regular expressions into one for efficiency.
func NewHTTPPathFilterCollector ¶
Filters out HTTP paths. TODO: compile the N regular expressions into one for efficiency.
func NewSamplingCollector ¶ added in v0.20.0
Wraps a collector and performs sampling. Returns the collector itself if the given sampleRate is 1.0.
type HARCollector ¶
type HARCollector struct {
// contains filtered or unexported fields
}
func NewHARCollector ¶
func NewHARCollector(interfaceName, outDir string, tags map[tags.Key]string) *HARCollector
func (*HARCollector) Close ¶
func (h *HARCollector) Close() error
TODO: output HAR files periodically instead of buffering everything in memory.
func (*HARCollector) Process ¶
func (h *HARCollector) Process(t akinet.ParsedNetworkTraffic) error
type LearnSessionCollector ¶ added in v0.20.4
type LearnSessionCollector interface { Collector SwitchLearnSession(akid.LearnSessionID) }
An additional method supported by the backend collector to switch learn sessions.
type PacketCountCollector ¶ added in v0.15.1
type PacketCountCollector struct { PacketCounts PacketCountConsumer Collector Collector }
This is a shim to add packet counts based on payload type.
func (*PacketCountCollector) Close ¶ added in v0.15.1
func (pc *PacketCountCollector) Close() error
func (*PacketCountCollector) IncludeHostName ¶ added in v0.22.1
func (pc *PacketCountCollector) IncludeHostName(tlsName string) bool
Don't record self-generated traffic in the breakdown by hostname, unless the --dogfood flag has been set.
func (*PacketCountCollector) Process ¶ added in v0.15.1
func (pc *PacketCountCollector) Process(t akinet.ParsedNetworkTraffic) error
type PacketCountConsumer ¶ added in v0.13.0
type PacketCountConsumer interface {
// Add an additional measurement to the current count
Update(delta PacketCounts)
}
A consumer accepts incremental updates in the form of PacketCounters.
type PacketCountDiscard ¶ added in v0.13.0
type PacketCountDiscard struct { }
Discard the count
func (*PacketCountDiscard) Update ¶ added in v0.13.0
func (d *PacketCountDiscard) Update(_ PacketCounts)
type PacketCounter ¶ added in v0.21.0
type PacketCounter struct {
// contains filtered or unexported fields
}
A consumer that sums the count by (Interface, SrcPort, SrcHost) tuples. (DstPort, DstHost) are unused.
In the future, this could put counters on a pipe and do the increments in a separate goroutine, but we would *still* need a mutex to read the totals out.
Imposes a hard limit on the number of ports, interfaces, and hosts that are individually tracked.
func NewPacketCounter ¶ added in v0.21.0
func NewPacketCounter() *PacketCounter
func (*PacketCounter) AllPorts ¶ added in v0.21.0
func (s *PacketCounter) AllPorts() []PacketCounts
All available port numbers
func (*PacketCounter) Summary ¶ added in v0.21.0
func (s *PacketCounter) Summary(n int) *PacketCountSummary
Return a summary of the total, as well as the top N ports and interfaces by TCP traffic.
func (*PacketCounter) Total ¶ added in v0.21.0
func (s *PacketCounter) Total() PacketCounts
func (*PacketCounter) TotalOnHost ¶ added in v0.21.19
func (s *PacketCounter) TotalOnHost(host string) PacketCounts
Packet counters summed over host
func (*PacketCounter) TotalOnInterface ¶ added in v0.21.0
func (s *PacketCounter) TotalOnInterface(name string) PacketCounts
Packet counters summed over interface
func (*PacketCounter) TotalOnPort ¶ added in v0.21.0
func (s *PacketCounter) TotalOnPort(port int) PacketCounts
Packet counters summed over port
func (*PacketCounter) Update ¶ added in v0.21.0
func (s *PacketCounter) Update(c PacketCounts)
type SamplingCollector ¶
type SamplingCollector struct {
// contains filtered or unexported fields
}
Wraps a Collector and performs sampling.
func (*SamplingCollector) Close ¶
func (sc *SamplingCollector) Close() error
func (*SamplingCollector) Process ¶
func (sc *SamplingCollector) Process(t akinet.ParsedNetworkTraffic) error
type SharedRateLimit ¶ added in v0.16.0
type SharedRateLimit struct { // Current epoch: start time, sampling start time, count of witnesses captured // Witnesses per minute (configured value) and per epoch (derived value) // Current estimate of time taken to capture WitnessesPerEpoch // contains filtered or unexported fields }
func NewRateLimit ¶ added in v0.16.0
func NewRateLimit(witnessesPerMinute float64) *SharedRateLimit
func (*SharedRateLimit) AllowHTTPRequest ¶ added in v0.16.0
func (r *SharedRateLimit) AllowHTTPRequest() bool
Check if request should be sampled; increase the count by one.
func (*SharedRateLimit) AllowOther ¶ added in v0.16.0
func (r *SharedRateLimit) AllowOther() bool
Check if a non-HTTP packet should be sampled. All non-HTTP requests are passed through so they can be counted, if we're in an interval, but don't (yet) count against the witness budget. (For example, we might want to start counting source/dest pairs for HTTPS, or otherwise recording unparsable network traffic.)func (r *SharedRateLimit) AllowOther() bool {
func (*SharedRateLimit) IntervalStarted ¶ added in v0.16.0
func (r *SharedRateLimit) IntervalStarted() bool
func (*SharedRateLimit) NewCollector ¶ added in v0.16.0
func (r *SharedRateLimit) NewCollector(next Collector) Collector
func (*SharedRateLimit) Stop ¶ added in v0.16.0
func (r *SharedRateLimit) Stop()
type TeeCollector ¶
Not to be confused with coffee collector.
func (TeeCollector) Close ¶
func (tc TeeCollector) Close() error
func (TeeCollector) Process ¶
func (tc TeeCollector) Process(t akinet.ParsedNetworkTraffic) error
type UserTrafficCollector ¶
type UserTrafficCollector struct {
Collector Collector
}
Filters out CLI's own traffic to Akita APIs.
func (*UserTrafficCollector) Close ¶
func (sc *UserTrafficCollector) Close() error
func (*UserTrafficCollector) Process ¶
func (sc *UserTrafficCollector) Process(t akinet.ParsedNetworkTraffic) error