Documentation
¶
Overview ¶
Package singbox renders the sing-box source rule-set JSON document. It owns format only: target limits and policy decisions are supplied by the target definition and the planner. Unlike the Keenetic dialect this format is a declarative match set rather than a list of imperative route commands, and it carries domains and both address families instead of IPv4 routes alone.
Index ¶
- Constants
- func ProjectedRuleCount(plan domain.RoutingPlan) (int, error)
- func Render(plan domain.RoutingPlan) ([]byte, error)
- func Validate(payload []byte) error
- type Renderer
- func (Renderer) Descriptor() domain.RendererDescriptor
- func (Renderer) ID() string
- func (Renderer) ProjectedRuleCount(plan domain.RoutingPlan) (int, error)
- func (Renderer) Render(plan domain.RoutingPlan) ([]byte, error)
- func (Renderer) SupportedRuleKinds() []domain.RuleKind
- func (Renderer) Validate(payload []byte) error
- func (Renderer) Version() string
- type Rule
- type RuleSet
Constants ¶
const ( ID = "singbox-ruleset-json" Version = "singbox-source-json-v1" // FormatVersion is the sing-box source rule-set schema version this // renderer emits and the only version its validator accepts. FormatVersion = 3 MaxEntries = 8192 MaxArtifactSize = 1 << 20 ContentType = "application/json" FileExtension = "json" )
Variables ¶
This section is empty.
Functions ¶
func ProjectedRuleCount ¶
func ProjectedRuleCount(plan domain.RoutingPlan) (int, error)
ProjectedRuleCount counts the canonical match entries the document will carry. It is the number a target rule limit is compared against, so it must not count a duplicate twice.
Types ¶
type Renderer ¶
type Renderer struct{}
func (Renderer) Descriptor ¶
func (Renderer) Descriptor() domain.RendererDescriptor
func (Renderer) ProjectedRuleCount ¶
func (Renderer) ProjectedRuleCount(plan domain.RoutingPlan) (int, error)
func (Renderer) SupportedRuleKinds ¶
SupportedRuleKinds is deliberately wider than the Keenetic dialect: the same plan therefore reaches this format with domain rules the router format has to drop.
type Rule ¶
Rule is one sing-box headless rule. Only the match fields this renderer emits are modelled; an unknown field makes a document invalid rather than ignored.