Documentation
¶
Overview ¶
Package pfsense provides a pfSense-specific parser and converter that transforms pfsense.Document into the platform-agnostic CommonDevice.
Package pfsense provides a pfSense-specific parser and converter that transforms pfsense.Document into the platform-agnostic CommonDevice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNilDocument = errors.New("pfsense converter: received nil document")
ErrNilDocument is returned when ToCommonDevice receives a nil document.
var ValidateFunc func(doc *pfsense.Document) error
ValidateFunc is a function that validates a parsed pfSense document and returns an error if validation fails. Set this package-level variable from the cmd layer to inject internal/validator without violating pkg/ purity. When nil, ParseAndValidate falls back to structural parsing only.
Functions ¶
func ConvertDocument ¶
func ConvertDocument(doc *pfsense.Document) (*common.CommonDevice, []common.ConversionWarning, error)
ConvertDocument transforms a parsed pfSense Document 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 pfSense 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 pfSense configuration files. It manages its own XML decoding because the shared XMLDecoder returns *schema.OpnSenseDocument which is incompatible with pfsense.Document.
func NewParser ¶
func NewParser(_ parser.XMLDecoder) *Parser
NewParser returns a new pfSense Parser. The decoder parameter is accepted for compatibility with the ConstructorFunc signature but is not used because pfSense requires its own XML decoding pipeline.
func (*Parser) Parse ¶
func (p *Parser) Parse(ctx context.Context, r io.Reader) (*common.CommonDevice, []common.ConversionWarning, error)
Parse reads a pfSense 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 a pfSense XML configuration from r, runs structural parsing and semantic validation, and returns a platform-agnostic CommonDevice along with any non-fatal conversion warnings. If ValidateFunc has not been set (e.g., by cmd/root.go), falls back to structural parsing only.