dictionary

package
v0.0.0-...-9fee2fa Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MPL-2.0 Imports: 9 Imported by: 6

Documentation

Overview

Package dictionary parses FreeRADIUS dictionary files.

API is currently unstable.

Index

Constants

View Source
const (
	EncryptUserPassword   = 1
	EncryptTunnelPassword = 2
)

Variables

This section is empty.

Functions

func SortAttributes

func SortAttributes(attrs []*Attribute)

func SortValues

func SortValues(values []*Value)

func SortVendors

func SortVendors(vendors []*Vendor)

Types

type Attribute

type Attribute struct {
	Name string
	OID  OID
	Type AttributeType

	Size IntFlag

	FlagEncrypt IntFlag
	FlagHasTag  BoolFlag
	FlagConcat  BoolFlag
}

func AttributeByName

func AttributeByName(attrs []*Attribute, name string) *Attribute

func AttributeByOID

func AttributeByOID(attrs []*Attribute, oid OID) *Attribute

func (*Attribute) Equals

func (a *Attribute) Equals(o *Attribute) bool

func (*Attribute) GoString

func (a *Attribute) GoString() string

func (*Attribute) HasTag

func (a *Attribute) HasTag() bool

func (*Attribute) MostlyEquals

func (a *Attribute) MostlyEquals(o *Attribute) bool

type AttributeType

type AttributeType int
const (
	AttributeString AttributeType = iota + 1
	AttributeOctets
	AttributeIPAddr
	AttributeDate
	AttributeInteger
	AttributeIPv6Addr
	AttributeIPv6Prefix
	AttributeIFID
	AttributeInteger64

	AttributeVSA

	AttributeEther
	AttributeABinary
	AttributeByte
	AttributeShort
	AttributeSigned
	AttributeTLV
	AttributeIPv4Prefix
)

func (AttributeType) String

func (t AttributeType) String() string

type AttributesOIDMap

type AttributesOIDMap struct {
	Attribute *Attribute
	Map       map[int]*AttributesOIDMap
}

type BeginVendorIncludeError

type BeginVendorIncludeError struct {
}

func (*BeginVendorIncludeError) Error

func (e *BeginVendorIncludeError) Error() string

type BoolFlag

type BoolFlag struct {
	Bool  bool
	Valid bool
}

type Dictionary

type Dictionary struct {
	AttributesByOID AttributesOIDMap
	Attributes      []*Attribute
	Values          []*Value
	Vendors         []*Vendor
	VendorByName    map[string]*Vendor
	VendorByNumber  map[uint]*Vendor
}

func Merge

func Merge(d1, d2 *Dictionary) (*Dictionary, error)

func (*Dictionary) GetAttributeByOID

func (d *Dictionary) GetAttributeByOID(oid OID) *Attribute

func (*Dictionary) GetVendorByName

func (d *Dictionary) GetVendorByName(name string) *Vendor

func (*Dictionary) GetVendorByNumber

func (d *Dictionary) GetVendorByNumber(num uint) *Vendor

func (*Dictionary) GoString

func (d *Dictionary) GoString() string

type DuplicateAttributeError

type DuplicateAttributeError struct {
	Attribute *Attribute
}

func (*DuplicateAttributeError) Error

func (e *DuplicateAttributeError) Error() string

type DuplicateAttributeFlagError

type DuplicateAttributeFlagError struct {
	Flag string
}

func (*DuplicateAttributeFlagError) Error

type DuplicateVendorError

type DuplicateVendorError struct {
	Vendor *Vendor
}

func (*DuplicateVendorError) Error

func (e *DuplicateVendorError) Error() string

type File

type File interface {
	io.Reader
	io.Closer
	Name() string
}

type FileSystemOpener

type FileSystemOpener struct {
	Root string
}

func (*FileSystemOpener) OpenFile

func (f *FileSystemOpener) OpenFile(name string) (File, error)

type IntFlag

type IntFlag struct {
	Int   int
	Valid bool
}

type InvalidAttributeEncryptTypeError

