Table of Contents

Class SqliteIpFilterChain

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

Provides the stage of an IP filter pipe that holds a SqliteIpFilter for each database a folder's manifest lists, and swaps them when the manifest changes.

public sealed class SqliteIpFilterChain : IIpFilter, IDisposable
Inheritance
SqliteIpFilterChain
Implements
Inherited Members

Remarks

The next stage decides first, and its verdict stands unless it is Default; then the databases do, in the manifest's order, each only for what those before it left at Default. A swap never touches the next stage. See SplitDbManifest.

Properties

IsEmpty

Gets a value indicating whether the pipe holds no rule, so it can only answer Default. Read it again when Changed occurs.

public bool IsEmpty { get; }

Property Value

bool

true while every database's sets are empty and the next stage, if any, is empty too.

Methods

Create(IIpFilter?, string, bool, CancellationToken)

Creates the stage for a folder: it reads the folder's manifest and opens each database it lists.

public static Task<SqliteIpFilterChain> Create(IIpFilter? next, string dbFolder, bool autoDisposeNextFilter, CancellationToken cancellationToken)

Parameters

next IIpFilter

The stage that decides first, which no swap touches, or null.

dbFolder string

The folder of the manifest and its databases.

autoDisposeNextFilter bool

true to dispose next with this stage.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<SqliteIpFilterChain>

A task whose result is the stage.

Exceptions

JsonException

The manifest is not valid JSON.

InvalidDataException

The manifest is the JSON null.

OperationCanceledException

cancellationToken was canceled.

Dispose()

Closes the databases, without raising Changed, and disposes the next stage when this stage was made to. A lookup after it gets the next stage's verdict, or Default.

public void Dispose()

Process(IpProtocol, IpEndPointValue)

Decides what happens to a flow.

public FilterAction Process(IpProtocol protocol, IpEndPointValue endPoint)

Parameters

protocol IpProtocol

The flow's protocol.

endPoint IpEndPointValue

The flow's destination.

Returns

FilterAction

The verdict; Default when the pipe has no objection.

Remarks

The next stage decides first, then the databases, in the manifest's order.

Reconfigure(CancellationToken)

Tells the pipe that its configuration outside the program, such as a database's path, may have changed.

public Task Reconfigure(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Remarks

Each stage passes it to its next one; a stage that owns such configuration reads it again and swaps its own parts, raising Changed if its verdicts may differ.

Exceptions

JsonException

The manifest is not valid JSON.

InvalidDataException

The manifest is the JSON null.

OperationCanceledException

cancellationToken was canceled.

Events

Changed

Occurs when the pipe's verdicts may have changed, as when a stage swaps its rules. A stage raises its next stage's event as its own, so the event reaches the outermost stage; a stage whose verdicts never change never raises it.

public event EventHandler? Changed

Event Type

EventHandler

Remarks

It occurs after a swap of the databases, and when the next stage's event does.