Documentation
¶
Overview ¶
Package nets maps client addresses to ASNs inside the engine and aggregates connection events without retaining addresses.
Index ¶
- func LookupAddr(a *Aggregator, addr net.Addr) uint32
- type Aggregator
- func (a *Aggregator) Add(inboundID string, asn uint32, event Event, credID, userID string)
- func (a *Aggregator) AddN(inboundID string, asn uint32, event Event, credID, userID string, count uint32)
- func (a *Aggregator) ClearTable()
- func (a *Aggregator) Enabled() bool
- func (a *Aggregator) LoadedSHA() string
- func (a *Aggregator) Lookup(addr netip.Addr) uint32
- func (a *Aggregator) Mode() uint32
- func (a *Aggregator) SetMode(mode uint32)
- func (a *Aggregator) SetTable(db *asndb.DB, sha string)
- func (a *Aggregator) Take() ([]*pb.NetworkCounters, []*pb.PersonNetwork)
- type Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LookupAddr ¶
func LookupAddr(a *Aggregator, addr net.Addr) uint32
LookupAddr resolves a peer address only while network collection is enabled. The address stays in the caller's scope.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator owns the active lookup table and one ten-minute window of network counts.
func New ¶
func New(mode uint32) *Aggregator
New returns an empty aggregator. A nil aggregator is safe to pass to engine environments.
func (*Aggregator) Add ¶
func (a *Aggregator) Add(inboundID string, asn uint32, event Event, credID, userID string)
Add records one connection event for an already-resolved ASN. The address must stay in the calling engine.
func (*Aggregator) AddN ¶
func (a *Aggregator) AddN(inboundID string, asn uint32, event Event, credID, userID string, count uint32)
AddN records count connection-level observations for one already-resolved ASN.
func (*Aggregator) ClearTable ¶
func (a *Aggregator) ClearTable()
ClearTable prevents further lookups until a matching table is loaded.
func (*Aggregator) Enabled ¶
func (a *Aggregator) Enabled() bool
Enabled reports whether lookups and connection events can be counted.
func (*Aggregator) LoadedSHA ¶
func (a *Aggregator) LoadedSHA() string
LoadedSHA returns the digest of the active table, or an empty string when none is loaded.
func (*Aggregator) Lookup ¶
func (a *Aggregator) Lookup(addr netip.Addr) uint32
Lookup maps an address to its ASN. It does no work when the feature is off or no table is loaded.
func (*Aggregator) SetMode ¶
func (a *Aggregator) SetMode(mode uint32)
SetMode selects off, aggregate-only, or aggregate-plus-person rows. Turning off drops the current window.
func (*Aggregator) SetTable ¶
func (a *Aggregator) SetTable(db *asndb.DB, sha string)
SetTable atomically replaces the address table and records the digest of its signed source file.
func (*Aggregator) Take ¶
func (a *Aggregator) Take() ([]*pb.NetworkCounters, []*pb.PersonNetwork)
Take transfers the current window to the caller, applying k=3 folding and resetting the aggregator.