Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Positions = NewPositionHistory()
Positions is the process-wide station position store, shared by the packet ingestion path (which records positions) and the filter layer (which reads them for m/, f/ and ranged t/ filters).
Functions ¶
This section is empty.
Types ¶
type DupeChecker ¶
type DupeChecker struct {
// contains filtered or unexported fields
}
DupeChecker suppresses duplicate packets seen within a sliding time window. It is safe for concurrent use.
Duplicate detection is based on the packet's source callsign and information field only — the via path (and any q-construct appended to it) is ignored, so the same payload relayed through different paths is recognised as one packet. To also catch copies that a client has lightly corrupted in transit, each accepted packet is additionally stored under several normalised variants (trailing spaces removed, high bit handled, low/DEL bytes handled); a later packet matching any stored variant is treated as a duplicate.
func NewDupeChecker ¶
func NewDupeChecker(window time.Duration) *DupeChecker
NewDupeChecker creates a checker that treats identical packets as duplicates if seen again within window.
func (*DupeChecker) Cleanup ¶
func (d *DupeChecker) Cleanup()
Cleanup removes all entries older than the window. It is safe for concurrent use and intended to be called periodically (e.g. from cron) for long-lived checkers so the map does not retain expired keys indefinitely.
func (*DupeChecker) Seen ¶
func (d *DupeChecker) Seen(packet string) bool
Seen reports whether packet was seen within the window; otherwise it records it (and its normalised variants) and returns false. Expired entries are pruned at most once per window (time-sampled) so the hot path stays O(1) amortised instead of scanning the whole map on every packet.
type HeardList ¶
type HeardList struct {
// contains filtered or unexported fields
}
HeardList records the set of source stations a client has recently received, each with a last-heard timestamp, expiring entries after a configurable TTL. It is safe for concurrent use.
func NewHeardList ¶
func NewHeardList() *HeardList
NewHeardList creates an empty heard list with the default TTL.
func NewHeardListTTL ¶
NewHeardListTTL creates an empty heard list whose entries expire after ttl. A non-positive ttl falls back to the default.
func (*HeardList) Add ¶
Add records that the client has just heard the given station. Empty callsigns are ignored; growth is bounded by maxHeard.
func (*HeardList) Heard ¶
Heard reports whether the client has heard the given station within the TTL.
type MapFloat64History ¶
MapFloat64History is the basic struct to record history with float64 map
func NewMapFloat64History ¶
func NewMapFloat64History() *MapFloat64History
NewMapFloat64History creates a new history map with float64
func (*MapFloat64History) ClearByKey ¶
func (d *MapFloat64History) ClearByKey(TTL float64)
ClearByKey clears expired data by key as time
func (*MapFloat64History) Record ¶
func (d *MapFloat64History) Record(key any, value float64)
Record records data
func (*MapFloat64History) ToSlice ¶
func (d *MapFloat64History) ToSlice() [][2]any
ToSlice transfers map to slice
func (*MapFloat64History) ToSliceRange ¶ added in v1.1.1
func (d *MapFloat64History) ToSliceRange(from, to float64) [][2]any
ToSliceRange transfers map to a timestamp-sorted slice. When from or to is zero, that side of the range is left open.
type PositionHistory ¶
type PositionHistory struct {
// contains filtered or unexported fields
}
PositionHistory records the last-known position of stations by callsign so position-aware filters can resolve friend/own positions. It is safe for concurrent use.
func NewPositionHistory ¶
func NewPositionHistory() *PositionHistory
NewPositionHistory creates an empty position history store.
func (*PositionHistory) Cleanup ¶
func (h *PositionHistory) Cleanup()
Cleanup removes expired entries. It is intended to be called periodically.
func (*PositionHistory) Get ¶
func (h *PositionHistory) Get(call string) (lat, lon float64, ok bool)
Get returns the last-known position of a station. ok is false when the station is unknown or its record has expired.
func (*PositionHistory) Len ¶
func (h *PositionHistory) Len() int
Len returns the number of currently stored stations (including any not yet expired-out by Cleanup).
func (*PositionHistory) Update ¶
func (h *PositionHistory) Update(call string, lat, lon float64)
Update records (or refreshes) the position of a station. Calls with an empty callsign are ignored.