Table of Contents

Class IpRangeListDbBuilder

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

Provides the build of a split IP database from plain lists of ranges, stored as given.

public class IpRangeListDbBuilder : SplitIpDbBuilder
Inheritance
IpRangeListDbBuilder
Inherited Members

Remarks

The signature's factory runs at every EnsureAsync(string, CancellationToken), so keep it cheap; the sets' factories run only when a build runs.

Constructors

IpRangeListDbBuilder(Func<string>, Func<IpRangeOrderedList>?, Func<IpRangeOrderedList>?, Func<IpRangeOrderedList>?)

Provides the build of a split IP database from plain lists of ranges, stored as given.

public IpRangeListDbBuilder(Func<string> sourceSignatureFactory, Func<IpRangeOrderedList>? includesFactory = null, Func<IpRangeOrderedList>? excludesFactory = null, Func<IpRangeOrderedList>? blocksFactory = null)

Parameters

sourceSignatureFactory Func<string>

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

includesFactory Func<IpRangeOrderedList>

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

excludesFactory Func<IpRangeOrderedList>

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

blocksFactory Func<IpRangeOrderedList>

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

Remarks

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.

InsertRangesAsync(SplitIpDbInserter, CancellationToken)

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

protected override Task InsertRangesAsync(SplitIpDbInserter inserter, CancellationToken cancellationToken)

Parameters

inserter SplitIpDbInserter

The inserter, which adds each range 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. The ranges of a set must not overlap: a lookup checks only the range whose start is the greatest at or below the address.

Exceptions

SqliteException

SQLite refused a row.

OperationCanceledException

The build's cancellation was requested.