Documentation
¶
Index ¶
- Constants
- Variables
- func EqualUnorderedAdg(a, b []string) bool
- func ExtractAllowlistDomains(logger *multilog.Logger, content string) ([]string, []string)
- func ExtractBlocklistDomains(logger *multilog.Logger, content string) ([]string, []string)
- func ParseToAdguardEntry(raw string) (string, bool)
- func RegisterGenericProcessor(sourceType string, processFunc ProcessFunc, blocklistOnly bool, ...)
- func RegisterProcessor(sourceType string, processorCreator func(string, string) Processor)
- func RegisterProcessorTypes(sourceType string, listTypes []string, ...)
- type AdGuardAllowlistProcessor
- type AdGuardBlocklistProcessor
- type AdGuardDomainAllowlistProcessor
- type AdGuardDomainBlocklistProcessor
- type AdGuardHttpUrlProcessor
- type AdguardCsvHttpUrlFindProcessor
- type BaseProcessor
- type DomainCommentProcessor
- type DomainCsvHttpUrlFindProcessor
- type DomainCustomCsvBlackbookProcessor
- type DomainCustomCsvMaltrailProcessor
- type DomainCustomHtmlCcamProcessor
- type DomainCustomHtmlPuppyScamsProcessor
- type DomainHttpUrlProcessor
- type DomainTopProcessor
- type DomainUrlProcessor
- type DomainWithCommentSuffixProcessor
- type GenericProcessor
- type HostnameProcessor
- type Ipv4CidrProcessor
- type Ipv4CsvHttpUrlFindProcessor
- type Ipv4CustomHtmlCcamProcessor
- type Ipv4FindProcessor
- type Ipv4FromDomainProcessor
- type Ipv4HttpUrlProcessor
- type Ipv4RangeProcessor
- type Ipv4UrlProcessor
- type Ipv6FindProcessor
- type Ipv6HtaccessProcessor
- type ProcessFunc
- type Processor
- type ProcessorFactory
- type ProcessorRegistry
- type SpecialProcessorRegistry
Constants ¶
const ( AdguardExceptionPrefix = "@@" AdguardBlockPrefix = "||" AdguardBlockSuffix = "^" AdguardBlockSuffixFull = "$" )
Variables ¶
var Processors = NewProcessorRegistry()
var SpecialProcessors = NewSpecialProcessorRegistry()
SpecialProcessors Global instance of the special processor registry
Functions ¶
func EqualUnorderedAdg ¶ added in v1.0.3
func ExtractAllowlistDomains ¶
func ExtractBlocklistDomains ¶
func ParseToAdguardEntry ¶ added in v1.0.3
ParseToAdguardEntry parses a raw URL string and returns an AdGuard folder-style entry
func RegisterGenericProcessor ¶
func RegisterGenericProcessor( sourceType string, processFunc ProcessFunc, blocklistOnly bool, allowlistOnly bool, )
RegisterGenericProcessor registers a processor with a custom processing function
func RegisterProcessor ¶
RegisterProcessor registers a processor for both blocklist and allowlist types
Types ¶
type AdGuardAllowlistProcessor ¶
type AdGuardAllowlistProcessor struct {
BaseProcessor
}
AdGuardAllowlistProcessor handles AdGuard allowlist entries (different format)
func NewAdGuardAllowlistProcessor ¶
func NewAdGuardAllowlistProcessor(sourceType, listType string) *AdGuardAllowlistProcessor
NewAdGuardAllowlistProcessor creates a new AdGuard allowlist processor
type AdGuardBlocklistProcessor ¶
type AdGuardBlocklistProcessor struct {
BaseProcessor
}
AdGuardBlocklistProcessor handles AdGuard blocklist entries
func NewAdGuardBlocklistProcessor ¶
func NewAdGuardBlocklistProcessor(sourceType, listType string) *AdGuardBlocklistProcessor
NewAdGuardBlocklistProcessor creates a new AdGuard blocklist processor
type AdGuardDomainAllowlistProcessor ¶ added in v1.0.1
type AdGuardDomainAllowlistProcessor struct {
BaseProcessor
}
AdGuardDomainAllowlistProcessor converts plain domains into AdGuard allowlist rules (@@||domain^)
func NewAdGuardDomainAllowlistProcessor ¶ added in v1.0.1
func NewAdGuardDomainAllowlistProcessor(sourceType, listType string) *AdGuardDomainAllowlistProcessor
NewAdGuardDomainAllowlistProcessor creates a new processor for adguard_domain allowlist
type AdGuardDomainBlocklistProcessor ¶ added in v1.0.1
type AdGuardDomainBlocklistProcessor struct {
BaseProcessor
}
AdGuardDomainBlocklistProcessor converts plain domains into AdGuard blocklist rules (||domain^)
func NewAdGuardDomainBlocklistProcessor ¶ added in v1.0.1
func NewAdGuardDomainBlocklistProcessor(sourceType, listType string) *AdGuardDomainBlocklistProcessor
NewAdGuardDomainBlocklistProcessor creates a new processor for adguard_domain blocklist
type AdGuardHttpUrlProcessor ¶ added in v1.0.3
type AdGuardHttpUrlProcessor struct {
BaseProcessor
}
AdGuardHttpUrlProcessor converts http/https URLs into AdGuard blocklist rules (||host/path$)
func NewAdGuardHttpUrlProcessor ¶ added in v1.0.3
func NewAdGuardHttpUrlProcessor(sourceType, listType string) *AdGuardHttpUrlProcessor
NewAdGuardHttpUrlProcessor creates a new processor for adguard_httpurl
type AdguardCsvHttpUrlFindProcessor ¶ added in v1.0.3
type AdguardCsvHttpUrlFindProcessor struct {
BaseProcessor
}
AdguardCsvHttpUrlFindProcessor extracts http/https URLs from CSV lines and converts them into AdGuard block rules
func NewAdguardCsvHttpUrlFindProcessor ¶ added in v1.0.3
func NewAdguardCsvHttpUrlFindProcessor(sourceType, listType string) *AdguardCsvHttpUrlFindProcessor
type BaseProcessor ¶
type BaseProcessor struct {
// contains filtered or unexported fields
}
BaseProcessor provides common functionality for all processors
func NewBaseProcessor ¶
func NewBaseProcessor(sourceType, listType string) BaseProcessor
NewBaseProcessor creates a new base processor with the given source type and list type
func (*BaseProcessor) GetListType ¶
func (bp *BaseProcessor) GetListType() string
GetListType returns the list type identifier for this processor
func (*BaseProcessor) GetSourceType ¶
func (bp *BaseProcessor) GetSourceType() string
GetSourceType returns the source type identifier for this processor
type DomainCommentProcessor ¶ added in v0.2.0
type DomainCommentProcessor struct {
BaseProcessor
}
func NewDomainCommentProcessor ¶ added in v0.2.0
func NewDomainCommentProcessor(sourceType, listType string) *DomainCommentProcessor
type DomainCsvHttpUrlFindProcessor ¶ added in v0.3.0
type DomainCsvHttpUrlFindProcessor struct {
BaseProcessor
}
func NewDomainCsvHttpUrlFindProcessor ¶ added in v0.3.0
func NewDomainCsvHttpUrlFindProcessor(sourceType, listType string) *DomainCsvHttpUrlFindProcessor
type DomainCustomCsvBlackbookProcessor ¶ added in v0.2.0
type DomainCustomCsvBlackbookProcessor struct {
BaseProcessor
}
func NewDomainCustomCsvBlackbookProcessor ¶ added in v0.2.0
func NewDomainCustomCsvBlackbookProcessor(sourceType, listType string) *DomainCustomCsvBlackbookProcessor
type DomainCustomCsvMaltrailProcessor ¶
type DomainCustomCsvMaltrailProcessor struct {
BaseProcessor
}
func NewDomainCustomCsvMaltrailProcessor ¶
func NewDomainCustomCsvMaltrailProcessor(sourceType, listType string) *DomainCustomCsvMaltrailProcessor
type DomainCustomHtmlCcamProcessor ¶ added in v0.3.0
type DomainCustomHtmlCcamProcessor struct {
BaseProcessor
}
DomainCustomHtmlCcamProcessor implements a processor for extracting domain names from HTML content, specifically focussing on CCAM-formatted HTML tables.
func NewDomainCustomHtmlCcamProcessor ¶ added in v0.3.0
func NewDomainCustomHtmlCcamProcessor(sourceType, listType string) *DomainCustomHtmlCcamProcessor
NewDomainCustomHtmlCcamProcessor creates a new instance of DomainCustomHtmlCcamProcessor.
Returns:
- A configured DomainCustomHtmlCcamProcessor instance
func (*DomainCustomHtmlCcamProcessor) Process ¶ added in v0.3.0
func (p *DomainCustomHtmlCcamProcessor) Process(logger *multilog.Logger, content string) ([]string, []string)
Process extracts valid domain names from HTML table cells. It parses the HTML content, finds all table cells, and extracts domains from each cell. Duplicate domains are automatically removed.
Parameters:
- logger: Logger for recording operations and errors
- content: The HTML content to process
Returns:
- A slice of valid domain names found in the content, sorted alphabetically
- A slice of invalid entries that couldn't be parsed as domains
type DomainCustomHtmlPuppyScamsProcessor ¶ added in v0.3.0
type DomainCustomHtmlPuppyScamsProcessor struct {
BaseProcessor
}
DomainCustomHtmlPuppyScamsProcessor implements a processor for extracting domain names from HTML content, specifically focusing on PuppyScams.
func NewDomainCustomHtmlPuppyScamsProcessor ¶ added in v0.3.0
func NewDomainCustomHtmlPuppyScamsProcessor(sourceType, listType string) *DomainCustomHtmlPuppyScamsProcessor
NewDomainCustomHtmlPuppyScamsProcessor creates a new instance of DomainCustomHtmlPuppyScamsProcessor.
Returns:
- A configured DomainCustomHtmlPuppyScamsProcessor instance
func (*DomainCustomHtmlPuppyScamsProcessor) Process ¶ added in v0.3.0
func (p *DomainCustomHtmlPuppyScamsProcessor) Process(logger *multilog.Logger, content string) ([]string, []string)
Process extracts valid domain names from HTML tags.
Parameters:
- logger: Logger for recording operations and errors
- content: The HTML content to process
Returns:
- A slice of valid domain names found in the content, sorted alphabetically
- A slice of invalid entries that couldn't be parsed as domains
type DomainHttpUrlProcessor ¶ added in v0.2.0
type DomainHttpUrlProcessor struct {
BaseProcessor
}
DomainHttpUrlProcessor implements a processor for extracting domain names from HTTP and HTTPS URLs.
func NewDomainHttpUrlProcessor ¶ added in v0.2.0
func NewDomainHttpUrlProcessor(sourceType, listType string) *DomainHttpUrlProcessor
NewDomainHttpUrlProcessor creates a new instance of DomainHttpUrlProcessor.
Returns:
- A configured DomainHttpUrlProcessor instance
func (*DomainHttpUrlProcessor) Process ¶ added in v0.2.0
Process extracts valid domain names from HTTP/HTTPS URLs. It parses each line, extracts the domain from URLs, and validates them. Duplicate domains are automatically removed.
Parameters:
- logger: Logger for recording operations and errors
- content: The content containing URLs to process
Returns:
- A slice of valid domain names found in the content
- A slice of invalid entries that couldn't be parsed
type DomainTopProcessor ¶
type DomainTopProcessor struct {
BaseProcessor
}
func NewDomainTopProcessor ¶
func NewDomainTopProcessor(sourceType, listType string) *DomainTopProcessor
type DomainUrlProcessor ¶ added in v0.3.0
type DomainUrlProcessor struct {
BaseProcessor
}
func NewDomainUrlProcessor ¶ added in v0.3.0
func NewDomainUrlProcessor(sourceType, listType string) *DomainUrlProcessor
type DomainWithCommentSuffixProcessor ¶ added in v0.2.0
type DomainWithCommentSuffixProcessor struct {
BaseProcessor
}
func NewDomainWithCommentSuffixProcessor ¶ added in v0.2.0
func NewDomainWithCommentSuffixProcessor(sourceType, listType string) *DomainWithCommentSuffixProcessor
type GenericProcessor ¶
type GenericProcessor struct {
BaseProcessor
// contains filtered or unexported fields
}
GenericProcessor is a customizable processor that uses a function for processing
func NewGenericProcessor ¶
func NewGenericProcessor(sourceType, listType string, processFunc ProcessFunc) *GenericProcessor
NewGenericProcessor creates a new processor with custom processing logic
type HostnameProcessor ¶
type HostnameProcessor struct {
BaseProcessor
}
func NewHostnameProcessor ¶
func NewHostnameProcessor(sourceType, listType string) *HostnameProcessor
type Ipv4CidrProcessor ¶ added in v0.2.0
type Ipv4CidrProcessor struct {
BaseProcessor
}
func NewIpv4CidrProcessor ¶ added in v0.2.0
func NewIpv4CidrProcessor(sourceType, listType string) *Ipv4CidrProcessor
type Ipv4CsvHttpUrlFindProcessor ¶ added in v0.3.0
type Ipv4CsvHttpUrlFindProcessor struct {
BaseProcessor
}
func NewIpv4CsvHttpUrlFindProcessor ¶ added in v0.3.0
func NewIpv4CsvHttpUrlFindProcessor(sourceType, listType string) *Ipv4CsvHttpUrlFindProcessor
type Ipv4CustomHtmlCcamProcessor ¶ added in v0.3.0
type Ipv4CustomHtmlCcamProcessor struct {
BaseProcessor
}
Ipv4CustomHtmlCcamProcessor implements a processor for extracting IPv4 addresses from HTML content, specifically targeting CCAM-formatted HTML tables.
func NewIpv4CustomHtmlCcamProcessor ¶ added in v0.3.0
func NewIpv4CustomHtmlCcamProcessor(sourceType, listType string) *Ipv4CustomHtmlCcamProcessor
NewIpv4CustomHtmlCcamProcessor creates a new instance of Ipv4CustomHtmlCcamProcessor.
Returns:
- A configured Ipv4CustomHtmlCcamProcessor instance
func (*Ipv4CustomHtmlCcamProcessor) Process ¶ added in v0.3.0
func (p *Ipv4CustomHtmlCcamProcessor) Process(logger *multilog.Logger, content string) ([]string, []string)
Process extracts valid IPv4 addresses from HTML table cells. It parses the HTML content, finds all table cells, and extracts IPv4 addresses from each cell. Duplicate addresses are automatically removed.
Parameters:
- logger: Logger for recording operations and errors
- content: The HTML content to process
Returns:
- A slice of valid IPv4 addresses found in the content, sorted alphabetically
- A slice of invalid entries that couldn't be parsed as IPv4 addresses
type Ipv4FindProcessor ¶
type Ipv4FindProcessor struct {
BaseProcessor
}
func NewIpv4FindProcessor ¶
func NewIpv4FindProcessor(sourceType, listType string) *Ipv4FindProcessor
type Ipv4FromDomainProcessor ¶ added in v0.4.0
type Ipv4FromDomainProcessor struct {
BaseProcessor
}
func NewIpv4FromDomainProcessor ¶ added in v0.4.0
func NewIpv4FromDomainProcessor(sourceType, listType string) *Ipv4FromDomainProcessor
type Ipv4HttpUrlProcessor ¶ added in v0.2.0
type Ipv4HttpUrlProcessor struct {
BaseProcessor
}
func NewIpv4HttpUrlProcessor ¶ added in v0.2.0
func NewIpv4HttpUrlProcessor(sourceType, listType string) *Ipv4HttpUrlProcessor
type Ipv4RangeProcessor ¶ added in v0.2.0
type Ipv4RangeProcessor struct {
BaseProcessor
}
func NewIpv4RangeProcessor ¶ added in v0.2.0
func NewIpv4RangeProcessor(sourceType, listType string) *Ipv4RangeProcessor
type Ipv4UrlProcessor ¶ added in v0.3.0
type Ipv4UrlProcessor struct {
BaseProcessor
}
func NewIpv4UrlProcessor ¶ added in v0.3.0
func NewIpv4UrlProcessor(sourceType, listType string) *Ipv4UrlProcessor
type Ipv6FindProcessor ¶ added in v0.3.0
type Ipv6FindProcessor struct {
BaseProcessor
}
func NewIpv6FindProcessor ¶ added in v0.3.0
func NewIpv6FindProcessor(sourceType, listType string) *Ipv6FindProcessor
type Ipv6HtaccessProcessor ¶ added in v0.3.0
type Ipv6HtaccessProcessor struct {
BaseProcessor
}
Ipv6HtaccessProcessor implements a processor for extracting IPv6 addresses from htaccess file content.
func NewIpv6HtaccessProcessor ¶ added in v0.3.0
func NewIpv6HtaccessProcessor(sourceType, listType string) *Ipv6HtaccessProcessor
type ProcessFunc ¶
ProcessFunc is a function type for the specific processing logic
type Processor ¶
type Processor interface {
// Process parses the content and returns valid and invalid entries
Process(logger *multilog.Logger, content string) ([]string, []string)
// GetSourceType returns the source type this processor handles
GetSourceType() string
// GetListType returns the list type this processor handles
GetListType() string
}
Processor defines the interface that all processor types should implement. Each processor must be able to parse content and extract valid and invalid entries, as well as report its source type.
type ProcessorFactory ¶
ProcessorFactory is a generic factory function type for creating processors
type ProcessorRegistry ¶
type ProcessorRegistry struct {
// contains filtered or unexported fields
}
ProcessorRegistry is a thread-safe registry for processors.
func NewProcessorRegistry ¶
func NewProcessorRegistry() *ProcessorRegistry
NewProcessorRegistry provides a thread-safe registry for processors.
func (*ProcessorRegistry) GetProcessor ¶
func (pr *ProcessorRegistry) GetProcessor(sourceType, listType string) (Processor, bool)
GetProcessor retrieves a processor for a source type and list type.
Parameters:
- sourceType: The source type to look up
- listType: The list type to look up
Returns:
- The registered processor for the source type and list type
- A boolean indicating whether a processor was found
func (*ProcessorRegistry) ListProcessors ¶
func (pr *ProcessorRegistry) ListProcessors() map[string]Processor
ListProcessors returns a copy of all registered processors. The returned map is a clone of the registry, so modifications to it won't affect the actual registry.
Returns:
- A map of composite keys (sourceType:listType) to processors
func (*ProcessorRegistry) RegisterProcessor ¶
func (pr *ProcessorRegistry) RegisterProcessor(sourceType, listType string, processor Processor)
RegisterProcessor registers a processor for a source type and list type. If a processor for the given source type and list type already exists, it will be replaced.
Parameters:
- sourceType: The source type identifier for this processor
- listType: The list type identifier for this processor
- processor: The processor implementation to register
type SpecialProcessorRegistry ¶
type SpecialProcessorRegistry struct {
// contains filtered or unexported fields
}
SpecialProcessorRegistry provides a way to register processors with special conditions different handling for blocklists vs. allowlists
func NewSpecialProcessorRegistry ¶
func NewSpecialProcessorRegistry() *SpecialProcessorRegistry
NewSpecialProcessorRegistry creates a new registry for special processors
func (*SpecialProcessorRegistry) GetProcessor ¶
func (r *SpecialProcessorRegistry) GetProcessor(sourceType, listType string) (Processor, bool)
GetProcessor returns a processor for the requested source and list types
func (*SpecialProcessorRegistry) Register ¶
func (r *SpecialProcessorRegistry) Register(sourceType, listType string, factory ProcessorFactory)
Register adds a processor factory for a specific source and list type
Source Files
¶
- adguard_csv_http_url_find_processor.go
- adguard_helpers.go
- adguard_processor.go
- base_processor.go
- domain_comment.go
- domain_csv_http_url_find_processor.go
- domain_custom_csv_blackbook.go
- domain_custom_csv_maltrail.go
- domain_custom_html_ccam_processor.go
- domain_custom_html_puppyscams_processor.go
- domain_http_url_processor.go
- domain_top_processor.go
- domain_url_processor.go
- domain_with_comment_suffix.go
- hostname_processor.go
- ipv4_cidr_expand_processor.go
- ipv4_csv_http_url_find_processor.go
- ipv4_custom_html_ccam_processor.go
- ipv4_find_processor.go
- ipv4_from_domain_processor.go
- ipv4_http_url_processor.go
- ipv4_range_expand_processor.go
- ipv4_url_processor.go
- ipv6_find_processor.go
- ipv6_htaccess_processor.go
- processor_factory.go
- processor_registry.go