lib

package
v0.0.0-...-ff55019 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

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

	CaseRemovePrefix CaseRemove = 0
	CaseRemoveEntry  CaseRemove = 1
)

Variables

View Source
var ActionsRegistry = map[Action]bool{
	ActionAdd:    true,
	ActionRemove: true,
	ActionOutput: true,
}

Functions

func IsEmpty

func IsEmpty(s string) bool

IsEmpty checks if a string is empty after trimming spaces

func RegisterInputConfigCreator

func RegisterInputConfigCreator(id string, fn inputConfigCreator) error

func RegisterInputConverter

func RegisterInputConverter(id string, converter InputConverter) error

func RegisterOutputConfigCreator

func RegisterOutputConfigCreator(id string, fn outputConfigCreator) error

func RegisterOutputConverter

func RegisterOutputConverter(id string, converter OutputConverter) error

func RemoveComment

func RemoveComment(line string) string

RemoveComment removes comments from a line

Types

type Action

type Action string

type Actioner

type Actioner interface {
	GetAction() Action
}

type CaseRemove

type CaseRemove int

type Config

type Config struct {
	Input  []ConfigItem `json:"input"`
	Output []ConfigItem `json:"output"`
}

Config is the configuration for converting domain lists

type ConfigItem

type ConfigItem struct {
	Type   string          `json:"type"`
	Action string          `json:"action"`
	Args   json.RawMessage `json:"args"`
}

ConfigItem is a single input or output configuration

func (*ConfigItem) GetInputConverter

func (c *ConfigItem) GetInputConverter() (InputConverter, error)

GetInputConverter returns an InputConverter for the ConfigItem

func (*ConfigItem) GetOutputConverter

func (c *ConfigItem) GetOutputConverter() (OutputConverter, error)

GetOutputConverter returns an OutputConverter for the ConfigItem

func (*ConfigItem) UnmarshalJSON

func (c *ConfigItem) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a ConfigItem from JSON

type Container

type Container interface {
	Add(entry *Entry) error
	Get(name string) (*Entry, bool)
	GetEntry(name string) (*Entry, bool)
	Has(name string) bool
	Loop() iter.Seq[*Entry]
	Len() int
	GetNames() []string
}

Container is a container for domain list entries

type Descriptioner

type Descriptioner interface {
	GetDescription() string
}

type Entry

type Entry struct {
	Name    string
	Domains []*router.Domain
}

Entry is a single domain list entry

func NewEntry

func NewEntry(name string) *Entry

NewEntry creates a new Entry

func (*Entry) AddDomain

func (e *Entry) AddDomain(domain *router.Domain)

AddDomain adds a domain to the entry

func (*Entry) AddDomains

func (e *Entry) AddDomains(domains []*router.Domain)

AddDomains adds multiple domains to the entry

func (*Entry) GetDomains

func (e *Entry) GetDomains() []*router.Domain

GetDomains returns all domains in the entry

func (*Entry) GetName

func (e *Entry) GetName() string

GetName returns the name of the entry

func (*Entry) MarshalText

func (e *Entry) MarshalText() ([]byte, error)

MarshalText converts the entry to text format

type InputConverter

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

type Instance

type Instance struct {
	Config    *Config
	Container Container
}

Instance is the main instance for converting domain lists

func NewInstance

func NewInstance() (*Instance, error)

NewInstance creates a new Instance

func (*Instance) InitConfig

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

InitConfig initializes the instance with a config file

func (*Instance) Run

func (i *Instance) Run() error

Run runs the conversion process

type OutputConverter

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

type SimpleContainer

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

SimpleContainer is a simple implementation of Container

func NewSimpleContainer

func NewSimpleContainer() *SimpleContainer

NewSimpleContainer creates a new SimpleContainer

func (*SimpleContainer) Add

func (c *SimpleContainer) Add(entry *Entry) error

Add adds an entry to the container

func (*SimpleContainer) Get

func (c *SimpleContainer) Get(name string) (*Entry, bool)

Get retrieves an entry by name

func (*SimpleContainer) GetEntry

func (c *SimpleContainer) GetEntry(name string) (*Entry, bool)

GetEntry retrieves an entry by name

func (*SimpleContainer) GetNames

func (c *SimpleContainer) GetNames() []string

GetNames returns all entry names

func (*SimpleContainer) Has

func (c *SimpleContainer) Has(name string) bool

Has checks if an entry exists

func (*SimpleContainer) Len

func (c *SimpleContainer) Len() int

Len returns the number of entries

func (*SimpleContainer) Loop

func (c *SimpleContainer) Loop() iter.Seq[*Entry]

Loop iterates over all entries

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