opnsense

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
var ErrNilDocument = errors.New("opnsense converter: received nil document")

ErrNilDocument is returned when ToCommonDevice receives a nil document.

Functions

func ConvertDocument

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

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.

Jump to

Keyboard shortcuts

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