Table of Contents

Class DomainListDbBuilder

Namespace
VpnHood.Core.Filtering.Sqlite
Assembly
VpnHood.Core.Filtering.Sqlite.dll

Provides the build of a split domain database from plain lists of domain names.

public class DomainListDbBuilder : SplitDomainDbBuilder
Inheritance
DomainListDbBuilder
Inherited Members

Remarks

Each name is stored as NormalizeDomain(string?) gives it, with its labels reversed; a blank one is dropped. The signature's factory runs at every EnsureAsync(string, CancellationToken), so keep it cheap; the sets' factories run only when a build runs.

Constructors

DomainListDbBuilder(Func<string>, Func<IReadOnlyList<string>>?, Func<IReadOnlyList<string>>?, Func<IReadOnlyList<string>>?)

Provides the build of a split domain database from plain lists of domain names.

public DomainListDbBuilder(Func<string> sourceSignatureFactory, Func<IReadOnlyList<string>>? includesFactory = null, Func<IReadOnlyList<string>>? excludesFactory = null, Func<IReadOnlyList<string>>? blocksFactory = null)

Parameters

sourceSignatureFactory Func<string>

Gives the source's signature (GetSourceSignature()).

includesFactory Func<IReadOnlyList<string>>

Gives the include set, or null to leave it empty.

excludesFactory Func<IReadOnlyList<string>>

Gives the exclude set, or null to leave it empty.

blocksFactory Func<IReadOnlyList<string>>

Gives the block set, or null to leave it empty.

Remarks

Each name is stored as NormalizeDomain(string?) gives it, with its labels reversed; a blank one is dropped. The signature's factory runs at every EnsureAsync(string, CancellationToken), so keep it cheap; the sets' factories run only when a build runs.

Methods

GetSourceSignature()

Gets the identity of the source of the sets, which a build stores in the database: it must change exactly when the sets would.

public override string GetSourceSignature()

Returns

string

The identity, compared as a string.

Remarks

EnsureAsync(string, CancellationToken) calls it every time, so keep it cheap: hashes and file sizes and times, never a parse of the source.

InsertDomainsAsync(SplitDomainDbInserter, CancellationToken)

Writes the source's domain names through an inserter, during a build.

protected override Task InsertDomainsAsync(SplitDomainDbInserter inserter, CancellationToken cancellationToken)

Parameters

inserter SplitDomainDbInserter

The inserter, which adds each name to the build's transaction.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Remarks

It is called only when a build runs.

Exceptions

SqliteException

SQLite refused a row.

OperationCanceledException

The build's cancellation was requested.