rulelist

package
v0.108.0-b.48 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package rulelist contains the implementation of the standard rule-list filter that wraps an urlfilter filtering-engine.

TODO(a.garipov): Expand.

Index

Constants

View Source
const DefaultRuleBufSize = 1024

DefaultRuleBufSize is the default length of a buffer used to read a line with a filtering rule, in bytes.

View Source
const ErrHTML errors.Error = "data is HTML, not plain text"

ErrHTML is returned by Parser.Parse if the data is likely to be HTML.

TODO(a.garipov): This error is currently returned to the UI. Stop that and make it all-lowercase.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParseResult

type ParseResult struct {
	// Title is the title contained within the filtering-rule list, if any.
	Title string

	// RulesCount is the number of rules in the list.  It excludes empty lines
	// and comments.
	RulesCount int

	// BytesWritten is the number of bytes written to dst.
	BytesWritten int

	// Checksum is the CRC-32 checksum of the rules content.  That is, excluding
	// empty lines and comments.
	Checksum uint32
}

ParseResult contains information about the results of parsing a filtering-rule list by Parser.Parse.

type Parser

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

Parser is a filtering-rule parser that collects data, such as the checksum and the title, as well as counts rules and removes comments.

func NewParser

func NewParser() (p *Parser)

NewParser returns a new filtering-rule parser.

func (*Parser) Parse

func (p *Parser) Parse(dst io.Writer, src io.Reader, buf []byte) (r *ParseResult, err error)

Parse parses data from src into dst using buf during parsing. r is never nil.

Jump to

Keyboard shortcuts

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