lib

package
v0.0.0-...-7a53b35 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 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"
)

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")
	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 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 Container

type Container interface {
	GetEntry(name string) (*Entry, bool)
	Add(entry *Entry, opts ...IgnoreIPOption) error
	Remove(name string, opts ...IgnoreIPOption)
	Loop() <-chan *Entry
}

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) GetName

func (e *Entry) GetName() string

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 struct {
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance() (*Instance, error)

func (*Instance) Init

func (i *Instance) Init(configFile string) error

func (*Instance) Run

func (i *Instance) Run() 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