sendpolicy

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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