Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidListCacheType = fmt.Errorf("not a valid ListCacheType, try [%s]", strings.Join(_ListCacheTypeNames, ", "))
Functions ¶
func ListCacheTypeNames ¶
func ListCacheTypeNames() []string
ListCacheTypeNames returns a list of possible string values of ListCacheType.
Types ¶
type FileDownloader ¶
type FileDownloader interface {
DownloadFile(ctx context.Context, link string) (io.ReadCloser, error)
}
FileDownloader is able to download some text file
func NewDownloader ¶
func NewDownloader(cfg config.Downloader, transport http.RoundTripper) FileDownloader
type ListCache ¶
type ListCache struct {
// contains filtered or unexported fields
}
ListCache generic cache of strings divided in groups
func NewListCache ¶
func NewListCache(ctx context.Context, t ListCacheType, cfg config.SourceLoading, groupSources map[string][]config.BytesSource, downloader FileDownloader, ) (*ListCache, error)
NewListCache creates new list instance
type ListCacheType ¶
type ListCacheType int
ListCacheType represents the type of cached list ENUM( denylist // is a list with blocked domains allowlist // is a list with allowlisted domains / IPs )
const ( // ListCacheTypeDenylist is a ListCacheType of type Denylist. // is a list with blocked domains ListCacheTypeDenylist ListCacheType = iota // ListCacheTypeAllowlist is a ListCacheType of type Allowlist. // is a list with allowlisted domains / IPs ListCacheTypeAllowlist )
func ParseListCacheType ¶
func ParseListCacheType(name string) (ListCacheType, error)
ParseListCacheType attempts to convert a string to a ListCacheType.
func (*ListCacheType) AppendText ¶ added in v0.28.0
func (x *ListCacheType) AppendText(b []byte) ([]byte, error)
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (ListCacheType) IsValid ¶
func (x ListCacheType) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (ListCacheType) MarshalText ¶
func (x ListCacheType) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (ListCacheType) String ¶
func (x ListCacheType) String() string
String implements the Stringer interface.
func (*ListCacheType) UnmarshalText ¶
func (x *ListCacheType) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type Matcher ¶
type Matcher interface {
// Match matches passed domain name against cached list entries
Match(domain string, groupsToCheck []string) (groups []string)
}
Matcher checks if a domain is in a list
type SourceOpener ¶
func NewSourceOpener ¶
func NewSourceOpener(txtLocInfo string, source config.BytesSource, downloader FileDownloader) (SourceOpener, error)
type TransientError ¶
type TransientError struct {
// contains filtered or unexported fields
}
TransientError represents a temporary error like timeout, network errors...
func (*TransientError) Error ¶
func (e *TransientError) Error() string
func (*TransientError) Unwrap ¶
func (e *TransientError) Unwrap() error