Class IpLocationSqliteBuilder
- Namespace
- VpnHood.Net.IpLocations.Providers.SqliteProvider
- Assembly
- VpnHood.Net.IpLocations.Providers.SqliteProvider.dll
Provides the means to build the SQLite database IpLocationSqliteProvider reads, from the zip of country IP ranges BuildLocalIpRangeLocationDb(Stream, string, CancellationToken) builds.
public static class IpLocationSqliteBuilder
- Inheritance
-
IpLocationSqliteBuilder
- Inherited Members
Methods
Build(IAsset, SqliteConnection, CancellationToken)
Builds the database on a connection, which it opens when it is closed, unless the database already holds the zip's build, which the zip's stamp tells. A rebuild replaces the IpLocations and Metadata tables in one transaction, so one that fails or is canceled before its commit leaves the last build. The database is compacted after the commit: a failure or a cancellation there leaves the new build, not compacted.
public static Task Build(IAsset zip, SqliteConnection connection, CancellationToken cancellationToken)
Parameters
zipIAssetThe zip of country IP ranges.
connectionSqliteConnectionThe connection; the caller keeps owning it.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
ziporconnectionis null.
Build(IAsset, string, CancellationToken)
Builds the database in a file, unless the file already holds the zip's build, which the zip's stamp tells.
public static Task Build(IAsset zip, string dbPath, CancellationToken cancellationToken)
Parameters
zipIAssetThe zip of country IP ranges.
dbPathstringThe database file; its folder is made when missing.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
zipis null.
ToBytes(IPAddress)
Converts an IP address to the database's key form: its 16 IPv6 bytes, an IPv4 address mapped to IPv6 first.
public static byte[] ToBytes(IPAddress ipAddress)
Parameters
ipAddressIPAddressThe IP address.
Returns
- byte[]
The 16 bytes.