lib

package
v0.0.0-...-be06655 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: CC-BY-SA-4.0 Imports: 12 Imported by: 8

Documentation

Index

Constants

View Source
const (
	ActionAdd    Action = "add"
	ActionRemove Action = "remove"
	ActionOutput Action = "output"

	IPv4 IPType = "ipv4"
	IPv6 IPType = "ipv6"

	CaseRemovePrefix CaseRemove = 0
	CaseRemoveEntry  CaseRemove = 1
)

Variables

View Source
var (
	ErrDuplicatedConverter = errors.New("duplicated converter")
	ErrUnknownAction       = errors.New("unknown action")
	ErrNotSupportedFormat  = errors.New("not supported format")
	ErrInvalidIPType       = errors.New("invalid IP type")
	ErrInvalidIP           = errors.New("invalid IP address")
	ErrInvalidIPLength     = errors.New("invalid IP address length")
	ErrInvalidIPNet        = errors.New("invalid IPNet address")
	ErrInvalidCIDR         = errors.New("invalid CIDR")
	ErrInvalidPrefix       = errors.New("invalid prefix")
	ErrInvalidPrefixType   = errors.New("invalid prefix type")
	ErrCommentLine         = errors.New("comment line")
)
View Source
var ActionsRegistry = map[Action]bool{
	ActionAdd:    true,
	ActionRemove: true,
	ActionOutput: true,
}

Functions

func GetRemoteURLContent

func GetRemoteURLContent(url string) ([]byte, error)

func GetRemoteURLReader

func GetRemoteURLReader(url string) (io.ReadCloser, error)

func ListInputConverter

func ListInputConverter()

func ListOutputConverter

func ListOutputConverter()

func RegisterInputConfigCreator

func RegisterInputConfigCreator(id string, fn inputConfigCreator) error

func RegisterInputConverter

func RegisterInputConverter(name string, c InputConverter) error

func RegisterOutputConfigCreator

func RegisterOutputConfigCreator(id string, fn outputConfigCreator) error

func RegisterOutputConverter

func RegisterOutputConverter(name string, c OutputConverter) error

Types

type Action

type Action string

type Actioner

type Actioner interface {
	GetAction() Action
}

type CaseRemove

type CaseRemove int

type Container

type Container interface {
	GetEntry(name string) (*Entry, bool)
	Len() int
	Add(entry *Entry, opts ...IgnoreIPOption) error
	Remove(entry *Entry, rCase CaseRemove, opts ...IgnoreIPOption) error
	Loop() <-chan *Entry
	Lookup(ipOrCidr string, searchList ...string) ([]string, bool, error)
}

func NewContainer

func NewContainer() Container

type Descriptioner

type Descriptioner interface {
	GetDescription() string
}

type Entry

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

func NewEntry

func NewEntry(name string) *Entry

func (*Entry) AddPrefix

func (e *Entry) AddPrefix(cidr any) error

func (*Entry) GetIPv4Set

func (e *Entry) GetIPv4Set() (*netipx.IPSet, error)

func (*Entry) GetIPv6Set

func (e *Entry) GetIPv6Set() (*netipx.IPSet, error)

func (*Entry) GetName

func (e *Entry) GetName() string

func (*Entry) MarshalIPRange

func (e *Entry) MarshalIPRange(opts ...IgnoreIPOption) ([]netipx.IPRange, error)

func (*Entry) MarshalPrefix

func (e *Entry) MarshalPrefix(opts ...IgnoreIPOption) ([]netip.Prefix, error)

func (*Entry) MarshalText

func (e *Entry) MarshalText(opts ...IgnoreIPOption) ([]string, error)

func (*Entry) RemovePrefix

func (e *Entry) RemovePrefix(cidr string) error

type IPType

type IPType string

func IgnoreIPv4

func IgnoreIPv4() IPType

func IgnoreIPv6

func IgnoreIPv6() IPType

type IgnoreIPOption

type IgnoreIPOption func() IPType

type InputConverter

type InputConverter interface {
	Typer
	Actioner
	Descriptioner
	Input(Container) (Container, error)
}

type Instance

type Instance interface {
	InitConfig(configFile string) error
	InitConfigFromBytes(content []byte) error
	AddInput(InputConverter)
	AddOutput(OutputConverter)
	ResetInput()
	ResetOutput()
	RunInput(Container) error
	RunOutput(Container) error
	Run() error
}

func NewInstance

func NewInstance() (Instance, error)

type OutputConverter

type OutputConverter interface {
	Typer
	Actioner
	Descriptioner
	Output(Container) error
}

type Typer

type Typer interface {
	GetType() string
}

Jump to

Keyboard shortcuts

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