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
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
nextIIpFilterThe stage that decides first, 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<SqliteIpFilterChain>
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(IpProtocol, IpEndPointValue)
Decides what happens to a flow.
public FilterAction Process(IpProtocol protocol, IpEndPointValue endPoint)
Parameters
protocolIpProtocolThe flow's protocol.
endPointIpEndPointValueThe 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
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.