xlistd

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package xlistd and subpackages implements a blacklist aggregator.

This package is a work in progress and makes no API stability promises.

Index

Constants

This section is empty.

Variables

Categories is a vector that constains all category types.

View Source
var ErrListRemoved = errors.New("removed from database, update your config")

ErrListRemoved is used when a list is marked as removed

Functions

func RegisterListBuilder

func RegisterListBuilder(class string, builder BuildListFn)

RegisterListBuilder registers a list builder for a class name

func RegisterWrapperBuilder

func RegisterWrapperBuilder(class string, builder BuildWrapperFn)

RegisterWrapperBuilder registers a wrapper builder for a class name

Types

type BuildListFn

type BuildListFn func(builder *Builder, parents []string, def ListDef) (List, error)

BuildListFn defines a function that constructs a checker.

type BuildWrapperFn

type BuildWrapperFn func(builder *Builder, def WrapperDef, list List) (List, error)

BuildWrapperFn defines a function that constructs a wrapper and returns the checker wrapped.

type Builder

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

Builder constructs RBL services.

func NewBuilder

func NewBuilder(services apiservice.Discover, opt ...BuilderOption) *Builder

NewBuilder instances a new builder.

func (Builder) APIService

func (b Builder) APIService(name string) (apiservice.Service, bool)

APIService returns service by name

func (*Builder) Build

func (b *Builder) Build(def ListDef) (List, error)

Build creates a RBL using the metadata passed as param.

func (*Builder) BuildChild

func (b *Builder) BuildChild(parents []string, def ListDef) (List, error)

BuildChild allows to create child list for composed RBL. Parameter parents is an array with the parents ID and is used for looping detection.

func (Builder) CertPath

func (b Builder) CertPath(cert string) string

CertPath returns path for certificate

func (Builder) DataPath

func (b Builder) DataPath(source string) string

DataPath returns path for source

func (*Builder) List

func (b *Builder) List(id string) (List, bool)

List returns the RBL created by builder with the id passed as param.

func (Builder) Logger

func (b Builder) Logger() yalogi.Logger

Logger returns logger

func (*Builder) OnShutdown

func (b *Builder) OnShutdown(f func() error)

OnShutdown registers the functions that will be executed during shutdown.

func (*Builder) OnStartup

func (b *Builder) OnStartup(f func() error)

OnStartup registers the functions that will be executed during startup.

func (*Builder) Shutdown

func (b *Builder) Shutdown() error

Shutdown executes all registered functions.

func (*Builder) Start

func (b *Builder) Start() error

Start executes all registered functions.

type BuilderOption

type BuilderOption func(*builderOpts)

BuilderOption is used for builder configuration.

func CertsDir

func CertsDir(s string) BuilderOption

CertsDir option sets certificate dir.

func DataDir

func DataDir(s string) BuilderOption

DataDir option sets source dir.

func SetLogger

func SetLogger(l yalogi.Logger) BuilderOption

SetLogger option sets a logger for the component.

type Category

type Category int

Category type is used for RBL classification.

const (
	Blacklist Category = iota //blacklist
	Whitelist                 //whitelist
	Mixedlist                 //mixed
	Infolist                  //information
)

Constants used for categories allowed.

func ToCategory

func ToCategory(s string) (Category, error)

ToCategory returns the category from its string representation.

func (Category) IsValid

func (c Category) IsValid() bool

IsValid returns true if resource code is a valid.

func (Category) MarshalJSON

func (c Category) MarshalJSON() ([]byte, error)

MarshalJSON implements interface for struct marshalling.

func (Category) String

func (c Category) String() string

func (*Category) UnmarshalJSON

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

UnmarshalJSON implements interface for struct unmarshalling.

type Format

type Format int

Format stores the type of available formats for lists.

const (
	Plain Format = iota
	CIDR
	Sub
)

List of formats.

func ToFormat

func ToFormat(s string) (Format, error)

ToFormat returns the format type from its string representation.

func (Format) String

func (f Format) String() string

String implements stringer interface.

type List

type List interface {
	ID() string
	Class() string
	Ping() error
	xlist.Checker
}

List is the main interface for RBL lists.

type ListDef

type ListDef struct {
	// ID must exist and be unique in databases for its correct operation
	ID string `json:"id"`
	// Class stores the component type of the RBL
	Class string `json:"class"`
	// Disabled flag
	Disabled bool `json:"disabled,omitempty"`
	// Removed flag
	Removed bool `json:"removed,omitempty"`
	// Deprecated flag
	Deprecated bool `json:"deprecated,omitempty"`
	// Name or description of the list
	Name string `json:"name,omitempty"`
	// Category of the list
	Category Category `json:"category"`
	// Tags associated with the list
	Tags []string `json:"tags,omitempty"`
	// Resources is a list of the recource types supported
	Resources []xlist.Resource `json:"resources,omitempty"`
	// Web provides the website of the RBL
	Web string `json:"web,omitempty"`
	// Source provides the origin of the RBL
	Source string `json:"source,omitempty"`
	// Client configuration
	Client *grpctls.ClientCfg `json:"tls,omitempty"`
	// Wrappers definition of the list
	Wrappers []WrapperDef `json:"wrappers,omitempty"`
	// Contains stores child RBLs
	Contains []ListDef `json:"contains,omitempty"`
	// Opts custom options of the RBL
	Opts map[string]interface{} `json:"opts,omitempty"`
}

ListDef stores metadata info about RBL services. It's used by Builder type to build generic Check interfaces.

func FilterCategory

func FilterCategory(c Category, l []ListDef) []ListDef

