filter

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package filter implements the standard APRS-IS server-side packet filters (14 types):

a/  area (bounding box)        b/  buddy (source callsign, wildcards)
d/  used digipeater            e/  entry station (q-construct igate)
f/  friend range               g/  message recipient
m/  my range                   o/  object/item name
p/  source prefix              q/  q-construct
r/  range (lat/lon/dist)       s/  symbol
t/  type (+ optional range)    u/  unproto (destination)

A filter string is a space-separated list of specs. A leading '-' negates a spec (matching packets are dropped). Type letters and the q construct value are case-sensitive; callsign/prefix matching is not.

Stateful filters (m/, f/ and the ranged form of t/) need station positions, supplied by the caller through a Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	// ClientPosition returns the requesting client's own last-known position.
	// ok is false when the position is unknown (m/ then cannot match).
	ClientPosition() (pos Position, ok bool)
	// StationPosition returns the last-known position of an arbitrary station
	// by callsign. ok is false when unknown.
	StationPosition(callsign string) (pos Position, ok bool)
}

Context supplies stateful information that some filters need.

Implementations are provided by the server layer (e.g. backed by a historydb of last-known station positions). A nil Context is acceptable; stateful filters that need data the Context cannot provide simply do not match.

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter is a compiled, reusable set of filter specs.

func Compile

func Compile(s string) *Filter

Compile parses a filter string into a reusable Filter. Unknown or malformed specs are skipped but recorded in the raw string. It never returns an error; an empty or whitespace-only string yields a Filter that matches nothing.

func (*Filter) Match

func (f *Filter) Match(pkt *parser.Parsed, ctx Context) bool

Match reports whether the packet should be forwarded to the client owning this filter. ctx may be nil. Negated specs are checked first: if any matches, the packet is dropped. Otherwise, a positive match passes; with no positive specs nothing passes.

func (*Filter) String

func (f *Filter) String() string

String returns the original filter text.

type Position

type Position struct {
	Lat float64
	Lon float64
}

Position is a geographic coordinate in decimal degrees.

Jump to

Keyboard shortcuts

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