sendpolicy

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PGNMatcher

type PGNMatcher struct {
	Singles []uint32
	Ranges  [][2]uint32 // [lo, hi] inclusive
}

PGNMatcher matches PGN numbers against a set of individual values and ranges.

func (*PGNMatcher) Contains

func (m *PGNMatcher) Contains(pgn uint32) bool

Contains returns true if pgn is in the matcher's set.

type SendPolicy

type SendPolicy struct {
	Enabled bool       // must be true for /send and /query to accept requests
	Rules   []SendRule // ordered rules; first match wins
}

SendPolicy controls whether the /send and /query endpoints are enabled and which frames are permitted. Rules are evaluated top-to-bottom; first match wins. If no rule matches, the request is denied. An empty Rules list with Enabled=true allows all frames (backwards compatible).

type SendRule

type SendRule struct {
	Allow bool        // true = allow, false = deny
	PGNs  *PGNMatcher // nil = match any PGN
	Names []uint64    // nil/empty = match any destination NAME
}

SendRule is a single allow or deny rule that matches frames by PGN and/or destination CAN NAME. Either matcher may be nil (wildcard).

func ParseSendRule

func ParseSendRule(s string) (SendRule, error)

ParseSendRule parses a single rule string. Syntax:

[!] [pgn:<spec>] [name:<hex>,...]

where <spec> is comma-separated PGN values or ranges (e.g. "59904", "59904,126208", "129025-129029", "59904,65280-65535").

A '!' prefix makes the rule a deny rule; otherwise it's an allow rule. Omitting pgn: matches all PGNs. Omitting name: matches all destinations.

Examples:

"pgn:59904"                              — allow PGN 59904 to any device
"pgn:59904,126208 name:001c6e4000200000" — allow two PGNs to one device
"pgn:129025-129029"                      — allow a PGN range
"!pgn:65280-65535"                       — deny proprietary PGN range
"name:001c6e4000200000"                  — allow any PGN to one device

func ParseSendRules

func ParseSendRules(rules []string) ([]SendRule, error)

ParseSendRules parses multiple rule strings.

func (*SendRule) Matches

func (r *SendRule) Matches(pgn uint32, dstNAME uint64, nameKnown bool) bool

Matches returns true if the rule matches the given PGN and destination NAME. A nil PGNs matcher matches any PGN; an empty Names list matches any NAME.

Jump to

Keyboard shortcuts

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