ublock

package module
v0.0.0-...-3d07873 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

README

Go Tenta AdBlock

GoDoc

Composes of asset construction, filtering, and compression/decompression primitives. Currently supporting filter definitions without options, host files.

Support for options and cosmetic filters, DOM alteration is underway.

Contact: developer@tenta.io

Installation

  1. go get github.com/tenta-browser/go-tenta-adblock

API

Asset generation

  • Init(): Initialize parser
  • AssembleRuleDatabase(): Download and parse filters, generate embeddable uBlock asset

Runtime filtering

  • Deserialize(): Reconstruct binary encoded asset into memory
  • Search(): Search for a token (URL) for appartenance to the filtering lists

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

For any questions, please contact developer@tenta.io

Contributing

We welcome contributions, feedback and plain old complaining. Feel free to open an issue or shoot us a message to developer@tenta.io. If you'd like to contribute, please open a pull request and send us an email to sign a contributor agreement.

About Tenta

The AdBlock library is brought to you by Team Tenta. Tenta is your private, encrypted browser that protects your data instead of selling it. We're building a next-generation browser that combines all the privacy tools you need, including built-in OpenVPN. Everything is encrypted by default. That means your bookmarks, saved tabs, web history, web traffic, downloaded files, IP address and DNS. A truly incognito browser that's fast and easy.

Note: This repository contains no code from the uBlock or uBlock Origin projects.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(outputPath string, forIOS bool) (err error)

Build - constructs new filters

outputPath : path and filename for the new filter forIOS : toggles between d.a.w.g. (android) or JSON (iOS) format

func Init

func Init(filterCacheDir string, c *Config) (err error)

Init - initialize for the export side of operations

filterCacheDir : directory where assets are cached cfg : configuration options

func SetLoggingEnabled

func SetLoggingEnabled(b bool)

SetLoggingEnabled -- toggle logging for package

Types

type Config

type Config struct {
	CompileDebugAsset bool          // use debug assets when building non-iOS filters
	CacheValidity     time.Duration // TTL for cached files on disk
	IOSFilterCutoffNo uint32        // the number of rules that can fit into one JSON
	HttpClient        *http.Client  // HTTP client used to download all assets
	Profile           ProfileType   // how aggressive the d.a.w.g. filter should be
	ListUrlBalanced   string        // list containing the exceptions for the balanced profile
	ListUrlEssential  string        // list containing the exceptions for the essential profile
	// contains filtered or unexported fields
}

NOTE Profiles use a different logic: `assetsUrl` is the most restrictive list (strict), and `ListUrlBalanced` and `ListUrlEssential` are lists containing exceptions for the rules found in `assetUrl`.

func DefaultConfig

func DefaultConfig() *Config

func (*Config) SetAssetsUrl

func (c *Config) SetAssetsUrl(url string)

func (*Config) SetCustomUrl

func (c *Config) SetCustomUrl(url string)

sets a custom asset URL

type ProfileType

type ProfileType uint8
const (
	ProfileTypeUnknown ProfileType = iota
	ProfileTypeEssential
	ProfileTypeBalanced
	ProfileTypeStrict
)

func ParseProfileType

func ParseProfileType(s string) ProfileType

func (ProfileType) String

func (p ProfileType) String() string

type UBlockHelper

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

UBlockHelper -- object to use in superior layers.

func Deserialize

func Deserialize(enc []byte) (*UBlockHelper, error)

Deserialize -- Deserializes the graph

func (*UBlockHelper) Search

func (u *UBlockHelper) Search(URL string) (bool, error)

Search -- returns true if networking should block request, false otherwise

Jump to

Keyboard shortcuts

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