FilterCategory returns all listdefs of the category.

func FilterClass

func FilterClass(c string, l []ListDef) []ListDef

FilterClass returns all listdefs that correspond to the class passed.

func FilterID

func FilterID(id string, l []ListDef) (ListDef, bool)

FilterID returns the listdef with the id in the ListDef slice.

func FilterResource

func FilterResource(r xlist.Resource, l []ListDef) []ListDef

FilterResource returns all listdefs that provides support for the resource passed.

func FilterTag

func FilterTag(tag string, l []ListDef) []ListDef

FilterTag returns all listdefs that contains the tag. If tag is empty it will return lists with no tags.

func ListDefsFromFile

func ListDefsFromFile(path string) ([]ListDef, error)

ListDefsFromFile creates a slice of ListDef from a file in json format.

func (ListDef) ClientCfg

func (def ListDef) ClientCfg() grpctls.ClientCfg

ClientCfg returns a copy of client configuration. It returns an empty struct if a null pointer is stored.

type ListDefsByID

type ListDefsByID []ListDef

ListDefsByID implements sort.Interface based on the ID field

func (ListDefsByID) Len

func (a ListDefsByID) Len() int

func (ListDefsByID) Less

func (a ListDefsByID) Less(i, j int) bool

func (ListDefsByID) Swap

func (a ListDefsByID) Swap(i, j int)

type ListDefsByName

type ListDefsByName []ListDef

ListDefsByName implements sort.Interface based on the Name field

func (ListDefsByName) Len

func (a ListDefsByName) Len() int

func (ListDefsByName) Less

func (a ListDefsByName) Less(i, j int) bool

func (ListDefsByName) Swap

func (a ListDefsByName) Swap(i, j int)

type WrapperDef

type WrapperDef struct {
	// Class stores the component type of the Wrapper
	Class string `json:"class"`
	// Opts custom options of the wrapper
	Opts map[string]interface{} `json:"opts,omitempty"`
}

WrapperDef stores metadata info about wrappers. Wrappers are used for provide additional funtionality to RBLs.

Directories

Path Synopsis
components
apicheckxl
Package apicheckxl provides a xlistd.List implementation that uses an xlist.Check api service for its checks.
Package apicheckxl provides a xlistd.List implementation that uses an xlist.Check api service for its checks.
dnsxl
Package dnsxl provides a xlistd.List implementation that uses a dns zone as a source for its checks.
Package dnsxl provides a xlistd.List implementation that uses a dns zone as a source for its checks.
filexl
Package filexl provides a xlistd.List implementation that uses a file as source for its checks.
Package filexl provides a xlistd.List implementation that uses a file as source for its checks.
geoip2xl
Package geoip2xl provides a xlistd.List implementation that uses a geoip database for checks.
Package geoip2xl provides a xlistd.List implementation that uses a geoip database for checks.
grpcxl
Package grpcxl provides a xlistd.List implementation that uses a remote xlist.Check service as source.
Package grpcxl provides a xlistd.List implementation that uses a remote xlist.Check service as source.
memxl
Package memxl provides a xlistd.List implementation that uses main memory for storage.
Package memxl provides a xlistd.List implementation that uses main memory for storage.
mockxl
Package mockxl provides a simple xlist.List implementation that can be used to test other components or test configurations.
Package mockxl provides a simple xlist.List implementation that can be used to test other components or test configurations.
parallelxl
Package parallelxl provides a simple xlistd.List implementation that can be used to check in parallel on the child components.
Package parallelxl provides a simple xlistd.List implementation that can be used to check in parallel on the child components.
sblookupxl
Package sblookupxl provides a xlistd.List implementation that uses google safe browsing api as source.
Package sblookupxl provides a xlistd.List implementation that uses google safe browsing api as source.
selectorxl
Package selectorxl provides a simple xlist.Checker implementation that can be used to select the component defined to the requested resource.
Package selectorxl provides a simple xlist.Checker implementation that can be used to select the component defined to the requested resource.
sequencexl
Package sequencexl provides a simple xlistd.List implementation that can be used to check in sequence on the child components.
Package sequencexl provides a simple xlistd.List implementation that can be used to check in sequence on the child components.
wbeforexl
Package wbeforexl provides a simple xlistd.List implementation that can be used to check on a white list before checking on a blacklist.
Package wbeforexl provides a simple xlistd.List implementation that can be used to check on a white list before checking on a blacklist.
wrappers
cachewr
Package cachewr provides a wrapper for RBLs that implements a memory cache system.
Package cachewr provides a wrapper for RBLs that implements a memory cache system.
loggerwr
Package loggerwr provides a wrapper for RBLs that implements a logging system.
Package loggerwr provides a wrapper for RBLs that implements a logging system.
metricswr
Package metricswr provides a wrapper for RBLs that implements prometheus metrics.
Package metricswr provides a wrapper for RBLs that implements prometheus metrics.
policywr
Package policywr provides a wrapper for RBLs that inserts policies into responses.
Package policywr provides a wrapper for RBLs that inserts policies into responses.
responsewr
Package responsewr provides a wrapper for RBLs that changes the responses.
Package responsewr provides a wrapper for RBLs that changes the responses.
scorewr
Package scorewr provides a wrapper for RBLs that inserts scores into responses.
Package scorewr provides a wrapper for RBLs that inserts scores into responses.
timeoutwr
Package timeoutwr provides a wrapper for RBLs that sets a timeout in the check resquests.
Package timeoutwr provides a wrapper for RBLs that sets a timeout in the check resquests.

Jump to

Keyboard shortcuts

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