ipaddrrangecheck

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const BinaryPackageVersion1 = 1

Variables

View Source
var ErrInsufficientBinaryBuffer = errors.New("insufficient binary buffer")
View Source
var ErrInvalidRule = errors.New("invalid check rule")
View Source
var ErrInvalidRuleType = errors.New("invalid rule type")
View Source
var ErrPackedBinaryBroken = errors.New("packed binary broken")
View Source
var ErrPackedBinarySizeMismatch = errors.New("packed binary size mismatch")
View Source
var ErrPackedBinaryUnsupportedVersion = errors.New("packed binary unsupported version")

Functions

This section is empty.

Types

type EqualAddressRule

type EqualAddressRule net.IP

func (EqualAddressRule) Contains

func (rule EqualAddressRule) Contains(ip net.IP) bool

func (EqualAddressRule) MarshalJSON

func (rule EqualAddressRule) MarshalJSON() ([]byte, error)

func (*EqualAddressRule) UnmarshalJSON

func (ruleRef *EqualAddressRule) UnmarshalJSON(buf []byte) (err error)

type Rule

type Rule interface {
	Contains(ip net.IP) bool
	// contains filtered or unexported methods
}

type RuleEntry

type RuleEntry struct {
	RuleType     RuleType `json:"rule_type"`
	RuleInstance Rule     `json:"condition"`
}

func (*RuleEntry) UnmarshalJSON

func (entry *RuleEntry) UnmarshalJSON(buf []byte) (err error)

type RuleSet

type RuleSet struct {
	// contains filtered or unexported fields
}

func NewRuleSet added in v0.0.2

func NewRuleSet(ruleEntries []RuleEntry) *RuleSet

func (*RuleSet) AppendEqualAddress

func (ruleSet *RuleSet) AppendEqualAddress(targetIP net.IP)

func (*RuleSet) AppendWithinNetwork

func (ruleSet *RuleSet) AppendWithinNetwork(targetNetwork *net.IPNet)

func (*RuleSet) AppendWithinRange

func (ruleSet *RuleSet) AppendWithinRange(fromIP net.IP, untilIP net.IP)

func (*RuleSet) Contains

func (ruleSet *RuleSet) Contains(ip net.IP) bool

func (*RuleSet) MarshalBinary

func (ruleSet *RuleSet) MarshalBinary() (data []byte, err error)

MarshalBinary returns the binary representation of the RuleSet. The binary representation is: - 4 bytes for Adler-32 checksum of the rest of binary package. - 4 bytes for total size (include checksum) of binary package. - 4 byte for count of rules. - 1 byte for binary package version. - rules in the following repeated format: --- 1 byte for rule type (RuleType), value 0 (UnknownRule) stop rule packs. --- packed rule binary.

func (*RuleSet) MarshalJSON

func (ruleSet *RuleSet) MarshalJSON() ([]byte, error)

func (*RuleSet) RuleEntries

func (ruleSet *RuleSet) RuleEntries() []RuleEntry

RuleEntries returns the internal slice of rule entries in the RuleSet. Do not alter the content of returned slice as it will also modify the content of rules in the ruleSet.

func (*RuleSet) UnmarshalBinary

func (ruleSet *RuleSet) UnmarshalBinary(data []byte) error

func (*RuleSet) UnmarshalJSON

func (ruleSet *RuleSet) UnmarshalJSON(buf []byte) (err error)

type RuleType

type RuleType int
const (
	UnknownRule RuleType = iota
	EqualAddress
	WithinNetwork
	WithinRange
)

func (RuleType) MarshalText

func (t RuleType) MarshalText() (text []byte, err error)

func (*RuleType) UnmarshalText

func (ref *RuleType) UnmarshalText(text []byte) error

type WithinNetworkRule

type WithinNetworkRule net.IPNet

func NewWithinNetworkRuleViaCIDR

func NewWithinNetworkRuleViaCIDR(s string) (*WithinNetworkRule, error)

func (*WithinNetworkRule) Contains

func (rule *WithinNetworkRule) Contains(ip net.IP) bool

func (*WithinNetworkRule) MarshalJSON

func (rule *WithinNetworkRule) MarshalJSON() ([]byte, error)

func (*WithinNetworkRule) UnmarshalJSON

func (rule *WithinNetworkRule) UnmarshalJSON(buf []byte) (err error)

type WithinRangeRule

type WithinRangeRule struct {
	FromIP  net.IP
	UntilIP net.IP
}

func NewWithinRangeRule

func NewWithinRangeRule(fromIP net.IP, untilIP net.IP) *WithinRangeRule

func (*WithinRangeRule) Contains

func (rule *WithinRangeRule) Contains(ip net.IP) bool

func (*WithinRangeRule) MarshalJSON

func (rule *WithinRangeRule) MarshalJSON() ([]byte, error)

func (*WithinRangeRule) UnmarshalJSON

func (rule *WithinRangeRule) UnmarshalJSON(buf []byte) (err error)

Jump to

Keyboard shortcuts

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