type InvalidAttributeEncryptTypeError struct {
	Type string
}

func (*InvalidAttributeEncryptTypeError) Error

type InvalidEndVendorError

type InvalidEndVendorError struct {
	Vendor string
}

func (*InvalidEndVendorError) Error

func (e *InvalidEndVendorError) Error() string

type InvalidOIDError

type InvalidOIDError struct {
	OID string
}

func (*InvalidOIDError) Error

func (e *InvalidOIDError) Error() string

type InvalidVendorFormatError

type InvalidVendorFormatError struct {
	Format string
}

func (*InvalidVendorFormatError) Error

func (e *InvalidVendorFormatError) Error() string

type NestedVendorBlockError

type NestedVendorBlockError struct {
}

func (*NestedVendorBlockError) Error

func (e *NestedVendorBlockError) Error() string

type OID

type OID []int

func (OID) Equals

func (o OID) Equals(other OID) bool

func (OID) String

func (o OID) String() string

type Opener

type Opener interface {
	OpenFile(name string) (File, error)
}

type ParseError

type ParseError struct {
	Inner error
	File  File
	Line  int
}

func (*ParseError) Error

func (e *ParseError) Error() string

type Parser

type Parser struct {
	Opener Opener

	// IgnoreIdenticalAttributes specifies whether identical attributes are
	// ignored, rather than a parse error being emitted.
	IgnoreIdenticalAttributes  bool
	IgnoreUnknownAttributeType bool
}

func (*Parser) Parse

func (p *Parser) Parse(f File) (*Dictionary, error)

func (*Parser) ParseFile

func (p *Parser) ParseFile(filename string) (*Dictionary, error)

type RecursiveIncludeError

type RecursiveIncludeError struct {
	Filename string
}

func (*RecursiveIncludeError) Error

func (e *RecursiveIncludeError) Error() string

type UnclosedVendorBlockError

type UnclosedVendorBlockError struct {
}

func (*UnclosedVendorBlockError) Error

func (e *UnclosedVendorBlockError) Error() string

type UnknownAttributeFlagError

type UnknownAttributeFlagError struct {
	Flag string
}

func (*UnknownAttributeFlagError) Error

func (e *UnknownAttributeFlagError) Error() string

type UnknownAttributeTypeError

type UnknownAttributeTypeError struct {
	Type string
}

func (*UnknownAttributeTypeError) Error

func (e *UnknownAttributeTypeError) Error() string

type UnknownLineError

type UnknownLineError struct {
	Line string
}

func (*UnknownLineError) Error

func (e *UnknownLineError) Error() string

type UnknownVendorError

type UnknownVendorError struct {
	Vendor string
}

func (*UnknownVendorError) Error

func (e *UnknownVendorError) Error() string

type UnmatchedEndVendorError

type UnmatchedEndVendorError struct {
}

func (*UnmatchedEndVendorError) Error

func (e *UnmatchedEndVendorError) Error() string

type Value

type Value struct {
	Attribute string
	Name      string
	Number    uint
}

func ValuesByAttribute

func ValuesByAttribute(values []*Value, attribute string) []*Value

type Vendor

type Vendor struct {
	Name   string
	Number uint

	TypeOctets   *int
	LengthOctets *int

	AttributesByOID AttributesOIDMap
	Attributes      []*Attribute
	Values          []*Value
}

func VendorByName

func VendorByName(vendors []*Vendor, name string) *Vendor

func VendorByNumber

func VendorByNumber(vendors []*Vendor, number uint) *Vendor

func (*Vendor) Equals

func (a *Vendor) Equals(b *Vendor) bool

func (*Vendor) GetAttributeByOID

func (v *Vendor) GetAttributeByOID(oid OID) *Attribute

func (*Vendor) GetLengthOctets

func (v *Vendor) GetLengthOctets() int

func (*Vendor) GetTypeOctets

func (v *Vendor) GetTypeOctets() int

func (*Vendor) GoString

func (v *Vendor) GoString() string

Jump to

Keyboard shortcuts

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