Documentation
¶
Overview ¶
Package opnsense provides an OPNsense-specific parser and converter that transforms schema.OpnSenseDocument into the platform-agnostic CommonDevice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNilDocument = errors.New("opnsense converter: received nil document")
ErrNilDocument is returned when ToCommonDevice receives a nil document.
Functions ¶
func ConvertDocument ¶
func ConvertDocument(doc *schema.OpnSenseDocument) (*common.CommonDevice, []common.ConversionWarning, error)
ConvertDocument transforms a parsed OpnSenseDocument into a platform-agnostic CommonDevice along with any non-fatal conversion warnings. This is a convenience function that creates a fresh converter internally.
func NewParserFactory ¶
func NewParserFactory(decoder parser.XMLDecoder) parser.DeviceParser
NewParserFactory returns a new DeviceParser configured for OPNsense devices. It satisfies the factory function signature required by DeviceParserRegistry.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser implements the DeviceParser interface for OPNsense configuration files. The XML decoder is injected at construction to keep this package free of internal/ imports.
func NewParser ¶
func NewParser(decoder parser.XMLDecoder) *Parser
NewParser returns a new OPNsense Parser backed by the given XML decoder. The decoder is typically cfgparser.NewXMLParser(), wired at the application layer.
func (*Parser) Parse ¶
func (p *Parser) Parse(ctx context.Context, r io.Reader) (*common.CommonDevice, []common.ConversionWarning, error)
Parse reads an OPNsense XML configuration from r (structural parsing only, no semantic validation) and returns a platform-agnostic CommonDevice along with any non-fatal conversion warnings.
func (*Parser) ParseAndValidate ¶
func (p *Parser) ParseAndValidate( ctx context.Context, r io.Reader, ) (*common.CommonDevice, []common.ConversionWarning, error)
ParseAndValidate reads an OPNsense XML configuration from r, runs both structural parsing and semantic validation, and returns a platform-agnostic CommonDevice along with any non-fatal conversion warnings.