Class SqliteDomainFilterChain
- Namespace
- VpnHood.Core.Filtering.Sqlite
- Assembly
- VpnHood.Core.Filtering.Sqlite.dll
Provides the stage of a domain filter pipe that holds a SqliteDomainFilter for each database a folder's manifest lists, and swaps them when the manifest changes.
public sealed class SqliteDomainFilterChain : IDomainFilter, IDisposable
- Inheritance
-
SqliteDomainFilterChain
- Implements
- Inherited Members
Remarks
The databases decide first, the one the manifest lists last first, each only for what those before it left at Default; then the next stage. 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
Remarks
The client reads a flow's domain name from its TLS handshake only while the pipe is not empty, or while its options force the names to be logged.
Methods
Create(IDomainFilter?, string, bool, CancellationToken)
Creates the stage for a folder: it reads the folder's manifest and opens each database it lists.
public static Task<SqliteDomainFilterChain> Create(IDomainFilter? next, string dbFolder, bool autoDisposeNextFilter, CancellationToken cancellationToken)
Parameters
nextIDomainFilterThe stage that decides after the databases, which no swap touches, or null.
dbFolderstringThe folder of the manifest and its databases.
autoDisposeNextFilterbooltrue to dispose
nextwith this stage.cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<SqliteDomainFilterChain>
A task whose result is the stage.
Exceptions
- JsonException
The manifest is not valid JSON.
- InvalidDataException
The manifest is the JSON
null.- OperationCanceledException
cancellationTokenwas 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(string?)
Decides what happens to a flow for a domain name, by the databases, then by the next stage.
public FilterAction Process(string? domain)
Parameters
Returns
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
cancellationTokenCancellationTokenThe 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
cancellationTokenwas 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
Remarks
It occurs after a swap of the databases, and when the next stage's event does.